diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-05-29 21:39:45 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-05-29 21:42:58 +0900 |
commit | 1da5c73932b2dcf2a089f125df1fe7cc4ab9fafd (patch) | |
tree | 4a72831408f73475346c6afb65cf3ab612f82d3b /parse.y | |
parent | 83e905eb4e6d1e8a7ebe88e3b1a6d7efa67ba01c (diff) |
parse.y: fix state after ivar/cvar
* parse.y (parse_atmark): return EXPR_END or EXPR_ENDFN, depending
on the previous state, even incomplete names consistently.
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -8396,6 +8396,7 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state) tokadd(p, '@'); c = nextc(p); } + SET_LEX_STATE(IS_lex_state_for(last_state, EXPR_FNAME) ? EXPR_ENDFN : EXPR_END); if (c == -1 || !parser_is_identchar(p)) { pushback(p, c); RUBY_SET_YYLLOC(loc); @@ -8407,6 +8408,7 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state) } parser_show_error_line(p, &loc); set_yylval_noname(); + SET_LEX_STATE(EXPR_END); return result; } else if (ISDIGIT(c)) { @@ -8417,7 +8419,7 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state) p->lex.pcur = ptr + len; RUBY_SET_YYLLOC(loc); if (result == tIVAR) { - if (IS_lex_state(EXPR_FNAME)) { + if (IS_lex_state_for(last_state, EXPR_FNAME)) { compile_error(p, "`@%c' is not allowed as an instance variable name", c); } else if (ptr[0] == '0') { @@ -8439,7 +8441,6 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state) } if (tokadd_ident(p, c)) return 0; - SET_LEX_STATE(EXPR_END); tokenize_ident(p, last_state); return result; } |