Erlang/OTP 23 [RELEASE CANDIDATE 3] [erts-10.7.1] [source-9a6e292336] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Interactive Elixir (1.11.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
This warning happens when using two :erlang.map_get.
Only happens when using mix compile, pasting this code into shell will not trigger a warning.
defmodule Test do
def test(map) when :erlang.map_get(map,:a) < :erlang.map_get(map,:b) do
map
end
def test(map) do
map
end
end
warning: incompatible types:
:a !~ %{}
in expression:
:erlang.map_get(map, :a)
Conflict found at
lib/test.ex:2: Test.test/1
The warning is correct, you have the arguments flipped. It should be :erlang.map_get(:a, map).
Ah right, lol. Would it be then be an issue the warning is not triggered if copy+pasting the code into REPL?
No, all warnings are not emitted in the REPL. Some checks are only be performed when code is compiled with the parallel compiler which is not the case for the shell.
Thanks I am closing this sorry for my silly mistake.
Most helpful comment
The warning is correct, you have the arguments flipped. It should be
:erlang.map_get(:a, map).