aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2014-04-09 13:04:36 +0200
committerHans Bolinder <[email protected]>2014-04-29 09:17:01 +0200
commit8943276198034c6500ecbf4e513886ccf80fa056 (patch)
tree0d235c514ba52f937caaf62627788de46e2fd558 /lib/stdlib
parent4f0b3948eae361c04a3ed565a475a5d38f3c876d (diff)
downloadotp-8943276198034c6500ecbf4e513886ccf80fa056.tar.gz
otp-8943276198034c6500ecbf4e513886ccf80fa056.tar.bz2
otp-8943276198034c6500ecbf4e513886ccf80fa056.zip
Disallow '_' as type variable
"... when _ :: ..." used to compile, but Dialyzer crashed.
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/erl_parse.yrl2
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl13
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index 3bb7a90c4f..8601c89d59 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -664,6 +664,8 @@ find_arity_from_specs([Spec|_]) ->
{type, _, 'fun', [{type, _, product, Args},_]} = Fun,
length(Args).
+build_def({var, L, '_'}, _Types) ->
+ ret_err(L, "bad type variable");
build_def(LHS, Types) ->
IsSubType = {atom, ?line(LHS), is_subtype},
{type, ?line(LHS), constraint, [IsSubType, [LHS, Types]]}.
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 16bd88938a..6e5892714b 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -3720,7 +3720,18 @@ otp_11851(Config) when is_list(Config) ->
t()-> a.
">>,
[],
- {errors,[{5,erl_lint,{bad_callback,{lint_test,a,1}}}],[]}}
+ {errors,[{5,erl_lint,{bad_callback,{lint_test,a,1}}}],[]}},
+ {otp_11851_3,
+ <<"-export([a/1]).
+
+ -spec a(_A) -> boolean() when
+ _ :: atom(),
+ _A :: integer().
+
+ a(_) -> true.
+ ">>,
+ [],
+ {errors,[{4,erl_parse,"bad type variable"}],[]}}
],
[] = run(Config, Ts),
ok.