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:
nobu 2016-09-21 04:38:46 +00:00
Родитель b458aef0f0
Коммит c924e2db96
3 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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