Skip to content

Commit 7b0796c

Browse files
committed
Remove ambiguous type wording from protocol errors
1 parent 7b80ac9 commit 7b0796c

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

lib/elixir/lib/exception.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ defmodule Protocol.UndefinedError do
20032003
# Indent only lines with contents on them
20042004
|> String.replace(~r/^(?=.+)/m, " ")
20052005

2006-
"protocol #{inspect(protocol)} not implemented for type " <>
2006+
"protocol #{inspect(protocol)} not implemented for " <>
20072007
value_type(value) <>
20082008
maybe_description(description) <>
20092009
maybe_available(protocol) <>
@@ -2038,7 +2038,7 @@ defmodule Protocol.UndefinedError do
20382038
". There are no implementations for this protocol."
20392039

20402040
{:consolidated, types} ->
2041-
". This protocol is implemented for the following type(s): " <>
2041+
". This protocol is implemented for: " <>
20422042
Enum.map_join(types, ", ", &inspect/1)
20432043

20442044
:not_consolidated ->

lib/elixir/lib/kernel.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5382,7 +5382,7 @@ defmodule Kernel do
53825382
53835383
john = %User{name: "John"}
53845384
MyProtocol.call(john)
5385-
** (Protocol.UndefinedError) protocol MyProtocol not implemented for %User{...}
5385+
** (Protocol.UndefinedError) protocol MyProtocol not implemented for User (a struct)
53865386
53875387
`defstruct/1`, however, allows protocol implementations to be
53885388
*derived*. This can be done by defining a `@derive` attribute as a

