Skip to content

Commit

Permalink
Support trailing commas in builtin
Browse files Browse the repository at this point in the history
`foo(Primitive.cexpr!('Qnil'),)` causes SEGV without this change.
  • Loading branch information
k0kubun committed Sep 19, 2022
1 parent f8dad61 commit 76a0e81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tool/mk_builtin_loader.rb
Expand Up @@ -87,7 +87,7 @@ def collect_builtin base, tree, name, bs, inlines, locals = nil
tree = tree[2]
next
when :method_add_arg
_, mid, (_, (_, args)) = tree
_method_add_arg, mid, (_arg_paren, args) = tree
case mid.first
when :call
_, recv, sep, mid = mid
Expand All @@ -96,6 +96,11 @@ def collect_builtin base, tree, name, bs, inlines, locals = nil
else
mid = nil
end
# w/ trailing comma: [[:method_add_arg, ...]]
# w/o trailing comma: [:args_add_block, [[:method_add_arg, ...]]]
if args && args.first == :args_add_block
args = args[1]
end
when :vcall
_, mid = tree
when :command # FCALL
Expand Down

0 comments on commit 76a0e81

Please sign in to comment.