Search code examples
prologswi-prologclpfd

Compilation error when mixing CLP(FD) and if-then-else construct


I do not understand why the following code does not compile; it produces a put_attr/3: Uninstantiated argument expected, found 2 (1-st argument) error:

:- use_module(library(clpfd)).

test(X, Y) :-
    (   X = 1
    ->  Y #= 2
    ;   Y = 3
    ).

The following code also does not compile:

test(X, Y) :-
    (   X = 1
    ->  Y = 2
    ;   Y #= 3
    ).

I don't understand why that is. Replacing the #= with simple unification = makes it compile, but I don't see why this wouldn't compile considering that this predicate :

test(X, Y) :-
    (   X = 1
    ->  Y #= 2*_
    ;   Y = 3
    ).

does compile!


Solution

  • This was a bug of the goal expansion of library(clpfd).

    This has been fixed by Markus Triska as of this commit.