Existing issue
Elixir and Erlang/OTP versions
Erlang/OTP 28 [erts-16.4.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Interactive Elixir (1.21.0-dev)
Operating system
any
Current behavior
The following code demonstrates that map update incorrectly infers input domain with mixed keys
Repro:
defmodule MixedKey do
def replace(m, flag) do
key = if flag, do: :a, else: 1
%{m | key => :new}
end
def run, do: replace(%{1 => :old}, false)
end
IO.inspect(MixedKey.run()) # %{1 => :new}
Result: the code works fine but reports a false positive warning:
warning: incompatible types given to replace/2:
replace(%{1 => :old}, false)
given types:
%{integer() => :old}, false
but expected one of:
%{..., a: term()}, term()
└─ iex:25: MixedKey.run/0
Note this issue is distinct from #15625
Expected behavior
No false positive warning. atom keys should not be inferred as required unless the whole kay type is constrained to atoms
Existing issue
Elixir and Erlang/OTP versions
Erlang/OTP 28 [erts-16.4.0.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Interactive Elixir (1.21.0-dev)
Operating system
any
Current behavior
The following code demonstrates that map update incorrectly infers input domain with mixed keys
Repro:
Result: the code works fine but reports a false positive warning:
Note this issue is distinct from #15625
Expected behavior
No false positive warning. atom keys should not be inferred as required unless the whole kay type is constrained to atoms