diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-19 21:33:29 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-04-19 21:33:29 +0900 |
| commit | e5368c006ad1f5f1dcf31ddb4093c45b5621a00c (patch) | |
| tree | c88ada396febdcb276c3b91e49dbe169fa29e681 | |
| parent | 426f80b191a0130e94a1daebf204ece0433e9d78 (diff) | |
| parent | b16697982eff27ef45d8c82b5e086cefd8716597 (diff) | |
| download | mruby-e5368c006ad1f5f1dcf31ddb4093c45b5621a00c.tar.gz mruby-e5368c006ad1f5f1dcf31ddb4093c45b5621a00c.zip | |
Merge pull request #2081 from nobu/parenthesed_do-block_in_cmdarg
Allow parenthesed do-block in cmdarg
| -rw-r--r-- | src/parse.y | 10 | ||||
| -rw-r--r-- | test/t/syntax.rb | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/parse.y b/src/parse.y index 345ac5756..053b5f3e9 100644 --- a/src/parse.y +++ b/src/parse.y @@ -2039,9 +2039,15 @@ primary : literal p->cmdarg_stack = $<stack>1; $$ = $3; } - | tLPAREN_ARG expr {p->lstate = EXPR_ENDARG;} rparen + | tLPAREN_ARG { - $$ = $2; + $<stack>1 = p->cmdarg_stack; + p->cmdarg_stack = 0; + } + expr {p->lstate = EXPR_ENDARG;} rparen + { + p->cmdarg_stack = $<stack>1; + $$ = $3; } | tLPAREN_ARG {p->lstate = EXPR_ENDARG;} rparen { diff --git a/test/t/syntax.rb b/test/t/syntax.rb index fac73aa7b..d761b1991 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -254,3 +254,14 @@ assert('External command execution.') do end true end + +assert('parenthesed do-block in cmdarg') do + class ParenDoBlockCmdArg + def test(block) + block.call + end + end + x = ParenDoBlockCmdArg.new + result = x.test (proc do :ok; end) + assert_equal :ok, result +end |
