From 921129288e0500be0dfc7cae6088eb8d2770488d Mon Sep 17 00:00:00 2001 From: Marten/Qqwy Date: Thu, 30 Sep 2021 17:04:18 +0200 Subject: [PATCH] more fixes --- lib/type_check.ex | 12 +++++++----- lib/type_check/macros.ex | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/type_check.ex b/lib/type_check.ex index 4a1474db..a5ce8d05 100644 --- a/lib/type_check.ex +++ b/lib/type_check.ex @@ -89,10 +89,12 @@ defmodule TypeCheck do iex> TypeCheck.conforms!({10, 20}, sorted_pair) {10, 20} iex> TypeCheck.conforms!({20, 10}, sorted_pair) - ** (TypeCheck.TypeError) `{20, 10}` does not check against `(sorted_pair :: {lower :: number(), higher :: number()} when lower <= higher)`. Reason: - type guard: - `lower <= higher` evaluated to false or nil. - bound values: %{higher: 10, lower: 20, sorted_pair: {20, 10}} + ** (TypeCheck.TypeError) `{20, 10}` does not match the definition of the named type `TypeCheckTest.TypeGuardExample.sorted_pair` + which is: `TypeCheckTest.TypeGuardExample.sorted_pair :: (sorted_pair when lower <= higher)`. Reason: + `{20, 10}` does not check against `(sorted_pair when lower <= higher)`. Reason: + type guard: + `lower <= higher` evaluated to false or nil. + bound values: %{higher: 10, lower: 20, sorted_pair: {20, 10}} Named types are available in your guard even from the (both local and remote) types that you are using in your time, as long as those types are not defined as _opaque_ types. @@ -244,7 +246,7 @@ defmodule TypeCheck do iex> {:error, type_error} = TypeCheck.dynamic_conforms(20, fourty_two) iex> type_error.message "At lib/type_check.ex:262: - `20` is not the same value as `42`." + `20` is not the same value as `42`." """ @spec dynamic_conforms(value, TypeCheck.Type.t()) :: {:ok, value} | {:error, TypeCheck.TypeError.t()} diff --git a/lib/type_check/macros.ex b/lib/type_check/macros.ex index c44dcab8..e70af39d 100644 --- a/lib/type_check/macros.ex +++ b/lib/type_check/macros.ex @@ -56,7 +56,7 @@ defmodule TypeCheck.Macros do ``` iex> MetaExample.joe - #TypeCheck.Type< %{TypeCheck.MacrosTest.MetaExample.joe() :: coolness_level: :high, name: :joe} > + #TypeCheck.Type< TypeCheck.MacrosTest.MetaExample.joe() :: %{coolness_level: :high, name: :joe} > iex> MetaExample.mike #TypeCheck.Type< TypeCheck.MacrosTest.MetaExample.mike() :: %{coolness_level: :high, name: :mike} >