]> Repositorios git - scryer-prolog.git/commitdiff
Fix char_code/2 predicate failure instead of exception on non-integer second argument
authorPaulo Moura <>
Sun, 9 May 2021 23:37:09 +0000 (00:37 +0100)
committerPaulo Moura <>
Sun, 9 May 2021 23:37:09 +0000 (00:37 +0100)
src/lib/builtins.pl

index 502827b6cf3dd7c85c66877147472ab40e27fb69..49b352e7b2bcabe02efa8ef87124d939169afecd 100644 (file)
@@ -1293,7 +1293,12 @@ char_code(Char, Code) :-
        ;  throw(error(type_error(integer, Code), char_code/2))
        )
     ;  atom_length(Char, 1) ->
-       '$char_code'(Char, Code)
+       (  var(Code) ->
+          '$char_code'(Char, Code)
+       ;  integer(Code) ->
+          '$char_code'(Char, Code)
+       ;  throw(error(type_error(integer, Code), char_code/2))
+       )
     ;  throw(error(type_error(character, Char), char_code/2))
     ).