An error is raised (and the module not unlocked) when trying to unlock a module with a wrong password or when trying to unlock a module locked with lock/0.
% After compiling the following code:
:- module(m).
:- export pub/0.
pub :- writeln(pub).
priv :- writeln(priv).
:- lock_pass("secret").
?- module(m).
trying to access a locked module in module(m)
?- call(pub) @ m.
pub
yes.
?- call(priv) @ m.
trying to access a locked module in priv
?- assert(foo) @ m.
trying to access a locked module in assert_(foo, m)
?- unlock(m, "pass").
key not correct in unlock(m, "pass")
?- unlock(m, "secret").
yes.
?- call(priv) @ m.
priv
yes.
?- assert(foo) @ m.
yes.