summaryrefslogtreecommitdiff
path: root/lib/dialyzer/test/small_SUITE_data/src/or_bug.erl
blob: fb8f6558b8791bef7bbd9d5434f347722cc3fd80 (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
%%---------------------------------------------------------------------------
%% From: Per Hedeland <per@hedeland.org>
%% Date: 11 Feb 2010
%%
%% The code below demonstrates a bug in dialyzer - it produces the warning:
%%	Clause guard cannot succeed.
%%	The variable Cs was matched against the type any()
%% for the first test/1 clause, but of course the claim can easily be easily
%% refuted by calling test(#cs{}).
%%---------------------------------------------------------------------------

-module(or_bug).

-export([test/1]).

-record(cs, {children = [], actions = []}).

-define(is_internal(X), ((X#cs.children =/= []) or
                         (X#cs.actions =/= []))).
-define(has_children(X), (X#cs.children /= [])).

test(Cs) when not ?is_internal(Cs)  -> foo;
test(Cs) when not ?has_children(Cs) -> bar;
test(Cs) when Cs#cs.children =/= [] -> baz.