Bug #3163: SyntaxError when using variable which is also a method in current scope with a Symbol argument
http://redmine.ruby-lang.org/issues/show/3163

Author: Benoit Daloze
Status: Open, Priority: High
Category: core, Target version: 1.9.x
ruby -v: ruby 1.9.2dev (2010-04-17 trunk 27362) [x86_64-darwin10.3.0]

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.


----------------------------------------
http://redmine.ruby-lang.org