Skip to content

Commit

Permalink
fix: avoid crash up in kivra_core
Browse files Browse the repository at this point in the history
  • Loading branch information
cdyb-kivra committed Oct 21, 2024
1 parent d3245e1 commit ce84107
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/eon_type.erl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ typecheck(#spec{term=Term0, type=Type, p_have=P_have}) ->
%% Since the extra_validation is typically used for checks
%% involving several terms, we return a reason given by
%% the validation code instead of a term name.
{error, Reason} -> {error, {untypable, [{x, Type, x, Reason, []}]}}
{error, Reason} -> {error, {untypable, [{to_iolist(Reason), Type, x, Reason, []}]}}
end;
false ->
Term
Expand All @@ -298,6 +298,13 @@ typecheck(#spec{term=Term0, type=Type, p_have=P_have}) ->
[?unlift(check_term(T, Type:element_type(Term0, P_have)))|| T <- Term0]
end.

to_iolist(Atom) when is_atom(Atom) ->
erlang:atom_to_binary(Atom);
to_iolist(Float) when is_float(Float) ->
erlang:float_to_binary(Float);
to_iolist(Any) ->
Any.

%%%_ * Behaviours ------------------------------------------------------
is_alias(Type) -> constructor(Type) =:= eon_type_alias.

Expand Down

0 comments on commit ce84107

Please sign in to comment.