Project

General

Profile

Feature #3163

Updated by mame (Yusuke Endoh) over 9 years ago

=begin 
  
  Hi, 
  Here is a simple example: 
 
  irb for ruby-1.9.2-r27362 
  > print = 0 
  > print :symbol 
  SyntaxError: (irb):2: syntax error, unexpected ':', expecting $end 
  print :symbol 
         ^ 
 	 from .../bin/irb:17:in `<main>' 
 
  Why does this generate a SyntaxError ? 
  It doesn't if you use parentheses of courses: print(:symbol) 
 
  But it shouldn't fail as long as these methods are not keywords. 
  This mean that *any* method which in current scope is also a variable, 
  and accept a symbol as argument (else you would not call it with a symbol), cause this issue: 
 
  def render(*args) 
    puts "in render" 
  end 
  render = 1 
  render :a 
  SyntaxError: (irb):5: syntax error, unexpected ':', expecting $end 
  render :a 
          ^ 
  and this cause it too: 
  render :a => "b" 
  SyntaxError:... 
  (and "method param: value" does not works either) 
 
  I ran a few times in this bug, while using some "p :done"(and having a local var p) to trace the program execution quickly. 
 
  Sorry if this has already been reported, but I didn't see. 
  I think the use of "method :symbol" or "method" is high, so this can be really frustrating to need to use parentheses. 
 
 =end 
 

Back