In ECLiPSe, some builtins raise events in cases where they just fail
in other systems, e.g. arg(1,2,X) fails in C-Prolog, but
raises a type error in ECLiPSe.
If some code relies on such behaviour, it is best to modify it by
adding an explicit check like
..., compound(T), arg(N, T, X), ...
Another alternative is to redefine the arg/3 builtin, using
:/2 to access the original version:
:- local arg/3.
arg(N, T, X) :-
eclipse_language:arg(N, T, X).
A third alternative
is to define an error handler which will fail the predicate
whenever the event is raised. In this case:
my_type_error(_, arg(_, _, _)) :- !, fail.
my_type_error(E, Goal) :- error(default(E), Goal).
:- set_error_handler(5, my_type_error/2).