Closed sega-yarkin closed 2 years ago
It looks like the reason is a check for falsy value here.
The generated: true
in meta seems can not ignore these warnings. I tried changing the code with the pash2
trick, which avoid the dialyzer guard_fail
warning.
suppress_warning(
quote do
case (case :erlang.phash2(1, 1) do
0 -> right
1 -> nil
end) do
x when x in [nil, false] ->
raise ExUnit.AssertionError,
expr: expr,
message: "Expected truthy, got #{inspect(right)}"
_ ->
:ok
end
end
)
Environment
Current behavior
ExUnit.Assertions.assert/1
produces Dialyzer warning when Dialyzer can figure out a type of right or left-hand side expressions, and it cannot benil
orfalse
.It looks like the reason is a check for falsy value here. Not sure if there is an easy way to do something with it, maybe the warning can be suppressed in ExUnit, so users don't have to deal with it.
Example
Dialyzer's warnings:
Generated Erlang code (truncated):
Expected behavior
No warnings