Elixir and Erlang/OTP versions
elixir 1.20.0-rc.1-otp-28
erlang 28.3.1
Operating system
MacOS
Current behavior
Up to Elixir 1.19, the following protocol definition does not error. In Elixir 1.20 it produces an error which is quite tricky to work out.
defprotocol TestProtocol do
def to_string(name, options \\ [])
end
The error is:
warning: protocols can only define functions without implementation via def/1, found: to_string/1
│
1 │ defprotocol TestProtocol do
│ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
│
└─ lib/prototest_protocol.ex:1: TestProtocol (module)
It took me longer than expected to realise this is because the handling of default parameters produces multiple function clauses with a delegate implementation.
Expected behavior
- Restore the behaviour of Elixir 1.19 or
- Improve the error message when protocols attempt to define callbacks with default arguments.
Elixir and Erlang/OTP versions
elixir 1.20.0-rc.1-otp-28
erlang 28.3.1
Operating system
MacOS
Current behavior
Up to Elixir 1.19, the following protocol definition does not error. In Elixir 1.20 it produces an error which is quite tricky to work out.
The error is:
It took me longer than expected to realise this is because the handling of default parameters produces multiple function clauses with a delegate implementation.
Expected behavior