Skip to content

Commit

Permalink
Improve TypeCheck.Spec.problem_tuple() to make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed May 31, 2022
1 parent f0b489e commit 17fbb94
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/type_check.ex
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ defmodule TypeCheck do
{:ok, 42}
iex> {:error, type_error} = TypeCheck.dynamic_conforms(20, fourty_two)
iex> type_error.message
"At lib/type_check.ex:279:
"At lib/type_check.ex:281:
`20` is not the same value as `42`."
"""
@spec dynamic_conforms(value, TypeCheck.Type.t()) ::
Expand Down Expand Up @@ -315,7 +315,7 @@ defmodule TypeCheck do
iex> TypeCheck.dynamic_conforms!(42, fourty_two)
42
iex> TypeCheck.dynamic_conforms!(20, fourty_two)
** (TypeCheck.TypeError) At lib/type_check.ex:279:
** (TypeCheck.TypeError) At lib/type_check.ex:281:
`20` is not the same value as `42`.
"""
@spec dynamic_conforms!(value, TypeCheck.Type.t()) :: value | no_return()
Expand Down
1 change: 1 addition & 0 deletions lib/type_check/internals/bootstrap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ case Code.ensure_compiled(TypeCheck.Builtin.Any) do
{:module, _} ->

TypeCheck.Internals.Bootstrap.Macros.recompile(TypeCheck.Type, "lib/type_check/type.ex")
TypeCheck.Internals.Bootstrap.Macros.recompile(TypeCheck.Spec, "lib/type_check/spec.ex")
TypeCheck.Internals.Bootstrap.Macros.recompile(TypeCheck.Options, "lib/type_check/options.ex")
TypeCheck.Internals.Bootstrap.Macros.recompile(TypeCheck.Builtin, "lib/type_check/builtin.ex")
end
6 changes: 4 additions & 2 deletions lib/type_check/spec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ defmodule TypeCheck.Spec do

import TypeCheck.Internals.Bootstrap.Macros
if_recompiling? do
@type! t() :: %__MODULE__{name: String.t(), param_types: list(TypeCheck.Type.t()), return_type: TypeCheck.Type.t(), location: [] | list({:file, binary()} | {:line, non_neg_integer()})}
@type! problem_tuple :: {t(), :no_match, %{}, any()}
use TypeCheck
@type! t() :: %__MODULE__{name: binary(), param_types: list(TypeCheck.Type.t()), return_type: TypeCheck.Type.t(), location: [] | list({:file, binary()} | {:line, non_neg_integer()})}
@type! problem_tuple :: {t(), :param_error, %{index: non_neg_integer(), problem: lazy(TypeCheck.TypeError.Formatter.problem_tuple())}, any()}
| {t(), :return_error, %{arguments: list(term()), problem: lazy(TypeCheck.TypeError.Formatter.problem_tuple())}, any()}
end

defp spec_fun_name(function, arity) do
Expand Down

0 comments on commit 17fbb94

Please sign in to comment.