Skip to content

A block after the do-block without parenthesis #102

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3874,6 +3874,30 @@ block_call : command do_block
$$ = method_optarg($$, $4);
%*/
}
| block_call '.' operation2 opt_paren_args brace_block
{
/*%%%*/
block_dup_check($4,$5);
$5->nd_iter = NEW_CALL($1, $3, $4);
$$ = $5;
fixpos($$, $1);
/*%
$$ = dispatch4(command_call, $1, ripper_id2sym('.'), $3, $4);
$$ = method_add_block($$, $5);
%*/
}
| block_call '.' operation2 command_args do_block
{
/*%%%*/
block_dup_check($4,$5);
$5->nd_iter = NEW_CALL($1, $3, $4);
$$ = $5;
fixpos($$, $1);
/*%
$$ = dispatch4(command_call, $1, ripper_id2sym('.'), $3, $4);
$$ = method_add_block($$, $5);
%*/
}
;

method_call : operation
Expand Down
32 changes: 32 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,38 @@ def test_newline_in_block_parameters
end
end
end

def test_do_block_after_do_block_without_parenthesis
assert_nothing_raised(SyntaxError) { eval(<<-CODE) }
["elem"].each_with_object [] do
end.map do
end
CODE
end

def test_do_block_after_do_block_without_parenthesis2
assert_nothing_raised(SyntaxError) { eval(<<-CODE) }
["elem"].each_with_object [] do
end.each_with_object [] do
end
CODE
end

def test_brace_block_after_do_block_without_parenthesis
assert_nothing_raised(SyntaxError) { eval(<<-CODE) }
["elem"].each_with_object [] do
end.map {
}
CODE
end

def test_brace_block_after_do_block_without_parenthesis2
assert_nothing_raised(SyntaxError) { eval(<<-CODE) }
["elem"].each_with_object [] do
end.each_with_object([]) {
}
CODE
end

private

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy