aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/small_SUITE_data/src/lists_key_bug.erl
blob: ad5cf3c503efb412d21da44a64fafbc5245479aa (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
-module(lists_key_bug).

%% OTP-15570

-export([is_1/1, is_2/1, i/1, t1/0, t2/0, im/0]).

%% int_set([3])
is_1(V) ->
    K = ikey(V),
    case lists:keyfind(K, 1, [{<<"foo">>, bar}]) of
        false ->
            a;
        {_, _} ->
            b
    end.

ikey(1) ->
    3;
ikey(2) ->
    <<"foo">>.

%% int_set([3, 5])
is_2(V) ->
    K = iskey(V),
    case lists:keyfind(K, 1, [{<<"foo">>, bar}]) of
        false ->
            a;
        {_, _} ->
            b
    end.

iskey(1) ->
    12;
iskey(2) ->
    14;
iskey(3) ->
    <<"foo">>.

%% integer()
i(V) ->
    K = intkey(V),
    case lists:keyfind(K, 1, [{9.0, foo}]) of
        false ->
            a;
        {_, _} ->
            b
    end.

intkey(K) when is_integer(K) ->
    K + 9999.

t1() ->
    case lists:keyfind({17}, 1, [{{17.0}, true}]) of
        false ->
            a;
        {_, _} ->
            b
    end.

t2() ->
    case lists:keyfind({17.0}, 1, [{{17}, true}]) of
        false ->
            a;
        {_, _} ->
            b
    end.

%% Note: #{1.0 => a} =/= #{1 => a}.
im() ->
    case lists:keyfind(#{1.0 => a}, 1, [{#{1 => a}, foo}]) of
        false ->
            a;
        {_, _} ->
            b
    end.