Void value expression

I noticed that this code:

def go
a = true
b = nil
return a.nil? or b.nil?
end
puts go

actually returns false in jruby–I would have expected it to return
true, and in MRI (1.8.6, 1.9.1), it yields:

bad.rb:4: void value expression

(so I suppose if it wants to match MRI, it should raise that error).
Is this a bug?
Thanks.
-r

I think the problem has to do with the low operator precedence of the
or operator.

The following code works:

def go
a = true
b = nil

return (a.nil? or b.nil?)

end
puts go

But I agree that the different implementations should at least throw
the same error message.

Regards
Roger

Am 09.02.2010 um 20:56 schrieb Roger P.:

actually returns false in jruby–I would have expected it to return


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi Roger and Roger,

I agree that this seems to be a JRuby compatibility issue and it is
definitely worth filing a JRuby issue for that, could you guys file
one?

Ideally, we should have RubySpec test for that as well.

Thanks,
–Vladimir

On Tue, Feb 9, 2010 at 9:38 PM, Roger G. [email protected] wrote:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

But we still need a JRuby bug filed! :slight_smile:

http://jira.codehaus.org/browse/JRUBY-4549

On Tue, Feb 9, 2010 at 10:39 PM, Vladimir S. [email protected]
wrote:

Ideally, we should have RubySpec test for that as well.

So, I just added RubySpecs for this case:
http://github.com/rubyspec/rubyspec/commit/38bd0643c3e7bdba0aecf5eb91b0be9b56b5b5d7

But we still need a JRuby bug filed! :slight_smile:

Thanks,
–Vladimir

return (a.nil? or b.nil?)
Roger

puts go
-r


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs