Skip to content

Commit

Permalink
[PRISM] prevent underflow on popped splatarray (ruby#8657)
Browse files Browse the repository at this point in the history
prevent underflow on popped splatarray

This only emits the splat array node when not popped
  • Loading branch information
HParker authored Oct 16, 2023
1 parent 06a4011 commit 6e88b72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions prism_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,9 +2397,9 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
PM_COMPILE(splat_node->expression);
}

ADD_INSN1(ret, &dummy_line_node, splatarray, Qtrue);

PM_POP_IF_POPPED;
if (!popped) {
ADD_INSN1(ret, &dummy_line_node, splatarray, Qtrue);
}
return;
}
case PM_STATEMENTS_NODE: {
Expand Down
4 changes: 4 additions & 0 deletions test/ruby/test_compile_prism.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ def test_HashNode
test_prism_eval("[ Prism: [:b, :c]]")
end

def test_SplatNode
test_prism_eval("*b = []")
end

############################################################################
# Jumps #
############################################################################
Expand Down

0 comments on commit 6e88b72

Please sign in to comment.