Skip to content

Fixes #7218. Empty rescue block returns exception object instead of nil.#7282

Merged
enebo merged 1 commit intojruby:jruby-9.3from
enebo:fix_7218
Aug 1, 2022
Merged

Fixes #7218. Empty rescue block returns exception object instead of nil.#7282
enebo merged 1 commit intojruby:jruby-9.3from
enebo:fix_7218

Conversation

@enebo
Copy link
Member

@enebo enebo commented Aug 1, 2022

The fix was an error in our parser. When we get exception variables in
a rescue statement we will make effectively '_e = $!' and then append
whatever is actually in the body of the exception body. In MRI's case
it ends up being 'nil'. In our case it was 'null'. Our impl thinks it
is smart and realizes nothing is happening and what should you append
if it is null anyways and just left the body as only '_e = $!'. We
needed '_e = $!; nil'.

Trivial fix is to make sure any null return from compstmt in this grammar
production will always just be nil. Impact from this change should only
effect the case when a rescue body is empty and in the precence of an
exception variable. What we did was wrong. I see no risk.

… of nil.

The fix was an error in our parser.  When we get exception variables in
a rescue statement we will make effectively '_e = $!' and then append
whatever is actually in the body of the exception body.  In MRI's case
it ends up being 'nil'.  In our case it was 'null'.  Our impl thinks it
is smart and realizes nothing is happening and what should you append
if it is null anyways and just left the body as only '_e = $!'.  We
needed '_e = $!; nil'.

Trivial fix is to make sure any null return from compstmt in this grammar
production will always just be nil.  Impact from this change should only
effect the case when a rescue body is empty and in the precence of an
exception variable.  What we did was wrong.  I see no risk.
@enebo enebo added this to the JRuby 9.3.7.0 milestone Aug 1, 2022
@enebo
Copy link
Member Author

enebo commented Aug 1, 2022

HEH. I always do this #7218 is fixed by this (subject never links the two???).

@headius headius linked an issue Aug 1, 2022 that may be closed by this pull request
@enebo enebo merged commit 80bd719 into jruby:jruby-9.3 Aug 1, 2022
@enebo enebo deleted the fix_7218 branch August 1, 2022 19:29
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 this pull request may close these issues.

Empty rescue block returns exception object instead of nil

1 participant