From: Paulo Moura <> Date: Sun, 9 May 2021 23:37:09 +0000 (+0100) Subject: Fix char_code/2 predicate failure instead of exception on non-integer second argument X-Git-Tag: v0.9.0~81^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=63db194140145d67681b5f16c8df8a87fc783d52;p=scryer-prolog.git Fix char_code/2 predicate failure instead of exception on non-integer second argument --- diff --git a/src/lib/builtins.pl b/src/lib/builtins.pl index 502827b6..49b352e7 100644 --- a/src/lib/builtins.pl +++ b/src/lib/builtins.pl @@ -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)) ).