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:
parent
849c4eaaf3
commit
676c01bb36
3 changed files with 15 additions and 7 deletions
|
@ -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>
|
Thu Oct 18 09:23:03 2012 Aaron Patterson <aaron@tenderlovemaking.com>
|
||||||
|
|
||||||
* hash.c (initialize_copy): duping should rehash the hash.
|
* hash.c (initialize_copy): duping should rehash the hash.
|
||||||
|
|
15
parse.y
15
parse.y
|
@ -8468,25 +8468,25 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case keyword_self:
|
case keyword_self:
|
||||||
yyerror("Can't change the value of self");
|
yyerror("Can't change the value of self");
|
||||||
break;
|
goto error;
|
||||||
case keyword_nil:
|
case keyword_nil:
|
||||||
yyerror("Can't assign to nil");
|
yyerror("Can't assign to nil");
|
||||||
break;
|
goto error;
|
||||||
case keyword_true:
|
case keyword_true:
|
||||||
yyerror("Can't assign to true");
|
yyerror("Can't assign to true");
|
||||||
break;
|
goto error;
|
||||||
case keyword_false:
|
case keyword_false:
|
||||||
yyerror("Can't assign to false");
|
yyerror("Can't assign to false");
|
||||||
break;
|
goto error;
|
||||||
case keyword__FILE__:
|
case keyword__FILE__:
|
||||||
yyerror("Can't assign to __FILE__");
|
yyerror("Can't assign to __FILE__");
|
||||||
break;
|
goto error;
|
||||||
case keyword__LINE__:
|
case keyword__LINE__:
|
||||||
yyerror("Can't assign to __LINE__");
|
yyerror("Can't assign to __LINE__");
|
||||||
break;
|
goto error;
|
||||||
case keyword__ENCODING__:
|
case keyword__ENCODING__:
|
||||||
yyerror("Can't assign to __ENCODING__");
|
yyerror("Can't assign to __ENCODING__");
|
||||||
break;
|
goto error;
|
||||||
}
|
}
|
||||||
switch (id_type(id)) {
|
switch (id_type(id)) {
|
||||||
case ID_LOCAL:
|
case ID_LOCAL:
|
||||||
|
@ -8526,6 +8526,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
|
||||||
default:
|
default:
|
||||||
compile_error(PARSER_ARG "identifier %s is not valid to set", rb_id2name(id));
|
compile_error(PARSER_ARG "identifier %s is not valid to set", rb_id2name(id));
|
||||||
}
|
}
|
||||||
|
error:
|
||||||
return assignable_result(0);
|
return assignable_result(0);
|
||||||
#undef assignable_result
|
#undef assignable_result
|
||||||
#undef parser_yyerror
|
#undef parser_yyerror
|
||||||
|
|
|
@ -187,8 +187,10 @@ class TestSyntax < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_unassignable
|
def test_unassignable
|
||||||
|
gvar = global_variables
|
||||||
%w[self nil true false __FILE__ __LINE__ __ENCODING__].each do |kwd|
|
%w[self nil true false __FILE__ __LINE__ __ENCODING__].each do |kwd|
|
||||||
assert_raise(SyntaxError) {eval("#{kwd} = nil")}
|
assert_raise(SyntaxError) {eval("#{kwd} = nil")}
|
||||||
|
assert_equal(gvar, global_variables)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue