From b81db531b24a6824bf5b89d8460baed5d5418835 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 8 Jan 2025 12:03:12 +0900 Subject: [PATCH] [Bug #21011] `nd_value` is NULL in massign --- compile.c | 2 +- test/ruby/test_parse.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compile.c b/compile.c index 585420214b..73fc303037 100644 --- a/compile.c +++ b/compile.c @@ -10417,7 +10417,7 @@ compile_shareable_literal_constant(rb_iseq_t *iseq, LINK_ANCHOR *ret, enum rb_pa VALUE lit = Qnil; DECL_ANCHOR(anchor); - enum node_type type = nd_type(node); + enum node_type type = node ? nd_type(node) : NODE_NIL; switch (type) { case NODE_TRUE: *value_p = Qtrue; diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index a2f64200f3..eaf9412ded 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1721,6 +1721,15 @@ x = __ENCODING__ end; end + def test_shareable_constant_value_massign + a = eval_separately("#{<<~"begin;"}\n#{<<~'end;'}") + begin; + # shareable_constant_value: experimental_everything + A, = 1 + end; + assert_equal(1, a) + end + def test_if_after_class assert_valid_syntax('module if true; Object end::Kernel; end') assert_valid_syntax('module while true; break Object end::Kernel; end')