aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2023-10-19 15:31:16 +0100
committerMatt Valentine-House <matt@eightbitraptor.com>2023-10-19 16:57:43 +0100
commit62e340251b577e3a9d11ac5c2b75ad49b8036294 (patch)
tree7a9b27f51c8e2b74bf2b077a8e93256a074d131b
parent9d9aa63e8240fe2226e756e59876d7b3fe908f1d (diff)
downloadruby-62e340251b577e3a9d11ac5c2b75ad49b8036294.tar.gz
Don't add anonymous locals when ISEQ binary debug is on
-rw-r--r--lib/prism/debug.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/prism/debug.rb b/lib/prism/debug.rb
index 6a68a3d33e..6cc0feb9b8 100644
--- a/lib/prism/debug.rb
+++ b/lib/prism/debug.rb
@@ -69,6 +69,8 @@ module Prism
# For the given source, parses with prism and returns a list of all of the
# sets of local variables that were encountered.
def self.prism_locals(source)
+ check_to_debug = ENV["RUBY_ISEQ_DUMP_DEBUG"] == "to_binary"
+
locals = []
stack = [Prism.parse(source).value]
@@ -106,7 +108,7 @@ module Prism
*params.keywords.select(&:value).map(&:name)
]
- sorted << AnonymousLocal if params.keywords.any?
+ sorted << AnonymousLocal if params.keywords.any? && !check_to_debug
# Recurse down the parameter tree to find any destructured
# parameters and add them after the other parameters.
@@ -127,17 +129,17 @@ module Prism
names.map!.with_index do |name, index|
if name == AnonymousLocal
- names.length - index + 1
+ names.length - index + 1 unless check_to_debug
else
name
end
end
- locals << names
+ locals << names.compact
when ClassNode, ModuleNode, ProgramNode, SingletonClassNode
locals << node.locals
when ForNode
- locals << [2]
+ locals << (check_to_debug ? [] : [2])
when PostExecutionNode
locals.push([], [])
when InterpolatedRegularExpressionNode