]> Repositorios git - scryer-prolog.git/commitdiff
detect character type errors in atom_{chars|codes}/2 (#1472)
authorMark Thom <[email protected]>
Mon, 16 May 2022 22:32:38 +0000 (16:32 -0600)
committerMark Thom <[email protected]>
Mon, 16 May 2022 22:32:38 +0000 (16:32 -0600)
src/lib/builtins.pl

index f6d02de86cff416c1d2178610914bdf3dc41f2e1..be7b2cd3e8b5a57c4b9f8755be761a39acf91032 100644 (file)
@@ -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))
     ).