Project

General

Profile

Bug #14690 ยป cmdarg_in_command_args_followed_by_tlbrace_arg.patch

ibylich (Ilya Bylich), 04/16/2018 12:31 PM

View differences:

parse.y
}
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;
}
;
test/ruby/test_parse.rb
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")}}
    (1-1/1)