undef should not fail immediately: it needs to test for exports first

This commit is contained in:
Vitor Santos Costa 2016-05-12 11:42:22 +01:00
parent e92062886b
commit c5323b2920
3 changed files with 10 additions and 8 deletions

View File

@ -888,10 +888,7 @@ static int interrupt_dexecute(USES_REGS1) {
static void undef_goal(USES_REGS1) {
PredEntry *pe = PredFromDefCode(P);
if (Yap_UnknownFlag(CurrentModule) == TermFail) {
P = FAILCODE;
return;
}
BEGD(d0);
/* avoid trouble with undefined dynamic procedures */
/* I assume they were not locked beforehand */

View File

@ -273,13 +273,18 @@ private(_).
'$handle_error'(_Action,_G0,_M0) :- fail.
% cases where we cannot afford to ever fail.
'$undefp'([_|print_message(Context, Msg)], true) :- !,
'$undefp'([ImportingMod|G], _) :- !,
recorded('$import','$import'(ExportingModI,ImportingMod,G,G0I,_,_),_), !,
% writeln('$execute0'(G0I, ExportingModI)),
'$execute0'(G0I, ExportingModI).
'$undefp'([_|print_message(Context, Msg)], _) :- !,
'$early_print_message'(Context, Msg).
% undef handler
'$undefp'([M0|G0], Action) :-
% make sure we do not loop on undefined predicates
'$stop_creeping'(Current),
yap_flag( unknown, Action, fail),
Action\=fail,
% yap_flag( debug, Debug, false),
(
'$undefp_search'(M0:G0, NM:NG),
@ -419,7 +424,7 @@ true :- true.
% simple trick to find out if this is we are booting from Prolog.
% boot from a saved state
(
current_prolog_flag(saved_program, false)
current_prolog_flag(saved_program, false)
->
prolog_flag(verbose, OldV, silent),
prolog_flag(resource_database, RootPath),
@ -1387,7 +1392,7 @@ not(G) :- \+ '$execute'(G).
bootstrap( F ),
yap_flag(verbose, _, Old),
'$live'.
bootstrap(F) :-
% '$open'(F, '$csult', Stream, 0, 0, F),

View File

@ -82,7 +82,7 @@ followed by the failure of that call.
:- '$set_no_trace'('$handle_error'(_,_,_), prolog).
/**
Z * @pred '$undefp_expand'(+ M0:G0, -MG)
* @pred '$undefp_expand'(+ M0:G0, -MG)
*
* @param G0 input goal
* @param M0 current module