[前][次][番号順一覧][スレッド一覧]

ruby-changes:73620

From: Takashi <ko1@a...>
Date: Tue, 20 Sep 2022 07:40:00 +0900 (JST)
Subject: [ruby-changes:73620] 76a0e81f40 (master): Support trailing commas in builtin

https://git.ruby-lang.org/ruby.git/commit/?id=76a0e81f40

From 76a0e81f409baf810411677e115bce4f4b05ba5e Mon Sep 17 00:00:00 2001
From: Takashi Kokubun <takashikkbn@g...>
Date: Tue, 20 Sep 2022 07:38:18 +0900
Subject: Support trailing commas in builtin

`foo(Primitive.cexpr!('Qnil'),)` causes SEGV without this change.
---
 tool/mk_builtin_loader.rb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tool/mk_builtin_loader.rb b/tool/mk_builtin_loader.rb
index 784dd30dc1..c5bbd79a80 100644
--- a/tool/mk_builtin_loader.rb
+++ b/tool/mk_builtin_loader.rb
@@ -87,7 +87,7 @@ def collect_builtin base, tree, name, bs, inlines, locals = nil https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L87
       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
@@ -96,6 +96,11 @@ def collect_builtin base, tree, name, bs, inlines, locals = nil https://github.com/ruby/ruby/blob/trunk/tool/mk_builtin_loader.rb#L96
       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
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]