aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-03-12 22:25:30 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-03-17 17:47:36 +0100
commit66039320f16622b62fe9dbd413034171130d4de4 (patch)
tree05aba938a99aa1da705884e390b1d209d4ed4714 /lib
parentc57ac1a6e02ae0fc9b85b204052596ab74cde45e (diff)
downloadotp-66039320f16622b62fe9dbd413034171130d4de4.tar.gz
otp-66039320f16622b62fe9dbd413034171130d4de4.tar.bz2
otp-66039320f16622b62fe9dbd413034171130d4de4.zip
stdlib: Move map type to proper definition
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/erl_lint.erl3
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl35
2 files changed, 35 insertions, 3 deletions
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index dc20a18485..3b3e4db518 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -2761,6 +2761,7 @@ check_record_types([], _Name, _DefFields, SeenVars, St, _SeenFields) ->
{SeenVars, St}.
is_var_arity_type(tuple) -> true;
+is_var_arity_type(map) -> true;
is_var_arity_type(product) -> true;
is_var_arity_type(union) -> true;
is_var_arity_type(record) -> true;
@@ -2793,7 +2794,6 @@ is_default_type({iodata, 0}) -> true;
is_default_type({iolist, 0}) -> true;
is_default_type({list, 0}) -> true;
is_default_type({list, 1}) -> true;
-is_default_type({map, 0}) -> true;
is_default_type({maybe_improper_list, 0}) -> true;
is_default_type({maybe_improper_list, 2}) -> true;
is_default_type({mfa, 0}) -> true;
@@ -2824,6 +2824,7 @@ is_default_type({timeout, 0}) -> true;
is_default_type({var, 1}) -> true;
is_default_type(_) -> false.
+%% OTP 17.0
is_newly_introduced_builtin_type({Name, _}) when is_atom(Name) -> false.
is_obsolete_builtin_type(TypePair) ->
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 5d189006a1..919489e3d7 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -63,7 +63,7 @@
too_many_arguments/1,
basic_errors/1,bin_syntax_errors/1,
predef/1,
- maps/1
+ maps/1,maps_type/1
]).
% Default timetrap timeout (set in init_per_testcase).
@@ -91,7 +91,8 @@ all() ->
otp_11772, otp_11771, export_all,
bif_clash, behaviour_basic, behaviour_multiple,
otp_7550, otp_8051, format_warn, {group, on_load},
- too_many_arguments, basic_errors, bin_syntax_errors, predef, maps].
+ too_many_arguments, basic_errors, bin_syntax_errors, predef,
+ maps,maps_type].
groups() ->
[{unused_vars_warn, [],
@@ -3394,6 +3395,36 @@ maps(Config) ->
[] = run(Config, Ts),
ok.
+maps_type(Config) when is_list(Config) ->
+ Ts = [
+ {maps_type1,
+ <<"
+ -type m() :: #{a => integer()}.
+ -spec t1(#{k=>term()}) -> {term(), map()}.
+
+ t1(#{k:=V}=M) -> {V,M}.
+
+ -spec t2(m()) -> integer().
+
+ t2(#{a:=V}) -> V.
+ ">>,
+ [],
+ []},
+ {maps_type2,
+ <<"
+ %% Built-in var arity map type:
+ -type map() :: tuple().
+ -type a() :: map().
+
+ -spec t(a()) -> a().
+ t(M) -> M.
+ ">>,
+ [],
+ {errors,[{3,erl_lint,{redefine_type,{map,0}}}],[]}}],
+ [] = run(Config, Ts),
+ ok.
+
+
run(Config, Tests) ->
F = fun({N,P,Ws,E}, BadL) ->
case catch run_test(Config, P, Ws) of