mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: fix cmdarg in command_args
* parse.y (call_args): fix invalid CMDARG state after command_args followed by tLBRACE_ARG. [ruby-core:86551] [Bug #14690] From: Ilya Bylich <ibylich@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
58a2084483
commit
f168dbd9ef
2 changed files with 17 additions and 0 deletions
13
parse.y
13
parse.y
|
@ -2170,7 +2170,20 @@ command_args : {
|
|||
}
|
||||
call_args
|
||||
{
|
||||
/* call_args can be followed by tLBRACE_ARG (that does CMDARG_PUSH(0) in the lexer)
|
||||
* but the push must be done after CMDARG_POP() in the parser.
|
||||
* So this code does CMDARG_POP() to pop 0 pushed by tLBRACE_ARG,
|
||||
* CMDARG_POP() to pop 1 pushed by command_args,
|
||||
* and CMDARG_PUSH(0) to restore back the flag set by tLBRACE_ARG.
|
||||
*/
|
||||
int lookahead = 0;
|
||||
switch (yychar) {
|
||||
case tLBRACE_ARG:
|
||||
lookahead = 1;
|
||||
}
|
||||
if (lookahead) CMDARG_POP();
|
||||
CMDARG_POP();
|
||||
if (lookahead) CMDARG_PUSH(0);
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -1196,6 +1196,10 @@ x = __ENCODING__
|
|||
end
|
||||
end
|
||||
|
||||
def test_cdmarg_after_command_args_and_tlbrace_arg
|
||||
assert_valid_syntax('let () { m(a) do; end }')
|
||||
end
|
||||
|
||||
=begin
|
||||
def test_past_scope_variable
|
||||
assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}}
|
||||
|
|
Loading…
Reference in a new issue