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

initialization/1 directive does not sufficiently take meta_predicate/1 declarations into account

Open triska opened this issue 2 years ago • 1 comments

For example, with run.pl consisting of:

:- use_module(library(format)).

:- meta_predicate g(:).

g(Goal) :- portray_clause(Goal).

run :- g(true).

:- initialization(run).
:- initialization(g(true)).

We get:

$ scryer-prolog -f run.pl
user:true.
true.

Whereas the expected output is:

user:true.
user:true.

This is because run is equivalent (per definitionem) to g(true).

This issue is the reason for https://github.com/mthom/scryer-prolog/discussions/1931#discussioncomment-6583858.

triska avatar Jul 31 '23 18:07 triska

Another example, which arises when the module wants to assert (generated) clauses:

:- module(m, [run/0]).

run :- p.

:- initialization(assertz((p :- true))).

Unexpectedly yielding:

?- run.
   error(existence_error(procedure,p/0),p/0), unexpected.
   true. % expected

Earlier versions of library(clpz) assert clauses in this way and it used to work, and I can now no longer test them due to this issue.

triska avatar Oct 08 '23 11:10 triska