1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

parse.y: fail if yyerror

* parse.y (assignable_gen): fail if yyerror occurred.  fix a bug in
  r36973.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-10-18 01:30:37 +00:00
parent 849c4eaaf3
commit 676c01bb36
3 changed files with 15 additions and 7 deletions

View file

@ -1,3 +1,8 @@
Thu Oct 18 10:30:34 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (assignable_gen): fail if yyerror occurred. fix a bug in
r36973.
Thu Oct 18 09:23:03 2012 Aaron Patterson <aaron@tenderlovemaking.com>
* hash.c (initialize_copy): duping should rehash the hash.

15
parse.y
View file

@ -8468,25 +8468,25 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
switch (id) {
case keyword_self:
yyerror("Can't change the value of self");
break;
goto error;
case keyword_nil:
yyerror("Can't assign to nil");
break;
goto error;
case keyword_true:
yyerror("Can't assign to true");
break;
goto error;
case keyword_false:
yyerror("Can't assign to false");
break;
goto error;
case keyword__FILE__:
yyerror("Can't assign to __FILE__");
break;
goto error;
case keyword__LINE__:
yyerror("Can't assign to __LINE__");
break;
goto error;
case keyword__ENCODING__:
yyerror("Can't assign to __ENCODING__");
break;
goto error;
}
switch (id_type(id)) {
case ID_LOCAL:
@ -8526,6 +8526,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
default:
compile_error(PARSER_ARG "identifier %s is not valid to set", rb_id2name(id));
}
error:
return assignable_result(0);
#undef assignable_result
#undef parser_yyerror

View file

@ -187,8 +187,10 @@ class TestSyntax < Test::Unit::TestCase
end
def test_unassignable
gvar = global_variables
%w[self nil true false __FILE__ __LINE__ __ENCODING__].each do |kwd|
assert_raise(SyntaxError) {eval("#{kwd} = nil")}
assert_equal(gvar, global_variables)
end
end