diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-15 00:44:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-03-15 00:44:51 +0000 |
commit | 3134b20a0129aa072d1cb40a5000297333b5818d (patch) | |
tree | 0ce60d24b14d37645f335da6d0f08b306045463c /parse.y | |
parent | bf4bcaf06115b32b5ffb4ddea972624d3ac7fa50 (diff) |
Show the source line at an invalid class/instance variable
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -7586,9 +7586,12 @@ parse_gvar(struct parser_params *p, const enum lex_state_e last_state) static enum yytokentype parse_atmark(struct parser_params *p, const enum lex_state_e last_state) { + const char *ptr = p->lex.pcur; enum yytokentype result = tIVAR; register int c = nextc(p); + YYLTYPE loc; + p->lex.ptok = ptr - 1; /* from '@' */ newtok(p); tokadd(p, '@'); if (c == '@') { @@ -7598,15 +7601,18 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state) } if (c == -1 || !parser_is_identchar(p)) { pushback(p, c); + RUBY_SET_YYLLOC(loc); if (result == tIVAR) { compile_error(p, "`@' without identifiers is not allowed as an instance variable name"); } else { compile_error(p, "`@@' without identifiers is not allowed as a class variable name"); } + parser_show_error_line(p, &loc); return 0; } else if (ISDIGIT(c)) { + RUBY_SET_YYLLOC(loc); pushback(p, c); if (result == tIVAR) { compile_error(p, "`@%c' is not allowed as an instance variable name", c); @@ -7614,6 +7620,7 @@ parse_atmark(struct parser_params *p, const enum lex_state_e last_state) else { compile_error(p, "`@@%c' is not allowed as a class variable name", c); } + parser_show_error_line(p, &loc); return 0; } |