mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: do after cmdarg in paren
* parse.y: `do` after cmdarg in parentheses 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@56198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b458aef0f0
commit
c924e2db96
3 changed files with 14 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Sep 21 13:38:44 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y: `do` after cmdarg in parentheses should be `do_block`
|
||||
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.
|
||||
|
|
2
parse.y
2
parse.y
|
@ -7911,7 +7911,7 @@ parse_ident(struct parser_params *parser, int c, int cmd_state)
|
|||
if (COND_P()) return keyword_do_cond;
|
||||
if (CMDARG_P() && !IS_lex_state_for(state, EXPR_CMDARG))
|
||||
return keyword_do_block;
|
||||
if (IS_lex_state_for(state, (EXPR_BEG | EXPR_ENDARG)))
|
||||
if (IS_lex_state_for(state, (EXPR_BEG | EXPR_END | EXPR_ENDARG)))
|
||||
return keyword_do_block;
|
||||
return keyword_do;
|
||||
}
|
||||
|
|
|
@ -832,6 +832,14 @@ eom
|
|||
assert_valid_syntax("foo (bar rescue nil)")
|
||||
end
|
||||
|
||||
def test_cmdarg_in_paren
|
||||
bug11873 = '[ruby-core:72482] [Bug #11873]'
|
||||
assert_valid_syntax %q{a b{c d}, :e do end}, bug11873
|
||||
assert_valid_syntax %q{a b(c d), :e do end}, bug11873
|
||||
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
|
||||
|
||||
private
|
||||
|
||||
def not_label(x) @result = x; @not_label ||= nil end
|
||||
|
|
Loading…
Reference in a new issue