Skip to content

Commit

Permalink
Handle all erl_anno:file() cases, fix self-check error
Browse files Browse the repository at this point in the history
  • Loading branch information
erszcz committed Sep 20, 2024
1 parent 701e244 commit 8858c41
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/typelib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,15 @@ annotate_user_type_(_Filename, Type) ->
-spec get_module_from_annotation(erl_anno:anno()) -> {ok, module()} | none.
get_module_from_annotation(Anno) ->
case erl_anno:file(Anno) of
File when is_list(File) ->
Basename = filename:basename(File, ".erl"),
{ok, list_to_existing_atom(?assert_type(Basename, string()))};
undefined ->
none
none;
File ->
case unicode:characters_to_binary(filename:basename(File, ".erl")) of
Basename when is_binary(Basename) ->
{ok, binary_to_existing_atom(Basename)};
_ ->
erlang:error({malformed_anno, Anno})
end
end.

-spec substitute_type_vars(type(),
Expand Down

0 comments on commit 8858c41

Please sign in to comment.