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

ruby-changes:61596

From: Nobuyoshi <ko1@a...>
Date: Sun, 7 Jun 2020 19:00:12 +0900 (JST)
Subject: [ruby-changes:61596] c0ba35f334 (master): Differentiate `...` in lambda arguments

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

From c0ba35f3344652bca7768cf37f367ff40f5e973e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Mon, 1 Jun 2020 23:43:31 +0900
Subject: Differentiate `...` in lambda arguments


diff --git a/parse.y b/parse.y
index 1848dc5..e7e4bdd 100644
--- a/parse.y
+++ b/parse.y
@@ -9365,6 +9365,10 @@ parser_yylex(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L9365
 		if (p->lex.paren_nest == 0 && looking_at_eol_p(p)) {
 		    rb_warn0("... at EOL, should be parenthesized?");
 		}
+		else if (p->lex.lpar_beg >= 0 && p->lex.lpar_beg+1 == p->lex.paren_nest) {
+		    if (IS_lex_state_for(last_state, EXPR_LABEL))
+			return tDOT3;
+		}
 		return is_beg ? tBDOT3 : tDOT3;
 	    }
 	    pushback(p, c);
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index cf0a93e..6245c73 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -1508,10 +1508,11 @@ eom https://github.com/ruby/ruby/blob/trunk/test/ruby/test_syntax.rb#L1508
     assert_valid_syntax('def nil(...) end')
     assert_valid_syntax('def true(...) end')
     assert_valid_syntax('def false(...) end')
+    unexpected = /unexpected \.{3}/
     assert_syntax_error('iter do |...| end', /unexpected/)
     assert_syntax_error('iter {|...|}', /unexpected/)
-    assert_syntax_error('->... {}', /unexpected/)
-    assert_syntax_error('->(...) {}', /unexpected/)
+    assert_syntax_error('->... {}', unexpected)
+    assert_syntax_error('->(...) {}', unexpected)
     assert_syntax_error('def foo(x, y, z) bar(...); end', /unexpected/)
     assert_syntax_error('def foo(x, y, z) super(...); end', /unexpected/)
     assert_syntax_error('def foo(...) yield(...); end', /unexpected/)
-- 
cgit v0.10.2


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

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