1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Differentiate ... in lambda arguments

This commit is contained in:
Nobuyoshi Nakada 2020-06-01 23:43:31 +09:00
parent 9d24ddbb53
commit c0ba35f334
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 7 additions and 2 deletions

View file

@ -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);

View file

@ -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/)