Elixir: Warning 'protocol has already been consolidated' when recompiling

Created on 19 Sep 2016  路  7Comments  路  Source: elixir-lang/elixir

When I add a protocol implementation such as the following, I run into a waring when recompiling:

defimpl Poison.Encoder, for: BSON.ObjectId do
  def encode(id, options) do
    BSON.ObjectId.encode!(id) |> Poison.Encoder.encode(options)
  end
end

produces on recompile

warning: the Poison.Encoder protocol has already been consolidated, an implementation for BSON.ObjectId has no effect

Using Elixir 1.3.2, for more info see https://github.com/ericmj/mongodb/issues/46#issuecomment-247893455

IEx Bug

Most helpful comment

has this regressed? I am using Elixir 1.9.0-rc.0 (aad7aa4) (compiled with Erlang/OTP 20)

All 7 comments

This happens when calling recompile/0 in iex.

I believe this is happening to you on auto-recompile as it is for me.

If you make changes to the Encoder you have to stop the app and restart to see the changes.

has this regressed? I am using Elixir 1.9.0-rc.0 (aad7aa4) (compiled with Erlang/OTP 20)

This seems to have regressed. I am using Elixir 1.8.1 with Erlang/OTP 20 and get the warning any time changed files are auto-recompiled in development.

I'm seeing the same warning with 1.8.2 compiled for Erlang/OTP 21. I can reproduce it every time by running r/1 in the iex console with the name of the module that's implementing the protocol (in this case the protocol is Phoenix.HTML.Safe).

Same here, happens at recompilation with

elixir --version
Erlang/OTP 21 [erts-10.3.5.6] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Elixir 1.8.2 (compiled with Erlang/OTP 21)

Would be cleaner without it. :smile:

Hitting this all the time as well, cannot auto-recompile at all, have to manually restart the server if we use --warnings-as-errors, have to restart server for any change.

Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe]
Elixir 1.9.0 (compiled with Erlang/OTP 20)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chulkilee picture chulkilee  路  3Comments

ericmj picture ericmj  路  3Comments

eproxus picture eproxus  路  3Comments

GianFF picture GianFF  路  3Comments

andrewcottage picture andrewcottage  路  3Comments