From c5323b292098ece8ba7b3acafbfb87c583202b3f Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Thu, 12 May 2016 11:42:22 +0100 Subject: [PATCH] undef should not fail immediately: it needs to test for exports first --- C/absmi.c | 5 +---- pl/boot.yap | 11 ++++++++--- pl/undefined.yap | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/C/absmi.c b/C/absmi.c index b4fe32fa2..fe0afb98c 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -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 */ diff --git a/pl/boot.yap b/pl/boot.yap index ff7a8f94c..ea6bb78c9 100644 --- a/pl/boot.yap +++ b/pl/boot.yap @@ -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), diff --git a/pl/undefined.yap b/pl/undefined.yap index 45cedfaa6..48bde51a6 100644 --- a/pl/undefined.yap +++ b/pl/undefined.yap @@ -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