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

ruby-changes:63471

From: Nobuyoshi <ko1@a...>
Date: Thu, 29 Oct 2020 18:20:04 +0900 (JST)
Subject: [ruby-changes:63471] bf951c763d (master): An ellipsis (...) can only be placed at the beginning

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

From bf951c763d00a4aee8f8c896d1a97c387fa8f30e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 29 Oct 2020 17:37:29 +0900
Subject: An ellipsis (...) can only be placed at the beginning


diff --git a/tool/ruby_vm/loaders/insns_def.rb b/tool/ruby_vm/loaders/insns_def.rb
index 47e4ba2..034905f 100644
--- a/tool/ruby_vm/loaders/insns_def.rb
+++ b/tool/ruby_vm/loaders/insns_def.rb
@@ -25,10 +25,10 @@ grammar = %r' https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L25
     (?<ws>       \g<comment> | \s                                  ){0}
     (?<ident>    [_a-zA-Z] [0-9_a-zA-Z]*                           ){0}
     (?<type>     (?: \g<keyword> \g<ws>+ )* \g<ident>              ){0}
-    (?<arg>      \g<type> \g<ws>+ \g<ident> | \.\.\.               ){0}
+    (?<arg>      \g<type> \g<ws>+ \g<ident>                        ){0}
     (?<argv>     (?# empty ) |
                  void        |
-                 \g<arg> (?: \g<ws>* , \g<ws>* \g<arg> \g<ws>* )*  ){0}
+                 (?: \.\.\. | \g<arg>) (?: \g<ws>* , \g<ws>* \g<arg> \g<ws>* )*  ){0}
     (?<pragma>   \g<ws>* // \s* attr \g<ws>+
                  (?<pragma:type> \g<type>   )              \g<ws>+
                  (?<pragma:name> \g<ident>  )              \g<ws>*
@@ -57,6 +57,10 @@ until scanner.eos? do https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/loaders/insns_def.rb#L57
   ope  = split.(scanner["insn:opes"])
   pop  = split.(scanner["insn:pops"])
   ret  = split.(scanner["insn:rets"])
+  if ope.include?("...")
+    raise sprintf("parse error at %s:%d:%s: operands cannot be variadic",
+                  scanner.__FILE__, scanner.__LINE__, name)
+  end
 
   attrs = []
   while l2 = scanner.scan(/\G#{grammar}\g<pragma>/o) do
-- 
cgit v0.10.2


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

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