OvermindDL1 / protocol_ex

Elixir Extended Protocol
https://hex.pm/packages/protocol_ex
49 stars 5 forks source link

Odd errors about doing a case in a match when I try to use a guard with `!` #21

Closed jjl closed 6 years ago

jjl commented 6 years ago

I've updated master on jjl/expro to reflect this failure for your easy testing.

The problem seems to be the !, it does not like it and the error is quite counterintuitive

defimpl_ex PointFiveTwo, %Two{}, for: One.PointFive do
  def pointfive(self) when !is_integer(self), do: :ok
  def pointfive(self), do: 1
end
== Compilation error in file lib/two.ex ==
** (CompileError) lib/two.ex:6: invalid expression in guard, case is not allowed in guards. To learn more about guards, visit: https://hexdocs.pm/elixir/guards.html
    (elixir) expanding macro: Kernel.!/1
    lib/two.ex:6: One.PointFive.PointFiveTwo.pointfive/1

Remove the bang and no more compile errors

michalmuskala commented 6 years ago

! is not allowed in guards. not is.

jjl commented 6 years ago

Ah, thanks for that @michalmuskala