Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/elixir/lib/exception.ex
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,13 @@ defmodule UnicodeConversionError do
"encoding starting at #{inspect rest}"
end

defp detail([h|_]) do
defp detail([h|_]) when is_integer(h) do
"code point #{h}"
end

defp detail([h|_]) do
detail(h)
end
end

defmodule Enum.OutOfBoundsError do
Expand Down
4 changes: 4 additions & 0 deletions lib/elixir/test/elixir/list_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ defmodule ListTest do
"invalid code point 57343", fn ->
List.to_string([0xDFFF])
end
assert_raise UnicodeConversionError,
"invalid encoding starting at <<216, 0>>", fn ->
List.to_string(["a", "b", <<0xD800 :: size(16)>>])
end

assert_raise ArgumentError,
"cannot convert list to string. The list must contain only integers, strings or nested such lists; got: [:a, :b]", fn ->
Expand Down