You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some cases implicitly returned match variables ($1) are being incorrectly returned as nil. Using an explicit return fixes the issue. This was seen on jruby 9.0.0.0.rc1.
Here is a simple script that reproduces the issue:
[gscott@dev tmp]$ jruby --version
jruby 9.0.0.0.rc1 (2.2.2) 2015-06-10 a0bf3b3 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]
[gscott@dev tmp]$ cat test.rb
def parse_char_with_return(string)
if string =~ /Prefix (\w)/
puts "++> parse_char_with_return(#{string}) = #{$1}"
return $1
end
end
def parse_char_wo_return(string)
if string =~ /Prefix (\w)/
puts "++> parse_char_wo_return(#{string}) = #{$1}"
$1
end
end
ret = parse_char_with_return("Prefix A")
puts "==> parse_char_with_return(Prefix A) = #{ret.inspect}"
raise(Exception, 'Failed to return correct value') if ret.nil?
puts ''
ret = parse_char_wo_return("Prefix A")
puts "==> parse_char_wo_return(Prefix A) = #{ret.inspect}"
[gscott@dev tmp]$ jruby test.rb
++> parse_char_with_return(Prefix A) = A
==> parse_char_with_return(Prefix A) = "A"
++> parse_char_wo_return(Prefix A) = A
==> parse_char_wo_return(Prefix A) = nil
Both parse_char_with_return and parse_char_wo_return should return "A" but the latter returns nil as shown above.
The text was updated successfully, but these errors were encountered:
jruby -X-C ../snippets/cat1.rb
++> parse_char_with_return(Prefix A) = A
==> parse_char_with_return(Prefix A) = "A"
++> parse_char_wo_return(Prefix A) = A
==> parse_char_wo_return(Prefix A) = "A"
Full build interpreter does have this issue:
jruby -X-C -Xjit.threshold=0 -Xjit.background=false ../snippets/cat1.rb
++> parse_char_with_return(Prefix A) = A
==> parse_char_with_return(Prefix A) = "A"
++> parse_char_wo_return(Prefix A) = A
==> parse_char_wo_return(Prefix A) = nil
This is good because it means yet again we can fix this without dipping into the bytecode layer (yay IR). I just tested this on master so it is still broken.
I also verified this does not affect 1.7 so @donv issue has same behavior but it is something broken in concurrent access (in #3031)
In some cases implicitly returned match variables ($1) are being incorrectly returned as nil. Using an explicit return fixes the issue. This was seen on jruby 9.0.0.0.rc1.
Here is a simple script that reproduces the issue:
Both parse_char_with_return and parse_char_wo_return should return "A" but the latter returns nil as shown above.
The text was updated successfully, but these errors were encountered: