Skip to content

Commit 57be943

Browse files
committed
Do not raise on foreign types, closes #10077
1 parent 99cad59 commit 57be943

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/iex/lib/iex/introspection.ex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -735,9 +735,15 @@ defmodule IEx.Introspection do
735735
## Helpers
736736

737737
defp format_typespec(definition, kind, nesting) do
738-
"@#{kind} #{Macro.to_string(definition)}"
739-
|> Code.format_string!(line_length: IEx.width() - 2 * nesting)
740-
|> IO.iodata_to_binary()
738+
string = "@#{kind} #{Macro.to_string(definition)}"
739+
740+
try do
741+
string
742+
|> Code.format_string!(line_length: IEx.width() - 2 * nesting)
743+
|> IO.iodata_to_binary()
744+
rescue
745+
_ -> string
746+
end
741747
|> color_prefix_with_line()
742748
|> indent(nesting)
743749
end

lib/iex/test/iex/helpers_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,7 @@ defmodule IEx.HelpersTest do
853853
defmodule TypeSample do
854854
@typedoc "An ID with description."
855855
@type id_with_desc :: {number, String.t}
856+
@type unquote(:"?")() :: :question_mark
856857
end
857858
"""
858859

@@ -872,6 +873,11 @@ defmodule IEx.HelpersTest do
872873
873874
An ID with description.
874875
"""
876+
877+
assert capture_io(fn -> t(TypeSample."?"()) end) == """
878+
@type ?() :: :question_mark
879+
880+
"""
875881
end)
876882
after
877883
cleanup_modules([TypeSample])

0 commit comments

Comments
 (0)