Repository navigation
erl_lint: Don't let maybe mark variables in scope as used - #11944
Open
robertoaloi wants to merge 1 commit into
Open
robertoaloi wants to merge 1 commit into
robertoaloi wants to merge 1 commit into
Conversation
A variable bound before a `case`, `if`, `receive` or `try` expression
was not reported as unused when one of its clauses contained a `maybe`
expression:
t(Unused, X) ->
case X of
a -> maybe ok end;
_ -> b
end.
The variable table returned for a `maybe` expression contained every
variable of the enclosing scope, not only the variables the expression
updated. `icrt_export/5` therefore considered all of them reused in
that clause and marked them as used. Return only the updated variables,
as other expressions do.
Contributor
CT Test Results 2 files 101 suites 1h 3m 19s ⏱️ Results for commit 75ee35c. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
meta-codesync Bot
pushed a commit
to WhatsApp/erlang-language-platform
that referenced
this pull request
Oct 26, 2026
Summary: `elp_lint` (our fork of `erl_lint`) did not report an unused variable bound before a `case`, `if`, `receive` or `try` when one of its clauses contained a `maybe` expression; this ports the upstream fix from erlang/otp#11944: ``` t(Unused, X) -> case X of a -> maybe ok end; _ -> b end. ``` - The variable table returned for `maybe` (with and without `else`) contained every variable of the enclosing scope, not only the ones the expression updated. `icrt_export/5` then treated all of them as reused in that clause and marked them as used. - `elp_lint` now returns only the updated variables via `vtupd_unsafe/3`, as other expressions do, matching the upstream change. - New `erlang_service` fixture `maybe_unused_var.erl` covers unused variables before `case` (with `maybe` and `maybe ... else`) and `receive`, and variables used inside `maybe` and `else`, which must not be reported. Reviewed By: alanz Differential Revision: D127201874 fbshipit-source-id: d8dc6866d61e85f4acb7aaa52d6777e91595ae04
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.
A variable bound before a
case,if,receiveortryexpression was not reported as unused when one of its clauses contained amaybeexpression:The variable table returned for a
maybeexpression contained every variable of the enclosing scope, not only the variables the expression updated.icrt_export/5therefore considered all of them reused in that clause and marked them as used. Return only the updated variables, as other expressions do.