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
Map.fetch(%{a: 1}, k) with k :: term() can return {:ok, 1} yet this repro shows the implementation neglects this
import Module.Types.Descr
m = closed_map(a: {integer(), false})
IO.inspect(map_get(m, term()), label: "map_get term")
IO.inspect(map_get(m, atom()), label: "map_get atom")
{:ok, r} = map_put(m, term(), pid())
IO.puts(to_quoted_string(r))
IO.inspect(subtype?(closed_map(a: {pid(), false}), r), label: "subtype (must be true)")
{_, d, _} = map_update(m, term(), atom([:x]), false)
IO.puts(to_quoted_string(d))
Prints:
map_get term: :error
map_get atom: {:ok, %{bitmap: 8}}
%{
atom() => pid(),
bitstring() => pid(),
float() => pid(),
fun() => pid(),
integer() => pid(),
list() => pid(),
map() => pid(),
pid() => pid(),
port() => pid(),
reference() => pid(),
tuple() => pid(),
a: integer()
}
subtype (must be true): false
%{a: integer()}
This issue affects only API. Real code produces dynamic(term()) keys
Expected behavior
Correct handling of term() keys
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
Map.fetch(%{a: 1}, k)withk :: term()can return{:ok, 1}yet this repro shows the implementation neglects thisPrints:
This issue affects only API. Real code produces
dynamic(term())keysExpected behavior
Correct handling of
term()keys