From 63db194140145d67681b5f16c8df8a87fc783d52 Mon Sep 17 00:00:00 2001 From: Paulo Moura <> Date: Mon, 10 May 2021 00:37:09 +0100 Subject: [PATCH] Fix char_code/2 predicate failure instead of exception on non-integer second argument --- src/lib/builtins.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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)) ). -- 2.54.0