Skip to content

confusing error message when tuple is used as typevariable #6411

@NobbZ

Description

@NobbZ

Environment

  • Elixir & Erlang versions (elixir --version):
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe]

Elixir 1.5.0
  • Operating system: Gentoo Linux (Linux funtoo-tuxedo 4.8.15-1 #8 SMP Thu Jun 8 18:56:41 CEST 2017 x86_64 Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz GenuineIntel GNU/Linux)

Current behavior

$ cat foo.ex
defmodule M do
  @spec f(list) :: nil when list: [integer]
  def f(_), do: nil

  # @spec g(tuple) :: nil when tuple: {integer, integer}
  def g(_), do: nil

  @spec h(integer) :: nil when integer: 1
  def h(1), do: nil
end

$ elixrc foo.ex

$ edit foo.ex # remove that `#` and make `g`s spec available

$ elixrc foo.ex

== Compilation error in file foo.ex ==
** (CompileError) foo.ex:5: type variable tuple is only used once (is unbound)
    (stdlib) lists.erl:1338: :lists.foreach/2
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6

Expected behavior

Print out a meaningful errormessage for all internal types or be able to use them as a typevariable.

Personally I'd prefer to disallow their usage as type variables.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions