aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2017-05-17 14:08:49 +0200
committerHans Bolinder <[email protected]>2017-05-22 15:05:49 +0200
commit838dde1e27ee6a6debf74cf2370b2284f618b348 (patch)
treeea2cd053e21765311224d70d814bead2a6a07638 /lib/stdlib
parent8d26eb5a9ccca27f926d1ed01d11a8ac0f55cf5a (diff)
downloadotp-838dde1e27ee6a6debf74cf2370b2284f618b348.tar.gz
otp-838dde1e27ee6a6debf74cf2370b2284f618b348.tar.bz2
otp-838dde1e27ee6a6debf74cf2370b2284f618b348.zip
stdlib: Warn for bad type variables of parameterized types
The linter emits warnings about using '_' as type variable in parameterized types.
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/erl_parse.yrl3
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl6
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index 2dcddeb8c2..733932e711 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -1052,6 +1052,9 @@ build_typed_attribute({atom,Aa,record},
build_typed_attribute({atom,Aa,Attr},
{type_def, {call,_,{atom,_,TypeName},Args}, Type})
when Attr =:= 'type' ; Attr =:= 'opaque' ->
+ lists:foreach(fun({var, A, '_'}) -> ret_err(A, "bad type variable");
+ (_) -> ok
+ end, Args),
case lists:all(fun({var, _, _}) -> true;
(_) -> false
end, Args) of
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 02524679fa..cc3d605840 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -3978,7 +3978,11 @@ otp_14323(Config) ->
{13,erl_lint,{undefined_function,{a,1}}},
{14,erl_lint,{bad_dialyzer_attribute,
{nowarn_function,{a,-1}}}}],
- []}}],
+ []}},
+ {otp_14323_2,
+ <<"-type t(_) :: atom().">>,
+ [],
+ {errors,[{1,erl_parse,"bad type variable"}],[]}}],
[] = run(Config, Ts),
ok.