Closed pmoura closed 1 year ago
Great find!
I have constructed a query that exhibits the issue, using ($)/1
from library(debug)
:
?- catch(get_byte(user_input, C), E, true), Err = error(permission_error(_,_,user_input),_), $subsumes_term(Err, E). call:subsumes_term(error(permission_error(A,B,user_input),C),error(permission_error(input,text_stream,user_input),get_byte/2)). false.
Whereas the portrayed goal succeeds in isolation:
?- subsumes_term(error(permission_error(A,B,user_input),C),error(permission_error(input,text_stream,user_input),get_byte/2)). true.
Unification also fails unexpectedly:
?- catch(get_byte(user_input, C), E, true), Err = error(permission_error(_,_,user_input),_), $Err = E. call:(error(permission_error(A,B,user_input),C)=error(permission_error(input,text_stream,user_input),get_byte/2)). false.
I think this may also make #1472 work as intended!
Confirmed.
But:
?- catch(get_byte(user_input, C), error(permission_error(_,_,S),_), true),
Si = user_input,
Si = S.
S = user_input, Si = user_input.
?- catch(get_byte(user_input, C), error(permission_error(_,_,S),_), true),
Si = user_input,
Si == S.
false.
?-
Several tests in the Logtalk distribution check for expected exceptions using the
subsumes_term/2
predicate. While all current tests for this predicate pass, we still see test failures like:As you can see, in all cases above (and other not show here), the expected exception subsumes the actual exception. But the implicit
subsumes_term/2
call fails. This may be due to a dereferencing bug in thesubsumes_term/2
predicate implementation or elsewhere. As typical of dereferencing bugs, the same calls succeed in the top-level. Fixing this bug will fix a few dozen test failures in Prolog standards compliance test suite.