I think that is the intended behavior. However, if your goal is to get some type of warning for accessing an unknown key on a struct, then you are in luck as elixir 1.17 can do this for you - check Elixir v1.17 released: set-theoretic types in patterns, calendar durations, and Erlang/OTP 27 support - The Elixir programming language.
defmodule Testing do
@type status :: :won | :lost
@type t :: %__MODULE__{
status: status()
}
defstruct status: :won
@spec action(t) :: status()
def action(%__MODULE__{} = state) do
state.sttus
end
end























