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

Fixed argument forwarding in reserved word method [Bug #16854]

This commit is contained in:
Nobuyoshi Nakada 2020-05-15 12:50:02 +09:00
parent e89b875081
commit 71c166e11e
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
Notes: git 2020-05-15 16:35:59 +09:00
2 changed files with 7 additions and 5 deletions

View file

@ -2152,10 +2152,6 @@ fname : tIDENTIFIER
$$ = $1;
}
| reswords
{
SET_LEX_STATE(EXPR_ENDFN);
$$ = $1;
}
;
fitem : fname
@ -8834,11 +8830,12 @@ parse_ident(struct parser_params *p, int c, int cmd_state)
kw = rb_reserved_word(tok(p), toklen(p));
if (kw) {
enum lex_state_e state = p->lex.state;
SET_LEX_STATE(kw->state);
if (IS_lex_state_for(state, EXPR_FNAME)) {
SET_LEX_STATE(EXPR_ENDFN);
set_yylval_name(rb_intern2(tok(p), toklen(p)));
return kw->id[0];
}
SET_LEX_STATE(kw->state);
if (IS_lex_state(EXPR_BEG)) {
p->command_start = TRUE;
}

View file

@ -1503,6 +1503,11 @@ eom
def test_argument_forwarding
assert_valid_syntax('def foo(...) bar(...) end')
assert_valid_syntax('def foo(...) end')
assert_valid_syntax('def ==(...) end')
assert_valid_syntax('def [](...) end')
assert_valid_syntax('def nil(...) end')
assert_valid_syntax('def true(...) end')
assert_valid_syntax('def false(...) end')
assert_syntax_error('iter do |...| end', /unexpected/)
assert_syntax_error('iter {|...|}', /unexpected/)
assert_syntax_error('->... {}', /unexpected/)