~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/dialyzer/test/opaque_SUITE_data/src/crash/crash_1.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%%-------------------------------------------------------------------
 
2
%%% From : Fredrik Thulin <ft@it.su.se>
 
3
%%%
 
4
%%% A module with an erroneous record field declaration which mixes up
 
5
%%% structured and opaque terms and causes a crash in dialyzer.
 
6
%%%
 
7
%%% In addition, it revealed that the compiler produced extraneous
 
8
%%% warnings about unused record definitions when in fact they are
 
9
%%% needed for type declarations. This is now fixed.
 
10
%%%-------------------------------------------------------------------
 
11
-module(crash_1).
 
12
 
 
13
-export([add/3, empty/0]).
 
14
 
 
15
%%--------------------------------------------------------------------
 
16
 
 
17
-record(sipurl,  {proto = "sip" :: string(), host :: string()}).
 
18
-record(keylist, {list = [] :: [_]}).
 
19
-type sip_headers() :: #keylist{}.
 
20
-record(request, {uri :: #sipurl{}, header :: sip_headers()}).
 
21
-type sip_request() :: #request{}.
 
22
 
 
23
%%--------------------------------------------------------------------
 
24
 
 
25
-record(target, {branch :: string(), request :: sip_request()}).
 
26
-opaque target() :: #target{}.
 
27
 
 
28
-record(targetlist, {list :: target()}).  % XXX: THIS ONE SHOULD READ [target()]
 
29
-opaque targetlist() :: #targetlist{}.
 
30
 
 
31
%%====================================================================
 
32
 
 
33
add(Branch, #request{} = Request, #targetlist{list = L} = TargetList) ->
 
34
    case get_using_branch(Branch, TargetList) of
 
35
        none ->
 
36
            NewTarget = #target{branch = Branch, request = Request},
 
37
            #targetlist{list = L ++ [NewTarget]};
 
38
        #target{} ->
 
39
            TargetList
 
40
    end.
 
41
 
 
42
-spec empty() -> targetlist().
 
43
 
 
44
empty() ->
 
45
    #targetlist{list = []}.
 
46
 
 
47
get_using_branch(Branch, #targetlist{list = L}) when is_list(Branch) ->
 
48
    get_using_branch2(Branch, L).
 
49
 
 
50
get_using_branch2(_Branch, []) ->
 
51
    none;
 
52
get_using_branch2(Branch, [#target{branch=Branch}=H | _T]) ->
 
53
    H;
 
54
get_using_branch2(Branch, [#target{} | T]) ->
 
55
    get_using_branch2(Branch, T).