Skip to content

Compilation error when using conforms? #146

@lbueso

Description

@lbueso

When a type is defined as follows:

defmodule A do
  use TypeCheck
  @type! t() :: %{v: integer()}

  @spec! f(t()) :: integer()
  def f(x), do: x.v
end

TypeCheck works correctly, but if I try to use TypeCheck.conforms? in the same module where a type is defined, I get a complation error:

defmodule A do
  use TypeCheck
  @type! t() :: %{v: integer()}


  def main() do
    x = 1
    TypeCheck.conforms?(x, t())
  end
end
== Compilation error in file lib/examples.ex ==
** (UndefinedFunctionError) function A.t/0 is undefined (function not available)
    A.t()
    (stdlib 3.17) erl_eval.erl:685: :erl_eval.do_apply/6
    (elixir 1.13.4) lib/code.ex:797: Code.eval_quoted/3
    (type_check 0.12.1) lib/type_check/type.ex:96: TypeCheck.Type.build_unescaped/4
    (type_check 0.12.1) lib/type_check.ex:202: TypeCheck."MACRO-conforms?"/4
    (type_check 0.12.1) expanding macro: TypeCheck.conforms?/2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions