Skip to content

Commit 9b6907b

Browse files
committed
Bring back #arg_rest local
1 parent 5c0b38f commit 9b6907b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/prism/debug.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,21 @@ def self.cruby_locals(source)
5959
stack = [ISeq.new(RubyVM::InstructionSequence.compile(source).to_a)]
6060

6161
while (iseq = stack.pop)
62-
locals << iseq.local_table
62+
names = [*iseq.local_table]
63+
names.map!.with_index do |name, index|
64+
# When an anonymous local variable is present in the iseq's local
65+
# table, it is represented as the stack offset from the top.
66+
# However, when these are dumped to binary and read back in, they
67+
# are replaced with the symbol :#arg_rest. To consistently handle
68+
# this, we replace them here with their index.
69+
if name == :"#arg_rest"
70+
names.length - index + 1
71+
else
72+
name
73+
end
74+
end
75+
76+
locals << names
6377
iseq.each_child { |child| stack << child }
6478
end
6579

0 commit comments

Comments
 (0)