From 65cca99b30c65d462aa67969e0f16f6e45db4705 Mon Sep 17 00:00:00 2001 From: Jean byroot Boussier Date: Tue, 6 Aug 2024 19:34:39 +0200 Subject: parse.y: const_decl_path don't replace destination node by a literal (#11314) [Bug #20668] The `dest` node is assumed to be a `CDECL`, so overwriting it with a `LIT` cause a crash on the next iteration. Co-authored-by: Jean Boussier --- test/ruby/test_parse.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index c2f02ff809..341d63c38a 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1475,6 +1475,21 @@ x = __ENCODING__ assert !obj.equal?(a) end + def test_shareable_constant_value_literal_const_refs + a = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: literal + # [Bug #20668] + SOME_CONST = { + 'Object' => Object, + 'String' => String, + 'Array' => Array, + } + SOME_CONST + end; + assert_ractor_shareable(a) + end + def test_shareable_constant_value_nested a, b = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}") begin; -- cgit v1.2.3