You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this this minimal repro emits an unused alias warning for alias A.B.C
defmodule A.B.C do
@callback foo() :: :ok
end
defmodule A do
use ExUnit.Case
alias A.B.C
test "with submodule" do
defmodule B do
@behaviour C
@impl C
def foo, do: :ok
end
assert true
end
end
warning: unused alias C
│
7 │ alias A.B.C
│ ~
│
└─ test/foo_test.exs:7:3
Expected behavior
no warning.
obviously, there are trivial fixes the user can take to fix this situation, like
define the submodules outside of the test macro
move the alias into the submodule itself
but i thought it might be worth shining a light on for you. no worries if it's a wontfix =) found via styler user issue
The text was updated successfully, but these errors were encountered:
The contents of a defmodule are only executed when the code runs, in this case, the test. So it is a won't fix because the alias has indeed not been used by the time the file has done compiling. It is an expected false warning. You can pass alias A.B.C, warn: false instead. Thanks for the report!
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.2.2] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]
Elixir 1.18.2 (compiled with Erlang/OTP 27)
Operating system
macos
Current behavior
this this minimal repro emits an unused alias warning for
alias A.B.C
Expected behavior
no warning.
obviously, there are trivial fixes the user can take to fix this situation, like
test
macrobut i thought it might be worth shining a light on for you. no worries if it's a wontfix =)
found via styler user issue
The text was updated successfully, but these errors were encountered: