Possible bug in setarg/3
Michael Ben Yosef <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CABnaNco+d1or1XP8Uy=Voa+NmB=MHywuMn+8HQ8TC9aMsUArzQ@mail.gmail.com> |
Hi,
I believe I've discovered a bug in setarg/3, or at least a behaviour I
really don't understand. The following session on Ubuntu 12.04 x86_64
demonstrates a test case for it:
---BEGIN---
$ cat bug.pl
bug(A, b(A,C)) :-
arg(1, A, C),
setarg(1, A, x).
bug_new(a(_)).
$ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 6.5.2)
Copyright (c) 1990-2013 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- [bug].
% bug compiled 0.00 sec, 3 clauses
true.
?- A = a(_), bug(A, B). % Behaves as expected:
A = a(x),
B = b(a(x), _G2326).
?- bug_new(A), bug(A, B). % Behaves unexpectedly:
A = a(x),
B = b(a(x), x).
?-
---END---
Why is x unified with C in bug/2 in the second query (and not in the first one)?
Kind regards,
Michael