save_image fails if target image name contains a dash
?- save_image(sitest, [libload(Bool)]).
succeeds, making sitest, sitest.pst.
But
?- save_image(si-test, [libload(Bool)]).
goes into an infinite failure bounce at the end of library loading:
….. Loading /Users/ken/ALS/GitHub/ALSProlog/unix/darwin/als-prolog/alsdir/library/xlists ...loaded ...loaded ...loaded ...loaded Loading /Users/ken/ALS/GitHub/ALSProlog/unix/darwin/als-prolog/alsdir/library/xlists …..
Executing ?-toggle_mod_show(builtins), and tracing shows shows that the cause of the failure is this failure of pbi_copy_file:
(1) 1 call: builtins: pbi_copy_file( /Users/ken/ALS/HH/ALSProlog_3.5.0-38-gc7934fa1/unix/darwin/als-prolog/alspro, si-test)? (1) 1 fail: builtins: pbi_copy_file( /Users/ken/ALS/HHH/ALSProlog_3.5.0-38-gc7934fa1/unix/darwin/als-prolog/alspro, si-test)?
Yea, a lot of procedures don't have any error handling for unexpected arguments -- in this case the compound term '-'(si, test). To get the ball rolling, here are some proposed error tests for save_image:
etest(Goal, Error) :- catch((Goal, !, fail), error(Error, _), true).
test_errors :- test([
etest(save_image(V), instantiation_error),
etest(save_image(1), type_error(atom, 1)),
etest(save_image(f(a)), type_error(atom, f(a))),
...
]).