From a5e72679bcc615b737aa32dee5b24fdf4f426619 Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Sat, 14 May 2022 09:52:34 +0200 Subject: [PATCH] prioritize type errors over instantiation errors Example: ?- must_be(chars, [a,X,cc]). error(type_error(character,cc),can_be/2). See https://github.com/mthom/scryer-prolog/pull/1474#issuecomment-1126664368 --- src/lib/error.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/error.pl b/src/lib/error.pl index a7cc4a5a..87b3ff46 100644 --- a/src/lib/error.pl +++ b/src/lib/error.pl @@ -1,5 +1,5 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Written September 2018 by Markus Triska (triska@metalevel.at) + Written 2018-2022 by Markus Triska (triska@metalevel.at) I place this code in the public domain. Use it in any way you want. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -48,6 +48,7 @@ must_be_(integer, Term) :- check_(integer, integer, Term). must_be_(atom, Term) :- check_(atom, atom, Term). must_be_(character, T) :- check_(error:character, character, T). must_be_(chars, Ls) :- + can_be(chars, Ls), % prioritize type errors over instantiation errors must_be(list, Ls), ( '$is_partial_string'(Ls) -> % The expected case (success) uses a very fast test. -- 2.54.0