If the Module does not exist, erase_module/1 simply succeeds.
An error (101) is raised when trying to erase a module from within itself.
Note that a module gets erased (and re-created) implicitly when the compiler encounters a module/1 directive and that module already exists.
Success:
[eclipse]: [user].
:- module(m).
:- export a/0.
a :- writeln(hello).
user compiled 60 bytes in 0.00 seconds
yes.
[eclipse]: import a/0 from m.
yes.
[eclipse]: a.
hello
yes.
[eclipse]: erase_module(m).
yes.
[eclipse]: a.
calling an undefined procedure a in module eclipse
Error:
erase_module(M). (Error 4).
erase_module(1). (Error 5).
erase_module(mod)@mod. (Error 101).