summaryrefslogtreecommitdiff
path: root/tool/rjit/bindgen.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/rjit/bindgen.rb')
-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|