[BUG] nil#call
Reported by mitchellvriley | June 16th, 2008 @ 03:03 AM | in 1.0 preview
In Rubinius, nil has a call method but in MRI it doesn't. This, for example, breaks the gem more_money, and probably more.
The problem is that when you yield in a method without a block being passed, nil#call is used to call LocalJumpError.
An example of the problem:
bar = foo.respond_to?(:call) ? foo.call : foo
This throws a LocalJumpError if foo is nil, which is not what you would expect.
Comments and changes to this ticket
-

-

-
Evan Phoenix June 16th, 2008 @ 03:35 PM
- → Assigned user changed from to Evan Phoenix
I've seen this before. Your code doesn't work on 1.9 either, which defines NilClass#call to raise a LocalJumpError as well. I've run into this a couple places and just informed the author that in future ruby version, it needs to be changed anyway and they change it.
I've only seen that occur twice, so it's pretty rare anyway it seems.
We can discuss a workaround if we think this is really common though.
-
Brian Ford November 24th, 2008 @ 03:00 PM
- → Tag changed from to bug compatibility core
- → State changed from new to invalid
We can fake out code like this with a special #respond_to? on NilClass if needed, but fixing the application code is a better solution. Since this is an old ticket, I'm closing it. Reopen if needed.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
