mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 61523: [Backport #14261]
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/branches/ruby_2_5@62509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aa58701dee
commit
2292ea6a8f
3 changed files with 11 additions and 11 deletions
14
parse.y
14
parse.y
|
@ -1983,18 +1983,10 @@ mlhs_node : user_variable
|
||||||
lhs : user_variable
|
lhs : user_variable
|
||||||
{
|
{
|
||||||
$$ = assignable(var_field($1), 0, &@$);
|
$$ = assignable(var_field($1), 0, &@$);
|
||||||
/*%%%*/
|
|
||||||
if (!$$) $$ = new_begin(0, &@$);
|
|
||||||
/*%
|
|
||||||
%*/
|
|
||||||
}
|
}
|
||||||
| keyword_variable
|
| keyword_variable
|
||||||
{
|
{
|
||||||
$$ = assignable(var_field($1), 0, &@$);
|
$$ = assignable(var_field($1), 0, &@$);
|
||||||
/*%%%*/
|
|
||||||
if (!$$) $$ = new_begin(0, &@$);
|
|
||||||
/*%
|
|
||||||
%*/
|
|
||||||
}
|
}
|
||||||
| primary_value '[' opt_call_args rbracket
|
| primary_value '[' opt_call_args rbracket
|
||||||
{
|
{
|
||||||
|
@ -9957,11 +9949,13 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *lo
|
||||||
#ifdef RIPPER
|
#ifdef RIPPER
|
||||||
ID id = get_id(lhs);
|
ID id = get_id(lhs);
|
||||||
# define assignable_result(x) (lhs)
|
# define assignable_result(x) (lhs)
|
||||||
|
# define assignable_error() (lhs)
|
||||||
# define parser_yyerror(parser, x) (lhs = assign_error_gen(parser, lhs))
|
# define parser_yyerror(parser, x) (lhs = assign_error_gen(parser, lhs))
|
||||||
#else
|
#else
|
||||||
# define assignable_result(x) assignable_result0(x, location)
|
# define assignable_result(x) assignable_result0(x, location)
|
||||||
|
# define assignable_error() new_begin(0, location)
|
||||||
#endif
|
#endif
|
||||||
if (!id) return assignable_result(0);
|
if (!id) return assignable_error();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case keyword_self:
|
case keyword_self:
|
||||||
yyerror0("Can't change the value of self");
|
yyerror0("Can't change the value of self");
|
||||||
|
@ -10024,7 +10018,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));
|
compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
return assignable_result(0);
|
return assignable_error();
|
||||||
#undef assignable_result
|
#undef assignable_result
|
||||||
#undef parser_yyerror
|
#undef parser_yyerror
|
||||||
}
|
}
|
||||||
|
|
|
@ -746,6 +746,12 @@ x = __ENCODING__
|
||||||
end
|
end
|
||||||
END
|
END
|
||||||
end
|
end
|
||||||
|
assert_raise(SyntaxError) do
|
||||||
|
eval "#{<<~"begin;"}\n#{<<~'end;'}", nil, __FILE__, __LINE__+1
|
||||||
|
begin;
|
||||||
|
x, true
|
||||||
|
end;
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_block_dup
|
def test_block_dup
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.5.0"
|
#define RUBY_VERSION "2.5.0"
|
||||||
#define RUBY_RELEASE_DATE "2018-02-21"
|
#define RUBY_RELEASE_DATE "2018-02-21"
|
||||||
#define RUBY_PATCHLEVEL 26
|
#define RUBY_PATCHLEVEL 27
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2018
|
#define RUBY_RELEASE_YEAR 2018
|
||||||
#define RUBY_RELEASE_MONTH 2
|
#define RUBY_RELEASE_MONTH 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue