scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

(+\)/2 in call/1 confused predicate calls

Open bakaq opened this issue 2 years ago • 8 comments

?- [user].
:- use_module(library(lambda)).

p.

?- Goal = (X +\ p), call(Goal).
   error(existence_error(procedure,p/0),p/0).
?- Goal = (X +\ (user:p)), call(Goal).
   Goal = X+\(user:p).

This seems to be the ultimate cause for https://github.com/aarroyoc/scryer-playground/issues/20. I couldn't reduce this for a custom predicate instead of (+\)/2, so I guess the problem is there, maybe in no_hat_call/1?

bakaq avatar Dec 28 '23 22:12 bakaq

Also, this works for some reason:

?- call(X +\ p).
   true.

bakaq avatar Dec 28 '23 22:12 bakaq

$ scryer-prolog ?- [user]. :- use_module(library(lambda)). p.

?- Goal = (X +\ user:p), write_canonical(Goal), nl. :(+(_74543,user),p) Goal = X+\user:p. ?-

infradig avatar Dec 28 '23 23:12 infradig

That doesn't seem to be the problem:

?- Goal = (X +\ (user:p)), write_canonical(Goal), nl, call(Goal).
+\(_43,:(user,p))
   Goal = X+\(user:p).

bakaq avatar Dec 28 '23 23:12 bakaq

Works in SICStus. If at it, the existence error produced by Scryer does not reveal the actual module where the error occurs, which makes diagnosing difficult.

UWN avatar Dec 29 '23 08:12 UWN

I think this is still not fixed fully:

?- use_module(library(lambda)).
   true.
?- [user].
p.
same(A,A).

?- X = (_+\p), same(X, Y), call(Y).
   error(existence_error(procedure,p/0),p/0). % unexpected
?- X = (_+\p), call(X).
    X = _A+\p.   % expected
?- 

UPDT: I've found this behavior during learning semantics of goal expansion for #2532

hurufu avatar Sep 06 '24 19:09 hurufu

Same problem when all is dynamic:

?- asserta((t2:-X=(_+\p),call(X))).
   true.
?- t2.
   error(existence_error(procedure,p/0),p/0).
?- p.
   true.

UWN avatar Sep 06 '24 19:09 UWN

Even

?- asserta((t3:-call(_+\p))).
   true.
?- t3.
   error(existence_error(procedure,p/0),p/0).

UWN avatar Sep 06 '24 19:09 UWN

What in tarnation!!????

?- [user].
:- use_module(library(lambda)).

p.

a(\p).

?- G = (\p), call(G).
   G = \p.
?- a(G), call(G).
   error(existence_error(procedure,p/0),p/0).
?- a(G0), G = (\p), G0 = G, call(G).
   G0 = \p, G = \p.
?- a(G0), G = (\p), G0 = G, call(G0).
   % G0 and G unified, why does one work and the
   % other give an error!!?? 
   error(existence_error(procedure,p/0),p/0).

bakaq avatar Sep 08 '24 02:09 bakaq

This seems to be working now!

Only example in this issue that still doesn't work is this one:

?- use_module(library(lambda)).
   true.
?- [user].
p.

?- asserta((t3 :- call(_+\p))).
   true.
?- t3.
   error(existence_error(procedure,p/0),p/0).

Which is weird because this works:

?- asserta((t2 :- X = (_+\p), call(X))).
   true.
?- t2.
   true.

bakaq avatar Dec 07 '24 22:12 bakaq

@mthom Thanks a lot for fixing 🎉

hurufu avatar Dec 08 '24 10:12 hurufu