Fatalize
Fatalize

Reputation: 3543

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!

Upvotes: 2

Views: 181

Answers (1)

Fatalize
Fatalize

Reputation: 3543

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

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

Upvotes: 2

Related Questions