[erlang-bugs] QLC boolean condition
Bernard Duggan
bduggan@REDACTED
Tue Apr 1 01:30:47 CEST 2014
Hi all,
It looks like QLC doesn't quite handle boolean operators in its filters
correctly. For the following code:
-------------------
-module(qlc_bug).
-include_lib("stdlib/include/qlc.hrl").
-compile(export_all).
-record(
rec, {
a, b
}).
test() ->
T = ets:new(test, [{keypos, 2}]),
ets:insert(T, #rec{a = 1, b = 1}),
ets:insert(T, #rec{a = 2, b = 2}),
qlc:e(qlc:q([A || A <- ets:table(T), A#rec.a =:= 1 orelse (A#rec.a
=:= 2 andalso A#rec.b =:= 1)])).
-------------------
I would expect a call to test/0 to return [{rec, 1, 1}], since the
second record ({rec, 2, 2}) should be excluded by the right hand side of
the 'andalso'. However the returned value is [{rec,1,1},{rec,2,2}].
(Tested on R16B03).
Cheers,
Bernard
________________________________
This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents.
More information about the erlang-bugs
mailing list