1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Ensure non-literal expressions shareable if leteral

This commit is contained in:
Nobuyoshi Nakada 2020-12-22 22:10:11 +09:00
parent c0a2d95cf3
commit 8a1e12499b
Notes: git 2020-12-23 13:51:06 +09:00
2 changed files with 8 additions and 6 deletions

View file

@ -11085,7 +11085,7 @@ shareable_literal_value(NODE *node)
}
#ifndef SHAREABLE_BARE_EXPRESSION
#define SHAREABLE_BARE_EXPRESSION 0
#define SHAREABLE_BARE_EXPRESSION 1
#endif
VALUE rb_ractor_make_shareable(VALUE obj);

View file

@ -1252,16 +1252,18 @@ x = __ENCODING__
end
def test_shareable_constant_value_nonliteral
c, d = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}")
assert_raise_separately(Ractor::IsolationError, /unshareable/, "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
# shareable_constant_value: literal
var = [:not_frozen]
C = var
D = begin [] end
[C, D]
end;
assert_not_ractor_shareable(c)
assert_not_ractor_shareable(d)
assert_raise_separately(Ractor::IsolationError, /unshareable/, "#{<<~"begin;"}\n#{<<~'end;'}")
begin;
# shareable_constant_value: literal
D = begin [] end
end;
end
def test_shareable_constant_value_unfrozen