swipl-devel
swipl-devel copied to clipboard
expects_dialect doesn't make emulated builtins visible to subsequently imported modules
Using SWI-Prolog 8.3.17 built from source (e5ff4a2c4d76ce57d177649b941f38792d876acd). I have code that uses :- expects_dialect(sicstus).
and then loads other modules, expecting the other modules to be loaded with SICStus emulation as well. This seems to work fine with emulated library predicates, but emulated built-in predicates are visible only to the module that calls expects_dialect(sicstus)
and not to any modules that it loads afterwards. To reproduce:
inbetween.pl:
:- module(inbetween, []).
:- expects_dialect(sicstus).
:- use_module(things).
things.pl:
:- module(things, []).
:- use_module(library(system)).
% Emulated built-in predicate - doesn't work.
:- trimcore.
% Emulated library predicate - works.
:- environ('TERM', TermType), format("Terminal type: ~w~n", [TermType]).
Loading the module:
?- use_module(inbetween).
ERROR: .../things.pl:5:
ERROR: catch/3: Unknown procedure: things:trimcore/0
ERROR: However, there are definitions for:
ERROR: inbetween:trimcore/0
ERROR: sicstus:trimcore/0
Warning: .../things.pl:5:
Warning: Goal (directive) failed: things:trimcore
Terminal type: xterm-256color
true.
For some reason, running expects_dialect(sicstus).
at the toplevel before loading the module makes the error go away:
?- expects_dialect(sicstus).
true.
?- use_module(inbetween).
Terminal type: xterm-256color
true.