summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-31 11:25:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-31 11:25:38 +0000
commit457521574c4765911c6b486b2b08170dcfd235cc (patch)
tree96da1db58b73c0f7e98a9843ab6eea56fcd7d8e8
parent59845bd47aaf7316d38aba33eb9bba7fac4bcc6d (diff)
parse.y: assignable_error
* parse.y (assignable_gen): should return valid NODE always even on errors. [ruby-core:84565] [Bug #14261] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y14
-rw-r--r--test/ruby/test_parse.rb6
2 files changed, 10 insertions, 10 deletions
diff --git a/parse.y b/parse.y
index 08c3461f70..c260a046dc 100644
--- a/parse.y
+++ b/parse.y
@@ -1984,18 +1984,10 @@ mlhs_node : user_variable
lhs : user_variable
{
$$ = assignable(var_field($1), 0, &@$);
- /*%%%*/
- if (!$$) $$ = new_begin(0, &@$);
- /*%
- %*/
}
| keyword_variable
{
$$ = assignable(var_field($1), 0, &@$);
- /*%%%*/
- if (!$$) $$ = new_begin(0, &@$);
- /*%
- %*/
}
| primary_value '[' opt_call_args rbracket
{
@@ -9980,11 +9972,13 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *lo
#ifdef RIPPER
ID id = get_id(lhs);
# define assignable_result(x) (lhs)
+# define assignable_error() (lhs)
# define parser_yyerror(parser, loc, x) (lhs = assign_error_gen(parser, lhs))
#else
# define assignable_result(x) assignable_result0(x, location)
+# define assignable_error() new_begin(0, location)
#endif
- if (!id) return assignable_result(0);
+ if (!id) return assignable_error();
switch (id) {
case keyword_self:
yyerror0("Can't change the value of self");
@@ -10047,7 +10041,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *lo
compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
}
error:
- return assignable_result(0);
+ return assignable_error();
#undef assignable_result
#undef parser_yyerror
}
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index e26bcdc07e..15c6245bac 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -746,6 +746,12 @@ x = __ENCODING__
end
END
end
+ assert_raise(SyntaxError) do
+ eval "#{<<~"begin;"}\n#{<<~'end;'}", nil, __FILE__, __LINE__+1
+ begin;
+ x, true
+ end;
+ end
end
def test_block_dup