From: B Kelly Date: 2010-12-24T09:30:59+09:00 Subject: [ruby-core:33851] [Ruby 1.9-Bug#4198][Open] parse error involving spaceship operator Bug #4198: parse error involving spaceship operator http://redmine.ruby-lang.org/issues/show/4198 Author: B Kelly Status: Open, Priority: Normal Category: core, Target version: 1.9.2 ruby -v: ruby 1.9.2p110 (2010-12-20 revision 30269) [i386-darwin10.4.0] Hi, I'm not sure if this is a bug? I'm getting a parse error on the last line of the following code, unless I add parenthesis: op-test-simple.rb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Opper def / (other) self end def + (other) self end def <=> (other) self end end foo = Opper.new("foo") bar = Opper.new("bar") baz = Opper.new("baz") quux = Opper.new("quux") joe = Opper.new("joe") mama = Opper.new("mama") so = Opper.new("so") fat = Opper.new("fat") quick = Opper.new("quick") brown = Opper.new("brown") fox = Opper.new("fox") foo + bar / baz + quux / joe + mama <=> so + fat / quick + brown <=> fox ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $ ruby19 -v op-test-simple.rb ruby 1.9.2p110 (2010-12-20 revision 30269) [i386-darwin10.4.0] op-test-simple.rb:29: syntax error, unexpected tCMP quick + brown <=> fox ^ op-test-simple.rb:29: warning: useless use of a variable in void context However, if parenthesis are added, like: (quick + brown <=> fox) or: quick + (brown <=> fox) then the parse error does not occur. Regards, Bill ---------------------------------------- http://redmine.ruby-lang.org