]> Repositorios git - scryer-prolog.git/commitdiff
remove error printing redundancy and inconsistent state resulting from file_load_clea...
authorMark <[email protected]>
Tue, 5 Sep 2023 19:52:18 +0000 (13:52 -0600)
committerMark <[email protected]>
Tue, 5 Sep 2023 19:53:57 +0000 (13:53 -0600)
src/loader.pl
tests/scryer/issues.rs

index aab86f9515604d89402513c184a518ccdaba33b2..0ba611178fd4dad6e33f3877192f76488a864548 100644 (file)
@@ -135,9 +135,15 @@ file_load_init(Stream, Evacuable) :-
     run_initialization_goals.
 
 file_load_cleanup(Evacuable, Error) :-
+    load_context(Module),
+    abolish(Module:'$initialization_goals'/1),
     unload_evacuable(Evacuable),
-    '$print_message_and_fail'(Error),
-       throw(Error).
+    (  clause('$toplevel':argv(_), _) ->
+       % let the toplevel call loader:write_error/1
+       throw(Error)
+    ;  '$print_message_and_fail'(Error)
+    ;  throw(file_load_error)
+    ).
 
 file_load(Stream, Path, Evacuable) :-
     create_file_load_context(Stream, Path, Evacuable),
@@ -505,7 +511,9 @@ consult(Item) :-
 
 use_module(Module) :-
     '$push_load_state_payload'(Evacuable),
-    use_module(Module, [], Evacuable).
+    catch('$call'(loader:use_module(Module, [], Evacuable)),
+          file_load_error,
+          '$call'(builtins:false)).
 
 use_module(Module, Exports) :-
     '$push_load_state_payload'(Evacuable),
index 94aa37c7302da56f3b22fd81fd8daf93c4842e33..821bbbf301a83ef7cb03e0e1aa2a91437aaa8f57 100644 (file)
@@ -29,7 +29,7 @@ fn do_not_duplicate_path_components() {
         ['tests-pl/issue852-throw_e.pl'].\n\
         halt.\n\
         ",
-        "   throw(e).\n   false.\n   throw(e).\n   false.\n",
+        "   throw(e).\n   throw(e).\n",
     );
 }