-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow rescuing exceptions that include a module #14553
Allow rescuing exceptions that include a module #14553
Conversation
issue: Actually, I think the one-line change doesn't cut it. I hadn't though about union types, so the additional spec is very helpful to realize that. We need to make sure to accept a union of module types as well. |
👍 I'll add a spec for that, it definitely worked fine when I was manually playing around with things. I specifically wanted to ensure when you rescue via a module, the compiler knows the exception is an instance of that module in regards to the abstract methods on said module. Kinda makes me wish we could had intersection types to do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just one spec to verify that it won't match any module?
module Foo; end
module Bar; end
class Ex < Exception
include Foo
end
x = 0
begin
begin
raise Ex.new("oh no")
rescue Bar
x = 1
end
rescue ex
ex.message
end
Resolves #14552