summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2022-12-10 13:54:53 +1300
committerGitHub <noreply@github.com>2022-12-10 13:54:53 +1300
commit22d391dc637dd756fdcdfc0ece4a71753b5b2ddb (patch)
tree3f52dd933eccbed682aa8b3ccd5a22fd05a257f0 /cont.c
parent24043031be75cb5119cc4a6c1ffb2c867b567633 (diff)
downloadruby-22d391dc637dd756fdcdfc0ece4a71753b5b2ddb.tar.gz
Add spec for fiber storage. (#6896)
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/cont.c b/cont.c
index e050deefdc..49629efd90 100644
--- a/cont.c
+++ b/cont.c
@@ -2090,10 +2090,17 @@ fiber_storage_validate_each(VALUE key, VALUE value, VALUE _argument)
static void
fiber_storage_validate(VALUE value)
{
+ // nil is an allowed value and will be lazily initialized.
+ if (value == Qnil) return;
+
if (!RB_TYPE_P(value, T_HASH)) {
rb_raise(rb_eTypeError, "storage must be a hash");
}
+ if (RB_OBJ_FROZEN(value)) {
+ rb_raise(rb_eFrozenError, "storage must not be frozen");
+ }
+
rb_hash_foreach(value, fiber_storage_validate_each, Qundef);
}