..., 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) :- compound(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).