From: "mame (Yusuke Endoh)" Date: 2012-11-20T21:20:31+09:00 Subject: [ruby-core:49697] [ruby-trunk - Feature #3163] SyntaxError when using variable which is also a method in current scope with a Symbol argument Issue #3163 has been updated by mame (Yusuke Endoh). Description updated Target version set to next minor ---------------------------------------- Feature #3163: SyntaxError when using variable which is also a method in current scope with a Symbol argument https://bugs.ruby-lang.org/issues/3163#change-33219 Author: Eregon (Benoit Daloze) Status: Assigned Priority: Low Assignee: matz (Yukihiro Matsumoto) Category: Target version: next minor =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 `
' 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 -- http://bugs.ruby-lang.org/