summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 04:07:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 04:07:22 +0000
commit85280f4b555a7f69692a5a469402c433a36b5eca (patch)
tree0c85d735184bacb8500dee121ee3fc2555f95534 /parse.y
parent4dfd3739055388f0395eee81b3297966498f49d5 (diff)
parse.y: fail if invalid name
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid name character. [ruby-core:54846] [Bug #8375]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y10
1 files changed, 4 insertions, 6 deletions
diff --git a/parse.y b/parse.y
index b677855821..a83f85f1f4 100644
--- a/parse.y
+++ b/parse.y
@@ -7876,7 +7876,8 @@ parser_yylex(struct parser_params *parser)
default:
if (!parser_is_identchar()) {
pushback(c);
- return '$';
+ compile_error(PARSER_ARG "`$%c' is not allowed as a global variable name", c);
+ return 0;
}
case '0':
tokadd('$');
@@ -7891,7 +7892,8 @@ parser_yylex(struct parser_params *parser)
tokadd('@');
c = nextc();
}
- if (c != -1 && ISDIGIT(c)) {
+ if (c != -1 && (ISDIGIT(c) || !parser_is_identchar())) {
+ pushback(c);
if (tokidx == 1) {
compile_error(PARSER_ARG "`@%c' is not allowed as an instance variable name", c);
}
@@ -7900,10 +7902,6 @@ parser_yylex(struct parser_params *parser)
}
return 0;
}
- if (!parser_is_identchar()) {
- pushback(c);
- return '@';
- }
break;
case '_':