summaryrefslogtreecommitdiff
path: root/lib/compiler/test/compilation_SUITE_data/infinite_loop.erl
blob: 8fb9125c77ad41e4c44361adf5ef6a1b9727bd36 (plain)
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
-module(infinite_loop).
-compile([export_all]).

?MODULE() ->
    ok.

%% When a series of calls initiated by a fun went into an infinite loop,
%% the compiler went into an infinite loop too.
foo() ->
    fun bar/0().

bar() ->
    baz().

baz() ->
    bar().

foobar() ->
    fun barfoo/0().

barfoo() ->
    barfoo().

%% GH-6474. The compiler would go into an infinite loop.

bc_infinite_loop() ->
    mutually_recursive(<<0 || false>>).

mutually_recursive(X) ->
    %% This LC will be implemented as mutually recursive functions.
    %% Analyzing them would cause an infinite loop.
    [0 || _ <- [], <<_>> <= X].