summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans <hanspagh@gmail.com>2018-11-27 01:04:00 +0100
committerJosé Valim <jose.valim@gmail.com>2018-11-27 01:04:00 +0100
commitdb9314374d394f7fca8223b90e722a8ffa851d72 (patch)
tree0c24964de293b66ecdb376069f74414d2e137dad
parent123cc6f8848fac81725cf788c98b0fe4b86189d1 (diff)
downloadelixir-db9314374d394f7fca8223b90e722a8ffa851d72.tar.gz
Add special fn case to signature_to_binary (#8429)
-rw-r--r--lib/elixir/src/elixir_erl.erl3
-rw-r--r--lib/elixir/test/elixir/kernel/docs_test.exs8
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/elixir/src/elixir_erl.erl b/lib/elixir/src/elixir_erl.erl
index 9623df65c..f8ea91032 100644
--- a/lib/elixir/src/elixir_erl.erl
+++ b/lib/elixir/src/elixir_erl.erl
@@ -531,6 +531,9 @@ get_type_docs(Set, Types) ->
signature_to_binary(_Module, Name, _Signature) when Name == '__aliases__'; Name == '__block__' ->
<<(atom_to_binary(Name, utf8))/binary, "(args)">>;
+signature_to_binary(_Module, fn, _Signature) ->
+ <<"fn">>;
+
signature_to_binary(_Module, Name, _Signature)
when Name == '__CALLER__'; Name == '__DIR__'; Name == '__ENV__';
Name == '__MODULE__'; Name == '__STACKTRACE__'; Name == '%{}' ->
diff --git a/lib/elixir/test/elixir/kernel/docs_test.exs b/lib/elixir/test/elixir/kernel/docs_test.exs
index b5209a21d..fd26dd2a5 100644
--- a/lib/elixir/test/elixir/kernel/docs_test.exs
+++ b/lib/elixir/test/elixir/kernel/docs_test.exs
@@ -307,4 +307,12 @@ defmodule Kernel.DocsTest do
{{:fuz, 0}, :none}
] = Enum.sort(function_docs)
end
+
+ describe "special signatures" do
+ test "fn" do
+ {:docs_v1, _, _, _, _, _, docs} = Code.fetch_docs(Kernel.SpecialForms)
+ {_, _, fn_docs, _, _} = Enum.find(docs, &match?({_, :fn, 1}, elem(&1, 0)))
+ assert fn_docs == ["fn"]
+ end
+ end
end