aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/opaque_SUITE_data/src/para/para3.erl
blob: d8c1f561f75544bd05cbe0dc2d51b4b2b41a52e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
-module(para3).

-export([t/0, t1/1, t2/0, ot1/1, ot2/0, t1_adt/0, t2_adt/0]).

-export([exp_adt/0]).

%% More opaque tests.

-export_type([ot1/0, ot1/1, ot1/2, ot1/3, ot1/4, ot1/5]).

-opaque ot1() :: {ot1(_)}.

-opaque ot1(A) :: {ot1(A, A)}.

-opaque ot1(A, B) :: {ot1(A, B, A)}.

-opaque ot1(A, B, C) :: {ot1(A, B, C, A)}.

-opaque ot1(A, B, C, D) :: {ot1(A, B, C, D, A)}.

-opaque ot1(A, B, C, D, E) :: {A, B, C, D, E}.

-spec ot1(_) -> ot1().

ot1(A) ->
    {{{{{A, A, A, A, A}}}}}.

-spec ot2() -> ot1(). % invalid type spec

ot2() ->
    foo.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

t() ->
    {{{17}}} = t1(3). %% pattern can never match

-type t1() :: {t1(_)}.

-type t1(A) :: {t1(A, A)}.

-type t1(A, B) :: {t1(A, B, A)}.

-type t1(A, B, C) :: {t1(A, B, C, A)}.

-type t1(A, B, C, D) :: {t1(A, B, C, D, A)}.

-type t1(A, B, C, D, E) :: {A, B, C, D, E}.

-spec t1(_) -> t1().

t1(A) ->
    {{{{{A, A, A, A, A}}}}}.

-spec t2() -> t1(). % invalid type spec

t2() ->
    foo.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Shows that the list TypeNames in t_from_form must include ArgsLen.

t1_adt() ->
    {{{{{17}}}}} = para3_adt:t1(3). % breaks the opacity

t2_adt() ->
    {{{{17}}}} = para3_adt:t1(3). % can never match

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-type exp() :: para3_adt:exp1(para3_adt:exp2()).

-spec exp_adt() -> exp(). % invalid type spec

exp_adt() ->
    3.