Merge pull request #945 from pmoura/fix_char_code_error_checking

Fix char_code/2 predicate failure instead of exception on non-integer second argument
This commit is contained in:
Mark Thom
2021-05-10 11:08:58 -06:00
committed by GitHub

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