summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2023-11-02 15:04:09 -0300
committerJemma Issroff <jemmaissroff@gmail.com>2023-11-02 17:46:43 -0300
commit5acced49c2cd9309bcd92f38542e79eb0af87dd1 (patch)
tree371fae18decfda24cf0b5516fdd1f3eeefe5e30a
parent33f18b3d2fac1d79d33b895fca58290823765d07 (diff)
[PRISM] Fix popped for SingletonClassNode
-rw-r--r--prism_compile.c3
-rw-r--r--test/ruby/test_compile_prism.rb2
2 files changed, 3 insertions, 2 deletions
diff --git a/prism_compile.c b/prism_compile.c
index b8aeebd69f..865cbfc116 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -3322,7 +3322,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
const rb_iseq_t *singleton_class = NEW_ISEQ(next_scope_node, rb_fstring_lit("singleton class"), ISEQ_TYPE_CLASS, lineno);
- PM_COMPILE(singleton_class_node->expression);
+ PM_COMPILE_NOT_POPPED(singleton_class_node->expression);
PM_PUTNIL;
ID singletonclass;
CONST_ID(singletonclass, "singletonclass");
@@ -3330,6 +3330,7 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
ADD_INSN3(ret, &dummy_line_node, defineclass,
ID2SYM(singletonclass), singleton_class,
INT2FIX(VM_DEFINECLASS_TYPE_SINGLETON_CLASS));
+ PM_POP_IF_POPPED;
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)singleton_class);
return;
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb
index ae40f4b152..8cf84a7c94 100644
--- a/test/ruby/test_compile_prism.rb
+++ b/test/ruby/test_compile_prism.rb
@@ -654,7 +654,7 @@ module Prism
end
def test_SingletonClassNode
- # assert_prism_eval("class << self; end")
+ assert_prism_eval("class << self; end")
end
def test_StatementsNode