This code:
defmodule Vector do
use TypedStruct
typedstruct do
field :x, integer(), enforce: true
field :y, integer(), enforce: true
end
@spec add(Vector.t(), Vector.t()) :: Vector.t()
def add(%Vector{x: x1, y: y1}, %Vector{x: x2, y: y2}), do: %Vector{x: x1 + x2, y: y1 + y2}
end
Gives this warning on the spec:
Type specification is a subtype of the success typing.
Function:
Vector.add/2
Type specification:
@spec add(t(), t()) :: t()
Success typing:
@spec add(%Vector{:x => number(), :y => number(), _ => _}, %Vector{
:x => number(),
:y => number(),
_ => _
}) :: %Vector{:x => number(), :y => number()}
I’ve set these warnings in elixirls: ["underspecs", "unmatched_returns", "error_handling", "specdiffs"]
Does anyone have an idea what’s wrong or how to fix this?