mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: preserve cmdarg_stack
* parse.y (brace_body, do_body): preserve cmdarg_stack so that `do` after cmdarg in a block should be `do_block` and bound to the outer method. [ruby-core:72482] [Bug #11873] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c924e2db96
commit
f4ac0d75d9
3 changed files with 38 additions and 5 deletions
|
@ -1,10 +1,12 @@
|
||||||
Wed Sep 21 13:38:44 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Sep 21 13:47:33 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (brace_body, do_body): preserve cmdarg_stack so that
|
||||||
|
`do` after cmdarg in a block should be `do_block` and bound to
|
||||||
|
the outer method. [ruby-core:72482] [Bug #11873]
|
||||||
|
|
||||||
* parse.y: `do` after cmdarg in parentheses should be `do_block`
|
* parse.y: `do` after cmdarg in parentheses should be `do_block`
|
||||||
and bound to the outer method. [ruby-core:72482] [Bug #11873]
|
and bound to the outer method. [ruby-core:72482] [Bug #11873]
|
||||||
|
|
||||||
Wed Sep 21 13:32:00 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
||||||
|
|
||||||
* parse.y (brace_body, do_body): extract block bodies.
|
* parse.y (brace_body, do_body): extract block bodies.
|
||||||
|
|
||||||
Tue Sep 20 23:02:50 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Sep 20 23:02:50 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
14
parse.y
14
parse.y
|
@ -3759,13 +3759,23 @@ brace_block : '{'
|
||||||
;
|
;
|
||||||
|
|
||||||
brace_body : {$<vars>$ = dyna_push();}
|
brace_body : {$<vars>$ = dyna_push();}
|
||||||
|
{$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);}
|
||||||
opt_block_param compstmt
|
opt_block_param compstmt
|
||||||
{$$ = new_brace_body($2, $3); dyna_pop($<vars>1);}
|
{
|
||||||
|
$$ = new_brace_body($3, $4);
|
||||||
|
dyna_pop($<vars>1);
|
||||||
|
CMDARG_SET($<num>2);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
do_body : {$<vars>$ = dyna_push();}
|
do_body : {$<vars>$ = dyna_push();}
|
||||||
|
{$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);}
|
||||||
opt_block_param compstmt
|
opt_block_param compstmt
|
||||||
{$$ = new_do_body($2, $3); dyna_pop($<vars>1);}
|
{
|
||||||
|
$$ = new_do_body($3, $4);
|
||||||
|
dyna_pop($<vars>1);
|
||||||
|
CMDARG_SET($<num>2);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
case_body : keyword_when args then
|
case_body : keyword_when args then
|
||||||
|
|
|
@ -840,6 +840,27 @@ eom
|
||||||
assert_valid_syntax %q{a b(c(d)), :e do end}, bug11873
|
assert_valid_syntax %q{a b(c(d)), :e do end}, bug11873
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_block_after_cmdarg_in_paren
|
||||||
|
bug11873 = '[ruby-core:72482] [Bug #11873]'
|
||||||
|
def bug11873.p(*);end;
|
||||||
|
|
||||||
|
assert_raise(LocalJumpError, bug11873) do
|
||||||
|
bug11873.instance_eval do
|
||||||
|
p p{p p;p(p)}, tap do
|
||||||
|
raise SyntaxError, "should not be passed to tap"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_raise(LocalJumpError, bug11873) do
|
||||||
|
bug11873.instance_eval do
|
||||||
|
p p{p(p);p p}, tap do
|
||||||
|
raise SyntaxError, "should not be passed to tap"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def not_label(x) @result = x; @not_label ||= nil end
|
def not_label(x) @result = x; @not_label ||= nil end
|
||||||
|
|
Loading…
Reference in a new issue