summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-03-08 13:13:22 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2023-03-08 13:13:23 -0800
commit309dd50a01203ac107c12e5a962e6aa6add75529 (patch)
treee399dedcf0a8f3edc076b1a91a79662f63685bc3
parentcc54e1cf48a232b19e2a69302403bdaa4433cb7a (diff)
downloadruby-309dd50a01203ac107c12e5a962e6aa6add75529.tar.gz
Fix node search in bindgen
This is to fix a weird bindgen behavior on Matt's branch: https://github.com/ruby/ruby/pull/7393
-rwxr-xr-xtool/rjit/bindgen.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/tool/rjit/bindgen.rb b/tool/rjit/bindgen.rb
index b37bd31ce9..5751cc0ad2 100755
--- a/tool/rjit/bindgen.rb
+++ b/tool/rjit/bindgen.rb
@@ -146,7 +146,14 @@ class BindingGenerator
end
# TODO: Support nested declarations
- nodes_index = nodes.group_by(&:spelling).transform_values(&:last)
+ nodes_index = nodes.group_by(&:spelling).transform_values do |values|
+ # Try to search a declaration with definitions
+ node_with_children = values.find { |v| !v.children.empty? }
+ next node_with_children if node_with_children
+
+ # Otherwise, assume the last one is the main declaration
+ values.last
+ end
# Define types
@types.each do |type|