elixir-lang/ex_doc

A certain type definition with multiple any() crashes ex_doc

Closed this issue · 0 comments

The below type definition causes a crash on main (commit d8146c3)

-type foo() :: fun((...) -> any()) | [any()].

crash:

       (ex_doc 0.35.1) lib/ex_doc/language/erlang.ex:699: ExDoc.Language.Erlang.pop/0
       (ex_doc 0.35.1) lib/ex_doc/language/erlang.ex:617: anonymous fn/2 in ExDoc.Language.Erlang.replace/3
       (elixir 1.14.0) lib/string.ex:1620: String.do_replace/4
       (elixir 1.14.0) lib/string.ex:1623: String.do_replace/4
       (elixir 1.14.0) lib/string.ex:1577: String.replace_guarded/4
       (ex_doc 0.35.1) lib/ex_doc/language/erlang.ex:601: ExDoc.Language.Erlang.autolink_spec/4

I couldn't shrink it further what is special about that contrived type definition, but the below type definitions work fine:

-type foo() :: fun() | [any()].
-type foo() :: fun((...) -> integer()) | [any()].
-type foo() :: fun((...) -> any()) | [integer()].