Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-rescue should not eagerly evaluate its elements #5538

headius opened this Issue Dec 21, 2018 · 0 comments


None yet
1 participant
Copy link

headius commented Dec 21, 2018

When rescuing multiple exceptions, they appear to be evaluated only if needed. For example:

[] ~/projects/rubygems $ ruby -v -e 'begin; raise; rescue StandardError, DumbError; p :here; end'
jruby (2.5.3) 2018-12-21 65a4b42 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [darwin-x86_64]
NameError: uninitialized constant DumbError
  const_missing at org/jruby/
         <main> at -e:1

[] ~/projects/rubygems $ rvm ruby-2.5.3 do ruby -v -e 'begin; raise; rescue StandardError, DumbError; p :here; end'
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]

DumbError does not exist, and yet the rescue handles StandardError properly.

I found this attempting to run RubyGems tests; they disable gems and then have a rescue block like this:

  gem 'minitest', '~> 5.0'
rescue NoMethodError, Gem::LoadError
  # for ruby tests

We raise a NameError for the Gem reference here, and MRI does not.

@headius headius added this to the JRuby milestone Dec 21, 2018

@enebo enebo closed this in 9253169 Dec 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.