From 2a6917b463fa4065f26aea44802e2e24cc494e4c Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 20 Feb 2024 16:45:59 -0500 Subject: Fix string value in hash literal being forced frozen We should pass `false` for `hash_key` for value nodes. Credits to `@kddnewton` for noticing and bisecting. --- test/ruby/test_literal.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 00adbff731..72dcce04e1 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -184,6 +184,11 @@ class TestRubyLiteral < Test::Unit::TestCase list.each { |str| assert_predicate str, :frozen? } end + def test_string_in_hash_literal + hash = eval("# frozen-string-literal: false\n""{foo: 'foo'}") + assert_not_predicate(hash[:foo], :frozen?) + end + if defined?(RubyVM::InstructionSequence.compile_option) and RubyVM::InstructionSequence.compile_option.key?(:debug_frozen_string_literal) def test_debug_frozen_string -- cgit v1.2.3