SWI-Prolog / issues

Dummy repository for issue tracking
7 stars 3 forks source link

"import clash" err msg not thrown #9

Closed anionic closed 7 years ago

anionic commented 9 years ago

this msg should be thrown?

Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 7.1.26) Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

1 ?- [test_module_1]. true.

2 ?- catch(consult(test_module_2), E, true). ERROR: import/1: No permission to import test_module_2:test_predicate/2 into use r (already imported from test_module_1) true.

3 ?-

JanWielemaker commented 9 years ago

Possibly that should be an option. I don't think it is the right default though. Compiler exceptions are handled by the higher control structures of the compiler and printed, after which compilation continues. Not doing that would break compilation at the first error. This doesn't give an overview of errors and quite often (parts of) programs are usable despite errors.

As is, catch(consult, ....) works for the case that the target file does not exist. In other case there is no systematic way to undo the side-effects of the partial compilation, another argument why compilation shouldn't abort on an exception.

If you want to terminate Prolog on an error, use message_hook/3, print the message and call halt(1).