Open guregu opened 2 years ago
Reduced it further:
:- module(js_toplevel, [js_ask/1]).
:- use_module(library(lists)).
js_ask(Input) :-
read_term_from_chars(Query, [variable_names(Vars)], Input),
query(Query, Status),
write(Vars), nl, write(Status), nl,
call_any_predicate(Status). % deleting this fixes it?
call_any_predicate(_).
query(Query, Status) :-
% weird:
catch(Query, Error, true),
% ok:
% call(Query),
query_status(true, Error, Status).
query_status(_OK, Error, error) :- nonvar(Error), !.
query_status(true, _, success).
query_status(false, _, failure).
person(socrates).
person(plato).
mortal(X) :- person(X).
I think optimization is the culprit:
$ ./tpl --version
Trealla Prolog (c) Infradig 2020-2022, v2.2.15
# weird
$ ./tpl js_toplevel.pl -g 'js_ask("mortal(X)")' --ns
[X=socrates]
success
true
;
# ok
$ ./tpl js_toplevel.pl -O0 -g 'js_ask("mortal(X)")' --ns
[X=socrates]
success
true
; [X=plato]
success
true
;
It would seem so.
On Sat, Oct 1, 2022 at 12:32 AM guregu @.***> wrote:
Reduced it further:
:- module(js_toplevel, [js_ask/1]).
:- use_module(library(lists)). js_ask(Input) :- read_term_from_chars(Query, [variable_names(Vars)], Input), query(Query, Status), write(Vars), nl, write(Status), nl, call_any_predicate(Status). % deleting this fixes it? call_anypredicate(). write_result(Status, Solution) :- write(Status), write(' '), write(Solution), nl. query(Query, Status) :- % weird: catch(Query, Error, true), % ok: % call(Query), query_status(true, Error, Status). query_status(_OK, Error, error) :- nonvar(Error), !.querystatus(true, , success).querystatus(false, , failure). person(socrates).person(plato).mortal(X) :- person(X).
I think optimization is the culprit:
$ ./tpl --version Trealla Prolog (c) Infradig 2020-2022, v2.2.15
weird
$ ./tpl js_toplevel.pl -g 'js_ask("mortal(X)")' --ns [X=socrates] success true;
ok
$ ./tpl js_toplevel.pl -O0 -g 'js_ask("mortal(X)")' --ns [X=socrates] success true; [X=plato] success true;
— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/52#issuecomment-1263654417, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSESLJQEYI2KQFZKFFILWA32ZHANCNFSM6AAAAAAQZZVIGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Backtracking here seems to use the wrong variable substitutions (as mentioned here: https://github.com/trealla-prolog/trealla/issues/46#issuecomment-1259576921).
Here's the smallest way to reproduce it I could find.See comment below for smaller version.Trace shows odd backtracking:
In particular step 51 looks suspect.