lib/elixir/test/elixir/inspect_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ defmodule Inspect.MapTest do
526526
# Inspect.Error is raised here when we tried to print the error message
527527
# called by another exception (Protocol.UndefinedError in this case)
528528
exception_message = ~s'''
529-
protocol Enumerable not implemented for type Inspect.MapTest.Failing (a struct)
529+
protocol Enumerable not implemented for Inspect.MapTest.Failing (a struct)
530530
531531
Got value:
532532
@@ -930,7 +930,7 @@ defmodule Inspect.CustomProtocolTest do
930930
got Protocol.UndefinedError with message:
931931
932932
"""
933-
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for type Inspect.CustomProtocolTest.MissingImplementation (a struct)
933+
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for Inspect.CustomProtocolTest.MissingImplementation (a struct)
934934
935935
Got value:
936936
@@ -961,7 +961,7 @@ defmodule Inspect.CustomProtocolTest do
961961
got Protocol.UndefinedError with message:
962962
963963
"""
964-
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for type Inspect.CustomProtocolTest.MissingImplementation (a struct)
964+
protocol Inspect.CustomProtocolTest.CustomInspect not implemented for Inspect.CustomProtocolTest.MissingImplementation (a struct)
965965
966966
Got value:
967967

lib/elixir/test/elixir/protocol/consolidation_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ defmodule Protocol.ConsolidationTest do
182182

183183
test "protocol not implemented" do
184184
message =
185-
"protocol Protocol.ConsolidationTest.Sample not implemented for type Atom. " <>
186-
"This protocol is implemented for the following type(s): Protocol.ConsolidationTest.ImplStruct" <>
185+
"protocol Protocol.ConsolidationTest.Sample not implemented for Atom. " <>
186+
"This protocol is implemented for: Protocol.ConsolidationTest.ImplStruct" <>
187187
"\n\nGot value:\n\n :foo\n"
188188

189189
assert_raise Protocol.UndefinedError, message, fn ->

lib/elixir/test/elixir/protocol_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ defmodule ProtocolTest do
120120
test "protocol not implemented" do
121121
message =
122122
"""
123-
protocol ProtocolTest.Sample not implemented for type Atom
123+
protocol ProtocolTest.Sample not implemented for Atom
124124
125125
Got value:
126126
@@ -289,7 +289,7 @@ defmodule ProtocolTest do
289289
assert Derivable.ok(struct) == {:ok, struct, %ImplStruct{}, []}
290290

291291
assert_raise Protocol.UndefinedError,
292-
~r"protocol ProtocolTest.Derivable not implemented for type ProtocolTest.NoImplStruct \(a struct\), you should try harder",
292+
~r"protocol ProtocolTest.Derivable not implemented for ProtocolTest.NoImplStruct \(a struct\), you should try harder",
293293
fn ->
294294
struct = %NoImplStruct{a: 1, b: 1}
295295
Derivable.ok(struct)

lib/elixir/test/elixir/string/chars_test.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ defmodule String.Chars.ErrorsTest do
106106
test "bitstring" do
107107
message =
108108
"""
109-
protocol String.Chars not implemented for type BitString, cannot convert a bitstring to a string
109+
protocol String.Chars not implemented for BitString, cannot convert a bitstring to a string
110110
111111
Got value:
112112
@@ -120,7 +120,7 @@ defmodule String.Chars.ErrorsTest do
120120

121121
test "tuple" do
122122
message = """
123-
protocol String.Chars not implemented for type Tuple
123+
protocol String.Chars not implemented for Tuple
124124
125125
Got value:
126126
@@ -134,7 +134,7 @@ defmodule String.Chars.ErrorsTest do
134134

135135
test "PID" do
136136
message =
137-
~r"^protocol String\.Chars not implemented for type PID\n\nGot value:\n\n #PID<.+?>$"
137+
~r"^protocol String\.Chars not implemented for PID\n\nGot value:\n\n #PID<.+?>$"
138138

139139
assert_raise Protocol.UndefinedError, message, fn ->
140140
to_string(self())
@@ -143,7 +143,7 @@ defmodule String.Chars.ErrorsTest do
143143

144144
test "ref" do
145145
message =
146-
~r"^protocol String\.Chars not implemented for type Reference\n\nGot value:\n\n #Reference<.+?>$"
146+
~r"^protocol String\.Chars not implemented for Reference\n\nGot value:\n\n #Reference<.+?>$"
147147

148148
assert_raise Protocol.UndefinedError, message, fn ->
149149
to_string(make_ref()) == ""
@@ -152,7 +152,7 @@ defmodule String.Chars.ErrorsTest do
152152

153153
test "function" do
154154
message =
155-
~r"^protocol String\.Chars not implemented for type Function\n\nGot value:\n\n #Function<.+?>$"
155+
~r"^protocol String\.Chars not implemented for Function\n\nGot value:\n\n #Function<.+?>$"
156156

157157
assert_raise Protocol.UndefinedError, message, fn ->
158158
to_string(fn -> nil end)
@@ -163,7 +163,7 @@ defmodule String.Chars.ErrorsTest do
163163
[port | _] = Port.list()
164164

165165
message =
166-
~r"^protocol String\.Chars not implemented for type Port\n\nGot value:\n\n #Port<.+?>$"
166+
~r"^protocol String\.Chars not implemented for Port\n\nGot value:\n\n #Port<.+?>$"
167167

168168
assert_raise Protocol.UndefinedError, message, fn ->
169169
to_string(port)
@@ -172,7 +172,7 @@ defmodule String.Chars.ErrorsTest do
172172

173173
test "user-defined struct" do
174174
message =
175-
"protocol String\.Chars not implemented for type String.Chars.ErrorsTest.Foo (a struct)\n\nGot value:\n\n %String.Chars.ErrorsTest.Foo{foo: \"bar\"}\n"
175+
"protocol String\.Chars not implemented for String.Chars.ErrorsTest.Foo (a struct)\n\nGot value:\n\n %String.Chars.ErrorsTest.Foo{foo: \"bar\"}\n"
176176

177177
assert_raise Protocol.UndefinedError, message, fn ->
178178
to_string(%Foo{})

0 commit comments

Comments
 (0)