From: Mark Thom Date: Mon, 16 May 2022 22:32:38 +0000 (-0600) Subject: detect character type errors in atom_{chars|codes}/2 (#1472) X-Git-Tag: v0.9.1~27 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=b96cd0612932517e9615a334b5942f934f9216fd;p=scryer-prolog.git detect character type errors in atom_{chars|codes}/2 (#1472) --- 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)) ).