Change fate_to_erlang warning
This warning always confuses me. Usually it is a case I haven't actually implemented, but I don't need the program to diagnose that for me, I need the program to tell me what the type was, so that I can work out why it thinks it isn't implemented. All three terms of the annotated type are relevant, but the annotated version can only differ from the normalized version if it is a record or variant definition, so we special case those two just to communicate that the fact that it is *some* kind of record did successfully pass through to the coerce logic, and otherwise we just try and print the opaque and normalized types faithfully.
This commit is contained in:
+22
-7
@@ -944,15 +944,30 @@ fate_to_erlang({O, N, {unknown_type, _}}, Data) ->
|
|||||||
io:format(Message, [O, N, Data])
|
io:format(Message, [O, N, Data])
|
||||||
end,
|
end,
|
||||||
{ok, Data};
|
{ok, Data};
|
||||||
fate_to_erlang({O, N, _}, Data) ->
|
fate_to_erlang(Type, Data) ->
|
||||||
case N of
|
TypeStr = type_to_iolist(Type),
|
||||||
already_normalized ->
|
io:format("Warning: Could not coerce term into ~s. Using term as is: ~p~n", [TypeStr, Data]),
|
||||||
io:format("Warning: Unimplemented type ~p.~nUsing term as is:~n~p~n", [O, Data]);
|
|
||||||
_ ->
|
|
||||||
io:format("Warning: Unimplemented type ~p (i.e. ~p).~nUsing term as is:~n~p~n", [O, N, Data])
|
|
||||||
end,
|
|
||||||
{ok, Data}.
|
{ok, Data}.
|
||||||
|
|
||||||
|
type_to_iolist({O, already_normalized, S}) ->
|
||||||
|
% Already normalized. Example output:
|
||||||
|
% type {map, [string, integer]}
|
||||||
|
opaque_type_to_iolist(O, S);
|
||||||
|
type_to_iolist({O, N, S}) ->
|
||||||
|
% Type alias. Print the alias, and then print the normalized version in
|
||||||
|
% parentheses. Example output:
|
||||||
|
% type "my_alias" (i.e. record type {"my_record_type", [integer]})
|
||||||
|
io_lib:format("type ~p (i.e. ~s)", [O, opaque_type_to_iolist(N, S)]).
|
||||||
|
|
||||||
|
opaque_type_to_iolist(N, {record, _}) ->
|
||||||
|
% N is the name of a record definition.
|
||||||
|
io_lib:format("record type ~p", [N]);
|
||||||
|
opaque_type_to_iolist(N, {variant, _}) ->
|
||||||
|
% N is the name of a variant definition.
|
||||||
|
io_lib:format("variant type ~p", [N]);
|
||||||
|
opaque_type_to_iolist(N, _) ->
|
||||||
|
% N is some other constructive type.
|
||||||
|
io_lib:format("type ~p", [N]).
|
||||||
|
|
||||||
|
|
||||||
%%% AACI Getters
|
%%% AACI Getters
|
||||||
|
|||||||
Reference in New Issue
Block a user