Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow parenthesed do-block in cmdarg #2081

Merged
merged 1 commit into from Apr 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/parse.y
Expand Up @@ -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
{
Expand Down
11 changes: 11 additions & 0 deletions test/t/syntax.rb
Expand Up @@ -254,3 +254,14 @@ class << Kernel
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