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

Lint/ShadowedException can't handle multiple rescue blocks #3388

Closed
ptarjan opened this issue Aug 9, 2016 · 3 comments · Fixed by #3389
Closed

Lint/ShadowedException can't handle multiple rescue blocks #3388

ptarjan opened this issue Aug 9, 2016 · 3 comments · Fixed by #3389

Comments

@ptarjan
Copy link
Contributor

ptarjan commented Aug 9, 2016

If you don't know the inheritance between exceptions, why are you complaining about shadowing?


Expected behavior

$ cat a.rb
begin
rescue A, B
  nil
rescue C
  nil
end
$ rubocop a.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

Actual behavior

$ cat a.rb
begin
rescue A, B
  nil
rescue C
  nil
end
$ rubocop a.rb
Inspecting 1 file
W

Offenses:

a.rb:2:1: W: Do not shadow rescued Exceptions
rescue A, B ...
^^^^^^^^^^^

1 file inspected, 1 offense detected

Steps to reproduce the problem

See above

RuboCop version

$ rubocop -V
0.42.0 (using Parser 2.3.1.2, running on ruby 2.2.4 x86_64-darwin15)
@ptarjan
Copy link
Contributor Author

ptarjan commented Aug 9, 2016

/cc @rrosenblum @jonas054

@rrosenblum
Copy link
Contributor

Definitely sounds like a bug. I thought I had a test case to check for a condition like this. I will take a look.

@rrosenblum
Copy link
Contributor

Interesting, rescuing a single custom exception works fine. Rescueing multiple custom exceptions in the same rescue works fine. Rescuing a custom exception in different rescues works. Rescuing multiple custom exceptions in a rescue group followed by a group with a different custom exception causes this bug. I will hopefully find a fix for this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants