Skip to content

Commit c46bdad

Browse files
committed
* parse.y (block_call): rules for block_call after block_call.
based on a patch by pasberth ruby#102 [ruby-dev:45308][Bug ruby#6115] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 45f3651 commit c46bdad

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Tue Mar 6 01:34:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* parse.y (block_call): rules for block_call after block_call.
4+
based on a patch by pasberth https://github.com/ruby/ruby/pull/102
5+
[ruby-dev:45308][Bug #6115]
6+
17
Tue Mar 6 01:24:13 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
28

39
* parse.y (block_command, block_call): simplified rules.

parse.y

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3856,6 +3856,30 @@ block_call : command do_block
38563856
$$ = method_optarg($$, $4);
38573857
%*/
38583858
}
3859+
| block_call dot_or_colon operation2 opt_paren_args brace_block
3860+
{
3861+
/*%%%*/
3862+
block_dup_check($4, $5);
3863+
$5->nd_iter = NEW_CALL($1, $3, $4);
3864+
$$ = $5;
3865+
fixpos($$, $1);
3866+
/*%
3867+
$$ = dispatch4(command_call, $1, $2, $3, $4);
3868+
$$ = method_add_block($$, $5);
3869+
%*/
3870+
}
3871+
| block_call dot_or_colon operation2 command_args do_block
3872+
{
3873+
/*%%%*/
3874+
block_dup_check($4, $5);
3875+
$5->nd_iter = NEW_CALL($1, $3, $4);
3876+
$$ = $5;
3877+
fixpos($$, $1);
3878+
/*%
3879+
$$ = dispatch4(command_call, $1, $2, $3, $4);
3880+
$$ = method_add_block($$, $5);
3881+
%*/
3882+
}
38593883
;
38603884

38613885
method_call : operation

test/ruby/test_syntax.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ def test_newline_in_block_parameters
6363
end
6464
end
6565

66+
tap do |_,
67+
bug6115 = '[ruby-dev:45308]',
68+
blockcall = '["elem"].each_with_object [] do end',
69+
methods = [['map', 'no'], ['inject([])', 'with']],
70+
blocks = [['do end', 'do'], ['{}', 'brace']],
71+
*|
72+
[%w'. dot', %w':: colon'].product(methods, blocks) do |(c, n1), (m, n2), (b, n3)|
73+
m = m.tr_s('()', ' ').strip if n2 == 'do'
74+
name = "test_#{n3}_block_after_blockcall_#{n1}_#{n2}_arg"
75+
code = "#{blockcall}#{c}#{m} #{b}"
76+
define_method(name) {assert_valid_syntax(code, bug6115)}
77+
end
78+
end
79+
6680
private
6781

6882
def make_tmpsrc(f, src)

0 commit comments

Comments
 (0)
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