Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocol TypeCheck.Protocols.ToCheck not implemented for [] of type List #189

Open
ProducerMatt opened this issue Sep 29, 2023 · 0 comments

Comments

@ProducerMatt
Copy link

ProducerMatt commented Sep 29, 2023

When making a function @spec! that's dependent on iolist(), I get the following compilation error:

== Compilation error in file lib/typing_bugs.ex ==
** (Protocol.UndefinedError) protocol TypeCheck.Protocols.ToCheck not implemented for [] of type List
    (type_check 0.13.5) lib/type_check/protocols/to_check.ex:1: TypeCheck.Protocols.ToCheck.impl_for!/1
    (type_check 0.13.5) lib/type_check/protocols/to_check.ex:4: TypeCheck.Protocols.ToCheck.to_check/2
    (type_check 0.13.5) lib/type_check/builtin/one_of.ex:21: anonymous fn/2 in TypeCheck.Protocols.ToCheck.TypeCheck.Builtin.OneOf.to_check/2
    (elixir 1.15.5) lib/enum.ex:4317: Enum.flat_map_list/2
    (elixir 1.15.5) lib/enum.ex:4318: Enum.flat_map_list/2
    (type_check 0.13.5) lib/type_check/builtin/one_of.ex:20: TypeCheck.Protocols.ToCheck.TypeCheck.Builtin.OneOf.to_check/2
    (type_check 0.13.5) lib/type_check/builtin/maybe_improper_list.ex:49: TypeCheck.Protocols.ToCheck.TypeCheck.Builtin.MaybeImproperList.build_element_check/2
    (type_check 0.13.5) lib/type_check/builtin/maybe_improper_list.ex:39: TypeCheck.Protocols.ToCheck.TypeCheck.Builtin.MaybeImproperList.to_check/2

This is Elixir 1.15 and the latest release of type_check.

Reproducing:

  • Make a new mix project.
  • add these dependencies:
      {:dialyxir, "~> 1.4", runtime: false},
      {:credo, "~> 1.7", runtime: false},
      {:type_check, "~> 0.13.5"}, # https://hexdocs.pm/type_check/readme.html
  • add this code in a module:
  @spec! iol(iolist()) :: iolist()
  def iol(ll) do
    [:test | ll]
  end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant