Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.7
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Parser, Ruby 1.9.2
-
Labels:None
-
Number of attachments :
Description
I noticed this while working on some custom library code to implement '!~'
Patch to add this to RubySpec, which currently fails in JRuby 1.6.7: https://github.com/jruby/rubyspec/pull/2
irb session showing the failure:
% JRUBY_OPTS=--1.9 irb >> JRUBY_VERSION + " " + JRUBY_REVISION => "1.6.7 3e82bc8" >> class Foo; def !~(val); return val; end; end => nil >> Foo.new.send(:"!~", /bar/) => /bar/ >> Foo.new !~ /bar/ => true
In the above example, 'Foo.new !~ /bar/' should have returned /bar/, not true.
Appears to be a parsing problem. It's parsing as in 1.8, as !(a =~ b):
system ~/projects/jruby $ ast -e 'a =~ b' AST: RootNode 0 NewlineNode 0 CallOneArgNode:=~ 0 VCallNode:a 0 ArrayNode 0 VCallNode:b 0 system ~/projects/jruby $ ast -e 'a !~ b' AST: RootNode 0 NewlineNode 0 NotNode 0 CallOneArgNode:=~ 0 VCallNode:a 0 ArrayNode 0 VCallNode:b 0 system ~/projects/jruby $ jruby --1.8 -S ast -e 'a !~ b' AST: RootNode 0 NewlineNode 0 NotNode 0 CallOneArgNode:=~ 0 VCallNode:a 0 ArrayNode 0 VCallNode:b 0It should parse as a call to :!~.