diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-08 04:07:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-08 04:07:22 +0000 |
commit | 85280f4b555a7f69692a5a469402c433a36b5eca (patch) | |
tree | 0c85d735184bacb8500dee121ee3fc2555f95534 /parse.y | |
parent | 4dfd3739055388f0395eee81b3297966498f49d5 (diff) | |
download | ruby-85280f4b555a7f69692a5a469402c433a36b5eca.tar.gz |
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.y | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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 '_': |