diff options
| author | tompng <tomoyapenguin@gmail.com> | 2024-12-13 02:19:58 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu.nakada@gmail.com> | 2024-12-15 16:55:30 +0900 |
| commit | e06b3b5ad1f6453ebebc5d9a54d82e3bb2ab116f (patch) | |
| tree | 18e7517576f95fd16ffbf1858707a7bc4aa11c1a /test/ruby | |
| parent | 730731cc86d1cf87a3478ffc242d52c70eda2e42 (diff) | |
[Bug #20927] Fix compile_shareable_literal_constant for hash with keyword splat
Compilation of NODE_HASH in compile_shareable_literal_constant does not support hash that contains keyword splat.
If there is a keyword splat, fallback to default case.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12338
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_parse.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index d52e480eb9..0ed4dd84e7 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -2,6 +2,7 @@ # frozen_string_literal: false require 'test/unit' require 'stringio' +require_relative '../lib/parser_support' class TestParse < Test::Unit::TestCase def setup @@ -1609,6 +1610,26 @@ x = __ENCODING__ assert_ractor_shareable(a[0]) end + def test_shareable_constant_value_hash_with_keyword_splat + # Prism compiler does not support keyword splat in Ractor constant [Bug #20916] + omit if ParserSupport.prism_enabled? + + a, b = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: experimental_everything + # [Bug #20927] + x = { x: {} } + y = { y: {} } + A = { **x } + B = { x: {}, **y } + [A, B] + end; + assert_ractor_shareable(a) + assert_ractor_shareable(b) + assert_equal({ x: {}}, a) + assert_equal({ x: {}, y: {}}, b) + end + def test_shareable_constant_value_unshareable_literal assert_raise_separately(Ractor::IsolationError, /unshareable object to C/, "#{<<~"begin;"}\n#{<<~'end;'}") |
