From b96cd0612932517e9615a334b5942f934f9216fd Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Mon, 16 May 2022 16:32:38 -0600 Subject: [PATCH] detect character type errors in atom_{chars|codes}/2 (#1472) --- src/lib/builtins.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index f6d02de8..be7b2cd3 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -1258,10 +1258,12 @@ atom_chars(Atom, List) :- ( var(Tail) -> throw(error(instantiation_error, atom_chars/2)) ; ground(List) -> + chars_or_vars(List, atom_chars/2), '$atom_chars'(Atom, List) ; throw(error(instantiation_error, atom_chars/2)) ) ; atom(Atom) -> + chars_or_vars(List, atom_chars/2), '$atom_chars'(Atom, List) ; throw(error(type_error(atom, Atom), atom_chars/2)) ). @@ -1275,11 +1277,13 @@ atom_codes(Atom, List) :- ( var(Atom) -> ( var(Tail) -> throw(error(instantiation_error, atom_codes/2)) - ; ground(List), Tail == [] -> + ; ground(List) -> + codes_or_vars(List, atom_codes/2), '$atom_codes'(Atom, List) ; throw(error(instantiation_error, atom_codes/2)) ) ; atom(Atom) -> + codes_or_vars(List, atom_codes/2), '$atom_codes'(Atom, List) ; throw(error(type_error(atom, Atom), atom_codes/2)) ). -- 2.54.0