-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.2.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]
Elixir 1.18.2 (compiled with Erlang/OTP 27)
Operating system
macos
Current behavior
Some refactoring surfaced an unused variable warning that should have also been present in the original code. Shrinking it down, it seems assert is swallowing unused variable warnings when the assignment is happening deep in.
all of these tests have an unused variable x
, but the first does not warn about it.
test "missing warning" do
assert Enum.member?(1..100, x = 1)
end
test "correctly warns without assert" do
Enum.member?(1..100, x = 1)
end
test "correctly warns with assert in" do
assert (x = 1) in 1..100
end
output:
warning: variable "x" is unused (if the variable is not meant to be used, prefix it with an underscore)
│
xx │ Enum.member?(1..100, x = 1)
│ ~
warning: variable "x" is unused (if the variable is not meant to be used, prefix it with an underscore)
│
xx │ assert (x = 1) in 1..100
│ ~
Expected behavior
warn for all unused variables =)
Metadata
Metadata
Assignees
Labels
No labels