Unknown procedure after reloading with make

I’m getting ERROR: Unknown procedure: '__aux_maplist/3_=+0'/2 when a file contains a consult and I reload it with make.

Windows 10 x64, SWI-Prolog version (threaded, 64 bits, version 8.2.4)

f1.pl

:- consult(f2).
a :- maplist(=, [], []).

f2.pl

:- use_module(library(clpfd)).

File → Consult → f1.pl

?- 
%    library(apply) compiled into apply 0.02 sec, 75 clauses
%    library(apply_macros) compiled into apply_macros 0.00 sec, 53 clauses
%    library(assoc) compiled into assoc 0.00 sec, 98 clauses
%    library(error) compiled into error 0.00 sec, 89 clauses
%    library(pairs) compiled into pairs 0.00 sec, 21 clauses
%   library(clpfd) compiled into clpfd 0.09 sec, 1,319 clauses
%  f2 compiled 0.09 sec, 1 clauses
% [path elided]/f1.pl compiled 0.09 sec, 4 clauses

Append b(b). to f1.pl.

?- make.
%  f2 compiled 0.02 sec, 0 clauses
% [path elided]/f1 compiled 0.02 sec, -1 clauses
Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning: 
Warning: '__aux_maplist/3_=+0'/2, which is referenced by
Warning:        [path elided]/f1.pl:2:5: 1-st clause of a/0
true.

?- b(A).
A = b.

?- a.
ERROR: Unknown procedure: '__aux_maplist/3_=+0'/2
ERROR: In:
ERROR:   [11] '__aux_maplist/3_=+0'([],[])
ERROR:   [10] a at [path elided]/f1.pl:2
ERROR:    [9] <user>
   Exception: (11) '__aux_maplist/3_=+0'([], []) ? abort
% Execution Aborted

Thanks for reporting. This reproduces. As a work around use

:- ensure_loaded(f2).

Better yet, create your project as modules and use use_module/1,2. I’ll have a look later.

1 Like

ensure_loaded works, thanks. I have a lot of record types (library(record)) and static data using them, so I wanted to split them into different files, but I wasn’t sure how to use module to export the generated record predicates without a fair amount of manual work. I’m new to Prolog, so let me know if I missed something.

If you use library(record) you indeed have to export the predicates you want to use from other modules. Possibly there should be an export_record/1 to export all of them. You may also consider using dicts instead of records.

I’m able to reproduce this too and the ensure_loaded workaround seems to be working fine.
I’m on Linux and don’t even use make; just the top-level directly.

Strangely, this happens consistently every 2 times I use consult, i.e once it works, next time it does not.

Are we talking about the same make? There is a make/0 in the top-level that lets you re-load source code that has changed, instead of using consult.

I never use any make :slight_smile:
I only use consult (because I wasn’t aware of make/0 ).

Should be fixed as found in Unknown procedure after reloading with make