diff --git a/lib/ex_doc/language/erlang.ex b/lib/ex_doc/language/erlang.ex index b45cdd1dc..5864c7092 100644 --- a/lib/ex_doc/language/erlang.ex +++ b/lib/ex_doc/language/erlang.ex @@ -538,8 +538,8 @@ defmodule ExDoc.Language.Erlang do {name, _, _}, acc when name in [:<<>>, :..] -> {nil, acc} - # -1 - {:-, _, [int]}, acc when is_integer(int) -> + # -1, +1 + {op, _, [int]}, acc when is_integer(int) and op in [:+, :-] -> {nil, acc} # fun() (spec_to_quoted expands it to (... -> any()) diff --git a/test/ex_doc/language/erlang_test.exs b/test/ex_doc/language/erlang_test.exs index 6b16eb4d0..a440d512a 100644 --- a/test/ex_doc/language/erlang_test.exs +++ b/test/ex_doc/language/erlang_test.exs @@ -767,6 +767,11 @@ defmodule ExDoc.Language.ErlangTest do ~s[foo() -> 1..255 | t().] end + test "integer unary", c do + assert autolink_spec(~s"-spec f(LimitedInteger :: +1 | -1) -> t().", c) == + ~s[f(LimitedInteger :: +1 | -1) -> t().] + end + test "function - any", c do assert autolink_spec(~s"-spec foo() -> fun() | t().", c) == ~s[foo() -> fun() | t().]