summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-19 20:42:58 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-12-23 13:50:42 +0900
commit7a094146e6ef38453a7e475450d90a9c83ea2277 (patch)
treedae133999b6504425ff1c9082974d813b7404b54 /vm.c
parentf14aaa2b1282d6dea9fad3d050e65828f1e269e1 (diff)
Changed shareable literal semantics [Feature #17397]
When `literal`, check if the literal about to be assigned to a constant is ractor-shareable, otherwise raise `Ractor::Error` at runtime instead of `SyntaxError`.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3950
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 3e775f8..a30ba9c 100644
--- a/vm.c
+++ b/vm.c
@@ -995,6 +995,7 @@ collect_outer_variable_names(ID id, VALUE val, void *ptr)
}
VALUE rb_ractor_make_shareable(VALUE obj);
+VALUE rb_ractor_ensure_shareable(VALUE obj, VALUE name);
static const rb_env_t *
env_copy(const VALUE *src_ep, VALUE read_only_variables)
@@ -3181,6 +3182,12 @@ m_core_make_shareable(VALUE recv, VALUE obj)
}
static VALUE
+m_core_ensure_shareable(VALUE recv, VALUE obj, VALUE name)
+{
+ return rb_ractor_ensure_shareable(obj, name);
+}
+
+static VALUE
core_hash_merge_kwd(VALUE hash, VALUE kw)
{
rb_hash_foreach(rb_to_hash_type(kw), kwmerge_i, hash);
@@ -3345,6 +3352,7 @@ Init_VM(void)
rb_define_method_id(klass, idProc, f_proc, 0);
rb_define_method_id(klass, idLambda, f_lambda, 0);
rb_define_method(klass, "make_shareable", m_core_make_shareable, 1);
+ rb_define_method(klass, "ensure_shareable", m_core_ensure_shareable, 2);
rb_obj_freeze(fcore);
RBASIC_CLEAR_CLASS(klass);
rb_obj_freeze(klass);