Forum: JRuby void value expression

Posted by Roger Pack (rogerdpack)
on 2010-02-09 20:56
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
Posted by Roger Gilliar (Guest)
on 2010-02-09 21:38
(Received via mailing list)
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 Pack:

> 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
Posted by Vladimir Sizikov (Guest)
on 2010-02-09 22:40
(Received via mailing list)
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 Gilliar <roger@gilliar.de> 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
Posted by Vladimir Sizikov (Guest)
on 2010-02-09 23:28
(Received via mailing list)
On Tue, Feb 9, 2010 at 10:39 PM, Vladimir Sizikov <vsizikov@gmail.com> 
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! :)

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
Posted by Roger Pack (rogerdpack)
on 2010-02-10 00:28
> But we still need a JRuby bug filed! :)

http://jira.codehaus.org/browse/JRUBY-4549
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.