File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1022,7 +1022,11 @@ defmodule Kernel.Typespec do
10221022 :elixir_errors . erl_warn ( caller . line , caller . file , warning )
10231023
10241024 { _ , :used_once } ->
1025- compile_error ( caller , "type variable #{ name } is unused" )
1025+ compile_error (
1026+ caller ,
1027+ "type variable #{ name } is used only once. Type variables in typespecs " <>
1028+ "must be referenced at least twice, otherwise it is equivalent to term()"
1029+ )
10261030
10271031 _ ->
10281032 :ok
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ defmodule TypespecTest do
133133 end
134134
135135 test "type variable unused (singleton type variable)" do
136- assert_raise CompileError , ~r" type variable x is unused " , fn ->
136+ assert_raise CompileError , ~r" type variable x is used only once " , fn ->
137137 test_module do
138138 @ type foo ( x ) :: integer
139139 end
@@ -168,8 +168,8 @@ defmodule TypespecTest do
168168 end
169169 end
170170
171- test "spec variable unused (singleton type variable)" do
172- assert_raise CompileError , ~r" type variable x is unused " , fn ->
171+ test "spec variable used only once (singleton type variable)" do
172+ assert_raise CompileError , ~r" type variable x is used only once " , fn ->
173173 test_module do
174174 @ spec foo ( x , integer ) :: integer when x: var
175175 def foo ( x , y ) , do: x + y
You can’t perform that action at this time.
0 commit comments