Dialyxir.Warnings.OpaqueCompare (Dialyxir v1.4.8)

Copy Markdown View Source

Attempt to test for equality or inequality between a term and an opaque type.

This warning replaces the separate :opaque_eq and :opaque_neq warnings starting in OTP 28.

Example

defmodule OpaqueStruct do
  defstruct [:opaque]

  @opaque t :: %OpaqueStruct{}
end

defmodule Example do
  @spec bad_compare(OpaqueStruct.t()) :: boolean()
  def bad_compare(opaque) do
    opaque == %OpaqueStruct{}
  end
end