Aetherus
Elixir 1.14.1 Protocol issue (Protocol.UndefinedError) - works in Elixir 1.14.0, but not in 1.14.1
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/lib/elixir/lib/protocol.ex at a285e5876b6f69e7c340d04851aae63c8a32bf1d · elixir-lang/elixir · GitHub
- elixir/lib/elixir/lib/protocol.ex at c5151e6890b5ac8df13276459696f0f47a8e634b · elixir-lang/elixir · GitHub
I don’t know if this is relevant. Please take a look. Thanks
Marked As Solved
LostKobrakai
You can do this to define an implementation for Bar, but I’m positive your version is not supposed to break as well.
defmodule Bar do
defstruct []
defimpl Foo do
def foo(x) do
...
end
end
end
2
Also Liked
al2o3cr
FWIW, this is an issue that will be fixed in 1.14.2:
2
Aetherus
Thank you for your quick reply. Saved my day. ![]()
1
Popular in Questions
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
I am trying to implement my new.html.eex file to create new posts on my website.
new.html.eex:
<h1>Create Post</h1>
<%= ...
New
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
I have a super simple question about elixir - how would I take a file like this
foo
bar
baz
and output a new file that enumerates th...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Other popular topics
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)?
Would
mix ecto.rollback -v 200809061...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










