-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Open
Description
Elixir and Erlang/OTP versions
Erlang/OTP 28 [erts-16.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Elixir 1.19.3 (compiled with Erlang/OTP 28)
Also main.
Current behavior
defmodule Repro do
def update(%{"foo" => %Date{year: year} = date}) do
%Date{date | year: year + 1}
end
end warning: a struct for Date is expected on struct update:
%Date{date | year: year + 1}
but got type:
dynamic()
where "date" was given the type:
# type: dynamic()
# from: lib/repro.ex:2:14
%{"foo" => %Date{year: year} = date}
Expected behavior
No warning, like if we use atom keys in the map (def update(%{foo: %Date{year: year} = date}) do).
Even for domain keys, I think variables matching a nested pattern should be inferred with this pattern?
Not sure if it is just a temporary state that will be addressed by #14558 or if it is just a bug.
Originally reported here.
axelson
Metadata
Metadata
Assignees
Labels
No labels