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:
parent
9d24ddbb53
commit
c0ba35f334
2 changed files with 7 additions and 2 deletions
4
parse.y
4
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);
|
||||
|
|
|
@ -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/)
|
||||
|
|
Loading…
Add table
Reference in a new issue