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:
@@ -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))
|
||||
).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user