diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-19 20:42:58 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-23 13:50:42 +0900 |
commit | 7a094146e6ef38453a7e475450d90a9c83ea2277 (patch) | |
tree | dae133999b6504425ff1c9082974d813b7404b54 /ractor.c | |
parent | f14aaa2b1282d6dea9fad3d050e65828f1e269e1 (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 'ractor.c')
-rw-r--r-- | ractor.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -2442,6 +2442,17 @@ rb_ractor_make_shareable_copy(VALUE obj) return copy; } +VALUE +rb_ractor_ensure_shareable(VALUE obj, VALUE name) +{ + if (!RTEST(rb_ractor_shareable_p(obj))) { + VALUE message = rb_sprintf("cannot assign unshareable object to %"PRIsVALUE, + name); + rb_exc_raise(rb_exc_new_str(rb_eRactorError, message)); + } + return obj; +} + static enum obj_traverse_iterator_result shareable_p_enter(VALUE obj) { |