aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-15 00:44:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-03-15 00:44:51 +0000
commit3134b20a0129aa072d1cb40a5000297333b5818d (patch)
tree0ce60d24b14d37645f335da6d0f08b306045463c /parse.y
parentbf4bcaf06115b32b5ffb4ddea972624d3ac7fa50 (diff)
downloadruby-3134b20a0129aa072d1cb40a5000297333b5818d.tar.gz
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.y7
1 files changed, 7 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index fd7ba924f9..b904797969 100644
--- a/parse.y
+++ b/parse.y
@@ -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;
}