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
1022
1022
:elixir_errors . erl_warn ( caller . line , caller . file , warning )
1023
1023
1024
1024
{ _ , :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
+ )
1026
1030
1027
1031
_ ->
1028
1032
:ok
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ defmodule TypespecTest do
133
133
end
134
134
135
135
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 ->
137
137
test_module do
138
138
@ type foo ( x ) :: integer
139
139
end
@@ -168,8 +168,8 @@ defmodule TypespecTest do
168
168
end
169
169
end
170
170
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 ->
173
173
test_module do
174
174
@ spec foo ( x , integer ) :: integer when x: var
175
175
def foo ( x , y ) , do: x + y
You can’t perform that action at this time.
0 commit comments