From: mame@... Date: 2017-11-27T07:13:31+00:00 Subject: [ruby-core:83885] [Ruby trunk Feature#3163][Rejected] 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). Status changed from Assigned to Rejected This ticket looks hopeless even if we leave it as open. Also, the current behavior is widely accepted by many people. Eregon, if you really want to change this behavior, could you please try to create a patch that has less side effect and then reopen this ticket? Thank you. ---------------------------------------- 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-67923 * Author: Eregon (Benoit Daloze) * Status: Rejected * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * 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 `<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 -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>