mirror of
https://github.com/ruby/ruby.git
synced 2026-01-27 12:34:21 +00:00
[PRISM] Fix CallNode with arguments when popped
Previously emitting a call node with an argument followed by another node would cause the argument to be mistakenly omitted from the argument list causing a stack underflow. ``` PRISM: ************************************************** -- raw disasm-------- 0000 putself ( 0) 0001 send <calldata:puts, 1>, nil ( 0) * 0004 pop ( 0) 0005 putobject 1 ( 0) 0007 leave ( 0) --------------------- ```
This commit is contained in:
parent
5cff4c5aa3
commit
dcb9ded6c9
@ -1403,7 +1403,7 @@ pm_setup_args(pm_arguments_node_t *arguments_node, int *flags, struct rb_callinf
|
||||
default: {
|
||||
orig_argc++;
|
||||
post_splat_counter++;
|
||||
PM_COMPILE(argument);
|
||||
PM_COMPILE_NOT_POPPED(argument);
|
||||
|
||||
if (has_splat) {
|
||||
// If the next node starts the keyword section of parameters
|
||||
|
||||
@ -694,6 +694,12 @@ module Prism
|
||||
|
||||
def test_CallNode
|
||||
assert_prism_eval("to_s")
|
||||
|
||||
# with arguments
|
||||
assert_prism_eval("eval '1'")
|
||||
|
||||
# with arguments and popped
|
||||
assert_prism_eval("eval '1'; 1")
|
||||
end
|
||||
|
||||
def test_CallAndWriteNode
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user