summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-18 01:30:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-18 01:30:37 +0000
commit676c01bb36d39cf1c0085c4853c9dcbd3b908f35 (patch)
treeae8cb959031fdd737cdac5ae498d43fe9dfa5dba
parent849c4eaaf3a03e98ee1f7aefbf58ec152585e4df (diff)
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
-rw-r--r--ChangeLog5
-rw-r--r--parse.y15
-rw-r--r--test/ruby/test_syntax.rb2
3 files changed, 15 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index b3c1b815b4..a2614373fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/parse.y b/parse.y
index db24e1564b..7eaab6b1b8 100644
--- a/parse.y
+++ b/parse.y
@@ -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
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 8b89f95dc4..49522c42cd 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -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