When defining a guarded type with @type!, if the type is used in an @spec! in other module, the functions used in the guard need to be fully qualified. This generates a compilation error:
defmodule A do
use TypeCheck
@type! f :: integer() when is_f(f)
def is_f(_f), do: true
end
defmodule B do
use TypeCheck
@spec! f() :: A.f()
def f(), do: 1
end
== Compilation error in file lib/examples.ex ==
** (CompileError) lib/type_check/spec.ex:4: undefined function is_f/1 (expected B to define such a function or for it to be imported, but none are available)
But this doesn't:
defmodule A do
use TypeCheck
@type! f :: integer() when A.is_f(f)
def is_f(_f), do: true
end
defmodule B do
use TypeCheck
@spec! f() :: A.f()
def f(), do: 1
end
If the @spec! that uses the type is defined in the same module that the guarded @type! this error doesn't appear.
When defining a guarded type with
@type!
, if the type is used in an@spec!
in other module, the functions used in the guard need to be fully qualified. This generates a compilation error:But this doesn't:
If the
@spec!
that uses the type is defined in the same module that the guarded@type!
this error doesn't appear.