Skip to content

Commit 49fa59d

Browse files
author
José Valim
committed
Improve Typespec stacktraces
1 parent c06a44c commit 49fa59d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/elixir/lib/kernel/typespec.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ defmodule Kernel.Typespec do
536536

537537
# Handle funs
538538
defp typespec({:fun, line, args}, vars, caller) when is_list(args) do
539-
IO.write "[WARNING] fun() type is deprecated, use (... -> type) instead\n#{Exception.formatted_stacktrace}"
539+
IO.write "[WARNING] fun() type is deprecated, use (... -> type) instead\n#{Exception.env_stacktrace(caller)}"
540540
typespec({:"->", line, [{args, quote do: any}]}, vars, caller)
541541
end
542542
defp typespec({:"->", line, [{[{:fun, _, arguments}], return}]}, vars, caller) when is_list(arguments) do
@@ -598,7 +598,8 @@ defmodule Kernel.Typespec do
598598

599599
# Handle local calls
600600
defp typespec({:string, line, arguments}, vars, caller) do
601-
IO.write "#{caller.file}:#{caller.line}: warning: string() type use is discouraged. For character lists, use char_list() type, for strings, String.t()\n"
601+
IO.write "warning: string() type use is discouraged. For character lists, use " <>
602+
"char_list() type, for strings, String.t()\n#{Exception.env_stacktrace(caller)}"
602603
arguments = lc arg inlist arguments, do: typespec(arg, vars, caller)
603604
{ :type, line, :string, arguments }
604605
end

0 commit comments

Comments
 (0)