diff --git a/parse.y b/parse.y index 1848dc5890..e7e4bddd50 100644 --- a/parse.y +++ b/parse.y @@ -9365,6 +9365,10 @@ parser_yylex(struct parser_params *p) 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 cf0a93e185..6245c73ec3 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1508,10 +1508,11 @@ eom 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/)