Project

General

Profile

Bug #11107

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

As below, lambda literal with do..end block can raise syntax error. 

 ``` 
 $ ./ruby -ve 'p ->() do a(1) do end end' 
 ruby 2.3.0dev (2015-04-26 trunk 50395) [x86_64-darwin14] 
 -e:1: syntax error, unexpected keyword_do_block, expecting keyword_end 
 p ->() do a(1) do end end 
                  ^ 
 ``` 

 The error is not raised when I use {...} block or omit parentheses from method call in lambda. 

 NG cases: 

 ```ruby ``` 
 p ->() do a(1) do end end 
 p ->() do a() do end end 
 p 1, ->() do a(1) do end end 
 ``` 

 OK cases: 

 ```ruby ``` 
 p ->() do a 1 do end end 
 p ->() do a do end end 
 p ->() { a(1) do end } 
 p ->() do a(1) {} end 
 p ->() { a(1) { } } 
 ``` 

 Confirmed versions (same results): 

 * ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-darwin14.3.0] 
 * ruby 2.0.0p598 (2014-11-13) [i386-mingw32] 
 * ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32] 
 * ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14] 
 * ruby 2.3.0dev (2015-04-26 trunk 50395) [x86_64-darwin14]

Back