% WAM findall/3: non-ground template instances should be copied with fresh,
% bindable variables (ISO semantics).

:- catch(set_prolog_flag(flowlog_engine, wam), _, true).

p(1).
p(2).

q(L) :- findall(pair(X,Y), p(X), L).

ok :-
  q(L),
  L = [pair(1,Y1), pair(2,Y2)],
  var(Y1),
  var(Y2),
  Y1 \== Y2,
  Y1 = a,
  Y2 = b,
  findall(X, (p(X), !), Lcut),
  Lcut = [1],
  findall(Z, p(3), Lnone),
  Lnone = [],
  findall(T, \+ true, Lneg),
  Lneg = [],
  X0 = outer,
  findall(W, p(W), _),
  X0 == outer.
