Fix char_code/2 predicate failure instead of exception on non-integer second argument

This commit is contained in:
Paulo Moura
2021-05-10 00:37:09 +01:00
parent 9b483d381f
commit 63db194140

View File

@@ -1293,7 +1293,12 @@ char_code(Char, Code) :-
; throw(error(type_error(integer, Code), char_code/2)) ; throw(error(type_error(integer, Code), char_code/2))
) )
; atom_length(Char, 1) -> ; 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)) ; throw(error(type_error(character, Char), char_code/2))
). ).