Lazy generates wrong type when used with one of
bamorim opened this issue · comments
While I was playing around with generating overrides automatically I stumbled upon the following problem:
defmodule TypeCheckProblem do
use TypeCheck
@type! t() :: lazy(t(true | false))
@type! t(value) :: {:value, value} | {:t, t()}
end
Will generate the following typespec:
iex(3)> t TypeCheckProblem.t()
@type t() ::
t(
TypeCheck.Builtin.one_of(
TypeCheck.Builtin.literal(true),
TypeCheck.Builtin.literal(false)
)
)
(This type is managed by `TypeCheck`, which allows checking values against the
type at runtime.)
Full definition:
t() :: lazy(t(true | false))
@type t(value) :: {:value, value} | {:t, t()}
(This type is managed by `TypeCheck`, which allows checking values against the
type at runtime.)
Full definition:
t(value) :: {:value, value} | {:t, t()}
Which causes dialyzer to fail because TypeCheck.Builtin.one_of/2
is not a type.
Thanks for reporting this bug!