diff options
| author | yui-knk <spiketeika@gmail.com> | 2024-03-19 18:17:46 +0900 |
|---|---|---|
| committer | Yuichiro Kaneko <spiketeika@gmail.com> | 2024-03-21 11:29:09 +0900 |
| commit | 8ba4d7d75fd231b61727eb0561eb686c1d67bfd4 (patch) | |
| tree | 219f536797366539ec276ba0d6c765a632bd2250 /test/ruby | |
| parent | 6650b3aecf6bd3f4bce10a9f1a615683020af186 (diff) | |
Fix unexpected node bug for `shareable_constant_value: literal`
[Bug #20339]
[Bug #20341]
`const_decl_path` changes the value of `NODE **dest`, LHS of an assignment,
with `NODE_LIT` created by `const_decl_path`. `shareable_literal_constant` calls
`const_decl_path` via `ensure_shareable_node` multiple times if RHS of an assignment
is array or hash. This means `NODE **dest` argument of `const_decl_path` can be `NODE_LIT`
from the second time then causes `[BUG] unexpected node: NODE_LIT` in
`rb_node_const_decl_val`.
This commit change to not update `NODE **dest` in `const_decl_path` to
fix the issue.
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_parse.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index a4ca08ec27..62498170fd 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1526,6 +1526,24 @@ x = __ENCODING__ assert_not_ractor_shareable(obj) assert_equal obj, a assert !obj.equal?(a) + + bug_20339 = '[ruby-core:117186] [Bug #20339]' + bug_20341 = '[ruby-core:117197] [Bug #20341]' + a, b = eval_separately(<<~'end;') + # shareable_constant_value: literal + foo = 1 + bar = 2 + A = { foo => bar } + B = [foo, bar] + [A, B] + end; + + assert_ractor_shareable(a) + assert_ractor_shareable(b) + assert_equal([1], a.keys, bug_20339) + assert_equal([2], a.values, bug_20339) + assert_equal(1, b[0], bug_20341) + assert_equal(2, b[1], bug_20341) end def test_shareable_constant_value_nested |
