Fix char_code/2 predicate failure instead of exception on non-integer second argument
This commit is contained in:
@@ -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) ->
|
||||||
|
( var(Code) ->
|
||||||
'$char_code'(Char, 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))
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user