Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

RBX exits without handling LocalJumpError exception in closure #1312

Open
chuckremes opened this Issue · 8 comments

6 participants

@chuckremes
Collaborator

https://gist.github.com/1301471

Adding a "return" to a Proc should produce a LocalJumpError. MRI catches this exception and prints it out. RBX just exits.

Example came from http://innig.net/software/ruby/closures-in-ruby.rb

@bruceadams

jruby-1.6.5 has the same issue. This issue is detected by
"Kernel#eval raises a LocalJumpError if there is no lambda-style closure in the chain"
in rubyspec/core/kernel/eval_spec.rb

@bruceadams

For JRuby, this issue has been know for years, see: http://jira.codehaus.org/browse/JRUBY-2760

@frodsan

Indeed. This is an issue in master:

$ rbx closure.rb 

About to call closure

$ ruby closure.rb 

About to call closure
Failed with LocalJumpError: unexpected return
@razielgn

This is still a issue as of baf153d.
The tricky part is to write a spec for this, since it happens only in a "bare" scope as the example points out.

@chuckremes
Collaborator

This bug was fixed sometime recently. A git-bisect would need to be done to pinpoint the exact time.

@chuckremes chuckremes closed this
@chewi

Please reopen this! It's failing under 2.3.0 and b97eec9.

I've also come across a possibly related problem with calling return inside a call to define_method.

$ rvm ruby-2.1.3 do ruby -e 'define_method(:foo) { 1.times { return "bar" } }; puts foo'
bar
$ rvm rbx-2.3.0 do ruby -e 'define_method(:foo) { 1.times { return "bar" } }; puts foo'
An exception occurred evaluating command line code:

unexpected return (LocalJumpError)

Backtrace:

                     { } in Object#__script__ at -e:1
                        Integer(Fixnum)#times at kernel/common/integer.rb:196
                     { } in Object#__script__ at -e:1
                     { } in Object#__script__ at -e:1
  Rubinius::BlockEnvironment#call_on_instance at kernel/common/block_environment.rb:53
                Kernel(Rubinius::Loader)#eval at kernel/common/eval.rb:176
                       Rubinius::Loader#evals at kernel/loader.rb:612
                        Rubinius::Loader#main at kernel/loader.rb:798
$ rvm rbx-head do ruby -e 'define_method(:foo) { 1.times { return "bar" } }; puts foo'
An exception occurred evaluating command line code:

unexpected return (LocalJumpError)

Backtrace:

                     { } in Object#__script__ at -e:1
                        Integer(Fixnum)#times at kernel/common/integer.rb:196
                     { } in Object#__script__ at -e:1
                     { } in Object#__script__ at -e:1
  Rubinius::BlockEnvironment#call_on_instance at kernel/common/block_environment.rb:53
                Kernel(Rubinius::Loader)#eval at kernel/common/eval.rb:176
                       Rubinius::Loader#evals at kernel/loader.rb:612
                        Rubinius::Loader#main at kernel/loader.rb:798
$ rvm rbx-2.3.0 do ruby -e 'def foo; 1.times { return "bar" }; end; puts foo'
bar
$ rvm rbx-head do ruby -e 'def foo; 1.times { return "bar" }; end; puts foo'
bar
@YorickPeterse

Confirmed this indeed re-occurs on rbx-2.3, re-opening.

@YorickPeterse YorickPeterse reopened this
@chewi chewi referenced this issue in activerecord-hackery/squeel
Open

Fix 4.1 adapter under Rubinius #351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.