[ruby-trunk - Bug #6115][Open] A block after the do-block without parenthesis

Issue #6115 has been reported by Nobuyoshi N…

Bug #6115: A block after the do-block without parenthesis

Author: Nobuyoshi N.
Status: Open
Priority: Normal
Category: core
Target version: 1.9.3
ruby -v: ruby 1.9.3p125 (2012-02-16 revision 34643)

= ((<pull request 102: A block after the do-block without

I think seemingly this source code is no problem:

$ cat unexpected.rb

langs = [“Ruby”]
langs.each_with_object [] do |lang, the_langs|
the_langs << “The #{lang}”
end.each do |the_lang|
puts the_lang

But syntax error:

$ ruby unexpected.rb
unexpected.rb:4: syntax error, unexpected keyword_do
end.each do |the_lang|
unexpected.rb:5: syntax error, unexpected tIDENTIFIER, expecting
keyword_do or ‘{’ or ‘(’

I want to this code behaves like:

$ cat expected.rb

langs = [“Ruby”]
(langs.each_with_object [] do |lang, the_langs|
the_langs << “The #{lang}”
end).each do |the_lang|
puts the_lang

$ ruby expected.rb
The Ruby

I changed the block_call in the parse.y to a primary-expression.

$ ./ruby -I./lib -I. unexpected.rb
The Ruby


上の unexpected.rb はぼくには一見なんの問題もなさそうなコードに見えます。


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs