The following code works in Elixir 1.14.0, but not in 1.14.1:
defprotocol Foo do
def foo(x)
end
###################
defmodule Bar do
defstruct []
defimpl Foo, for: __MODULE__ do
def foo(x) do
...
end
end
end
##################
Foo.foo(%Bar{})
In 1.14.1, when the last statement is called, the following error is raised (I was trying this in Livebook):
** (Protocol.UndefinedError) protocol Foo not implemented for %Bar{} of type Bar (a struct)
#cell:enx47nczjxo7awjw44j4cdlxiv536l3w:1: Foo.impl_for!/1
#cell:enx47nczjxo7awjw44j4cdlxiv536l3w:2: Foo.foo/1
#cell:2zzjhjq5howfzuc33tjy7lttvaatqq2r:1: (file)
I compared the source code in these 2 versions, and the only difference I saw is
- elixir/protocol.ex at a285e5876b6f69e7c340d04851aae63c8a32bf1d · elixir-lang/elixir · GitHub
- elixir/protocol.ex at c5151e6890b5ac8df13276459696f0f47a8e634b · elixir-lang/elixir · GitHub
I don’t know if this is relevant. Please take a look. Thanks