[Beam] Fix try/catch warnings and reraise unbound variable bug#4392
Open
[Beam] Fix try/catch warnings and reraise unbound variable bug#4392
Conversation
- Skip exception wrapping (#{message => ...}) in catch blocks that don't
reference the exception variable, eliminating unused term warnings
- Strip side-effect-free expressions (literals, variables, pure BIFs like
self/0, node/0) from non-final block positions to avoid "no effect" warnings
- Fix reraise() generating unbound MatchValue variable by adding
CatchReasonVar to context so Throw uses the raw Erlang reason variable
- Add Extended case to containsIdentRef/isCapturedInClosure utilities
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fable_utils:to_list already handles binaries (strings) via unicode:characters_to_list, but Seq.toList was falling through to the compiled seq:to_list which doesn't handle raw BEAM types. Add explicit Replacement for Seq.toList to use fable_utils:to_list. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#{message => ...}) in catch blocks that don't reference the exception variable, usingcontainsIdentRefto check usagestripStrayOk→stripNoEffectto also strip literals, standalone variables, and pure BIF calls (self/0,node/0) from non-final block positionsreraise()generating unboundMatchValuevariable: AddCatchReasonVarto the Beam context soThrowemitserlang:error(Exn_reason_N)directly using the raw Erlang reason variable. This fixesseq.erlcompilation failures wherereraise()in catch blocks produced references to never-bound variablescontainsIdentRef/isCapturedInClosure: Add missingExtended(Throw(...))case so reraise references to catch variables are properly detectedTest plan
seq.erlnow compiles without unbound variable errors🤖 Generated with Claude Code