You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears that referencing __MODULE__ in a @type! declaration results in a specification that can never be met. For example, suppose t is declared as a type...
Calling Typetest.hello("Jane") results in the following error:
** (TypeCheck.TypeError) The call to `hello/1` failed,
because the returned result does not adhere to the spec `Typetest.t`.
Rather, its value is: `%Typetest{name: "Jane"}`.
Details:
The result of calling `hello("Jane")`
does not adhere to spec `hello(String.t()) :: Typetest.t`. Reason:
Returned result:
`%Typetest{name: "Jane"}` does not match the definition of the named type `Typetest.t`
which is: `Typetest.t
::
%{__struct__: TypeCheck.Internals.UserTypes.Typetest, name: String.t()}`. Reason:
`%Typetest{name: "Jane"}` does not check against `%{__struct__: TypeCheck.Internals.UserTypes.Typetest, name: String.t()}`. Reason:
under key `:__struct__`:
`Typetest` is not the same value as `TypeCheck.Internals.UserTypes.Typetest`.
It seems that TypeCheck has converted it to an internal module and is then comparing the module against that. Changing the type to @type! t :: %Typetest{name: String.t()} works, but referencing __MODULE__ I believe to be quite common.
The text was updated successfully, but these errors were encountered:
It appears that referencing
__MODULE__
in a@type!
declaration results in a specification that can never be met. For example, supposet
is declared as a type...Calling
Typetest.hello("Jane")
results in the following error:It seems that TypeCheck has converted it to an internal module and is then comparing the module against that. Changing the type to
@type! t :: %Typetest{name: String.t()}
works, but referencing__MODULE__
I believe to be quite common.The text was updated successfully, but these errors were encountered: