Skip to content

ProtcolEx implementation fails to compile with @spec #66

Description

@DaTrader

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions