OvermindDL1 / protocol_ex

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

ProtcolEx implementation fails to compile with @spec #66

Open DaTrader opened 2 years ago

DaTrader commented 2 years ago

The following code does not compile (Elixir 1.13.4) unless the @spec is removed:

import ProtocolEx

defprotocol_ex JsonDecodable do
  @spec decode( term()) :: { :ok, term()} | { :error, any()}
  def decode( json_decodable)
end

The compiler error:

== Compilation error in file lib/json_decoder/json_decodable.ex ==
** (ProtocolEx.InvalidProtocolSpecification) Unhandled specification node:  {:@, [line: 4], [{:spec, [line: 4], [{:"::", [line: 4], [{:decode, [line: 4], [{:term, [line: 4], []}]}, {:|, [line: 4], [{:ok, {:term, [line: 4], []}}, nil]}]}]}]}
    (protocol_ex 0.4.4) lib/protocol_ex.ex:618: ProtocolEx.decompose_spec_element/4
    (protocol_ex 0.4.4) lib/protocol_ex.ex:548: ProtocolEx.decompose_spec/4
    (protocol_ex 0.4.4) expanding macro: ProtocolEx.defprotocolEx/3
    lib/json_decoder/json_decodable.ex:3: (file)
    (protocol_ex 0.4.4) expanding macro: ProtocolEx.defprotocol_ex/2
    lib/json_decoder/json_decodable.ex:3: (file)
OvermindDL1 commented 5 months ago

Hrmm, yeah I never took into account spec nodes either... PR is welcome? Or I'll get to it next time I do an update on my internal systems... :-)