[ruby/prism] Bring back #arg_rest local
https://github.com/ruby/prism/commit/9b6907b727
This commit is contained in:
parent
9b40f42c22
commit
5d9d07a491
@ -59,7 +59,21 @@ module Prism
|
||||
stack = [ISeq.new(RubyVM::InstructionSequence.compile(source).to_a)]
|
||||
|
||||
while (iseq = stack.pop)
|
||||
locals << iseq.local_table
|
||||
names = [*iseq.local_table]
|
||||
names.map!.with_index do |name, index|
|
||||
# When an anonymous local variable is present in the iseq's local
|
||||
# table, it is represented as the stack offset from the top.
|
||||
# However, when these are dumped to binary and read back in, they
|
||||
# are replaced with the symbol :#arg_rest. To consistently handle
|
||||
# this, we replace them here with their index.
|
||||
if name == :"#arg_rest"
|
||||
names.length - index + 1
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
locals << names
|
||||
iseq.each_child { |child| stack << child }
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user