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)) ).