Skip to content

Commit 149e2ff

Browse files
committed
Fix Ruby head build
1 parent a8c05e8 commit 149e2ff

File tree

3 files changed

+5
-38
lines changed

3 files changed

+5
-38
lines changed

lib/prism/debug.rb

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

6161
while (iseq = stack.pop)
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
62+
locals << iseq.local_table
7763
iseq.each_child { |child| stack << child }
7864
end
7965

@@ -141,7 +127,7 @@ def self.prism_locals(source)
141127
sorted << AnonymousLocal if params.keywords.any?
142128

143129
if params.keyword_rest.is_a?(ForwardingParameterNode)
144-
sorted.push(:*, :&, :"...")
130+
sorted.push(:*, :**, :&, :"...")
145131
elsif params.keyword_rest.is_a?(KeywordRestParameterNode)
146132
sorted << params.keyword_rest.name if params.keyword_rest.name
147133
end

src/prism.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,9 +3999,8 @@ pm_keyword_hash_node_create(pm_parser_t *parser) {
39993999
*/
40004000
static void
40014001
pm_keyword_hash_node_elements_append(pm_keyword_hash_node_t *hash, pm_node_t *element) {
4002-
// If the element being added is not an AssocNode or does not have a symbol key, then
4003-
// we want to turn the STATIC_KEYS flag off.
4004-
// TODO: Rename the flag to SYMBOL_KEYS instead.
4002+
// If the element being added is not an AssocNode or does not have a symbol
4003+
// key, then we want to turn the SYMBOL_KEYS flag off.
40054004
if (!PM_NODE_TYPE_P(element, PM_ASSOC_NODE) || !PM_NODE_TYPE_P(((pm_assoc_node_t *) element)->key, PM_SYMBOL_NODE)) {
40064005
pm_node_flag_unset((pm_node_t *)hash, PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS);
40074006
}

test/prism/locals_test.rb

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# There have also been changes made in other versions of Ruby, so we only want
99
# to test on the most recent versions.
10-
return if !defined?(RubyVM::InstructionSequence) || RUBY_VERSION < "3.2"
10+
return if !defined?(RubyVM::InstructionSequence) || RUBY_VERSION < "3.4.0"
1111

1212
# Omit tests if running on a 32-bit machine because there is a bug with how
1313
# Ruby is handling large ISeqs on 32-bit machines
@@ -57,24 +57,6 @@ class LocalsTest < TestCase
5757
# Dead code eliminated
5858
invalid << "whitequark/ruby_bug_10653.txt"
5959

60-
# case :a
61-
# in Symbol(*lhs, x, *rhs)
62-
# end
63-
todos << "seattlerb/case_in.txt"
64-
65-
# <<~HERE
66-
# #{<<~THERE}
67-
# THERE
68-
# HERE
69-
todos << "seattlerb/heredoc_nested.txt"
70-
71-
# Ruby < 3.3.0 fails to parse:
72-
#
73-
# <<-' HERE'
74-
# foo
75-
# HERE
76-
invalid << "heredocs_leading_whitespace.txt" if RUBY_VERSION < "3.3.0"
77-
7860
base = File.join(__dir__, "fixtures")
7961
skips = invalid | todos
8062

0 commit comments

Comments
 (0)