Project

General

Profile

Bug #12073

Updated by nobu (Nobuyoshi Nakada) about 8 years ago

This code causes a syntax error: 

 ~~~ruby ~~~ 
 def a(b:) 
   b 
 end 
 a = 1 
 a b: 9 
 
 # !> program.rb:5: syntax error, unexpected ':', expecting end-of-input 
 # !> a b: (9) 
 # !>       ^ 
 ~~~ 

 However, if we remove the local assignment it works 

 ~~~ruby ~~~ 
 def a(b:) 
   b 
 end 
 a b: 9 # => 9 
 ~~~ 

 Or if we use parentheses it works 

 ~~~ruby ~~~ 
 def a(b:) 
   b 
 end 
 a = 1 
 a(b: 9) # => 9 
 ~~~ 

 Or if we use non-keyword arguments it works 

 ~~~ruby ~~~ 
 def a(b) 
   b 
 end 
 a = 1 
 a 9 # => 9 
 ~~~

Back