From: Benoit Daloze Date: 2011-01-18T10:55:16+09:00 Subject: Re: Obscure syntax error On 17 January 2011 22:35, Ryan Davis wrote: > > On Jan 17, 2011, at 02:25 , Rolf Timmermans wrote: > >> x = nil >> x "y" >> #=> bar.rb:2:in `
': undefined method `x' for main:Object (NoMethodError) >> >> x = nil >> x :y >> #=> bar.rb:2: syntax error, unexpected ':', expecting $end > > I think the explanation is simple: you (most likely) found a bug in the parser. > > You should report this to ruby-core@ Hi, Sorry, I already found it: http://redmine.ruby-lang.org/issues/show/3163 However, it seems to have re-appeared :( Doing in a file: p = 3 p :sym Results in: ruby 1.9.3dev (2010-12-28 trunk 30412) [x86_64-darwin10.5.0] /Users/benoitdaloze/Desktop/test.rb:210: warning: `:' after local variable is interpreted as binary operator /Users/benoitdaloze/Desktop/test.rb:210: warning: even though it seems like symbol literal /Users/benoitdaloze/Desktop/test.rb:210: warning: possibly useless use of a variable in void context /Users/benoitdaloze/Desktop/test.rb:210: syntax error, unexpected ':', expecting $end p :sym ^ If I remember correctly, it worked with Nobu's patch. It must have been reverted since. Please post your ideas/suggestions about this bug, it is not so easy with the operators. So, for the record, the Symbol is not accepted because it is believed as part of the ternary operator ? :