diff --git a/compile.c b/compile.c index 5d619e0ca6b8ea..7d5c5b5b127706 100644 --- a/compile.c +++ b/compile.c @@ -4910,7 +4910,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop static inline int static_literal_node_pair_p(const NODE *node, const rb_iseq_t *iseq) { - return RNODE_LIST(node)->nd_head && static_literal_node_p(RNODE_LIST(node)->nd_head, iseq, true) && static_literal_node_p(RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, iseq, true); + return RNODE_LIST(node)->nd_head && static_literal_node_p(RNODE_LIST(node)->nd_head, iseq, true) && static_literal_node_p(RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, iseq, false); } static int diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index 00adbff731dac1..72dcce04e168a6 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -184,6 +184,11 @@ def test_frozen_string_in_array_literal 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