(+\)/2 in call/1 confused predicate calls
?- [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?
Also, this works for some reason:
?- call(X +\ p).
true.
$ scryer-prolog ?- [user]. :- use_module(library(lambda)). p.
?- Goal = (X +\ user:p), write_canonical(Goal), nl. :(+(_74543,user),p) Goal = X+\user:p. ?-
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).
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.
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
Same problem when all is dynamic:
?- asserta((t2:-X=(_+\p),call(X))).
true.
?- t2.
error(existence_error(procedure,p/0),p/0).
?- p.
true.
Even
?- asserta((t3:-call(_+\p))).
true.
?- t3.
error(existence_error(procedure,p/0),p/0).
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).
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.
@mthom Thanks a lot for fixing 🎉