[erlang-bugs] qlc incorrect results from simple query

Sam Bobroff <>
Fri Feb 28 04:14:55 CET 2014


Hey all,

It appears that QLC is returning incorrect results for a fairly simple usage of “and” and “or”, as shown below:

$ cat bug.erl
-module(bug).
-export([start/0]).
-include_lib("stdlib/include/qlc.hrl").

-record(r, { k, v }).

start() ->
        T = ets:new(r, [{keypos, 2}]),
        L = [#r{k=1, v=a}, #r{k=2, v=b}, #r{k=3, v=c}],
        ets:insert(T, L),
        io:fwrite("QLC  ~p\n", [ qlc:e(qlc:q([R || R <- ets:table(T), (R#r.k =:= 1) or ((R#r.k =:= 2) and (R#r.v =:= a))])) ]),
        io:fwrite("List ~p\n", [                        [R || R <- L, (R#r.k =:= 1) or ((R#r.k =:= 2) and (R#r.v =:= a))] ]).
$ erlc bug.erl
$ erl -noshell -run bug -run init stop
QLC  [{r,1,a},{r,2,b}]
List [{r,1,a}]
$

This seems to occur on at least R16B01, R16B03 and 17.0-rc1.

Cheers,
Sam.
—
template<class T,class...>class C{C<T*const,T,C>a;C<T,C>b;};C<int>c;


________________________________

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