From 43ede3f26cda8c2a4dfbce9a44b0b6aa06281cd7 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Tue, 12 Dec 2023 16:23:50 +0000 Subject: [PRISM] Compile NextNode arguments --- prism_compile.c | 10 +++++++++- test/ruby/test_compile_prism.rb | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/prism_compile.c b/prism_compile.c index f1f70a9b63..2f0161fb47 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -2219,7 +2219,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, } } ADD_LABEL(ret, eend); - PM_NOP; + if (!popped) { + PM_NOP; + } pm_statements_node_t *statements = begin_node->ensure_clause->statements; if (statements) { PM_COMPILE((pm_node_t *)statements); @@ -3919,6 +3921,12 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret, ADD_LABEL(ret, splabel); + if (next_node->arguments) { + PM_COMPILE_NOT_POPPED((pm_node_t *)next_node->arguments); + } + else { + PM_PUTNIL; + } pm_add_ensure_iseq(ret, iseq, 0, src, scope_node); ADD_ADJUST(ret, &dummy_line_node, ISEQ_COMPILE_DATA(iseq)->redo_label); diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 05db94227e..e95baf5d5c 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -902,6 +902,15 @@ module Prism end while i < 5 res CODE + + assert_prism_eval(<<-CODE) + while false + begin + ensure + end + next + end + CODE end def test_RedoNode -- cgit v1.2.3