Skip to content

Conversation

@davidjulien
Copy link
Contributor

On Elixir 1.19, mix compile fails with:

== Compilation error in file lib/panpipe/document.ex ==
** (ProtocolEx.MissingRequiredProtocolDefinition) On Protocol `Elixir.Panpipe.Pandoc.AST.Node` missing a required protocol callback on `Panpipe.Pandoc.Document` of:  to_panpipe/1
    (protocol_ex 0.4.4) lib/protocol_ex.ex:692: anonymous fn/3 in ProtocolEx.verify_valid_spec_on_module/3
    (elixir 1.19.3) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2
    (protocol_ex 0.4.4) lib/protocol_ex.ex:678: ProtocolEx.verify_valid_spec_on_module/3
    lib/panpipe/document.ex:36: (file)
  • ProtocolEx.MissingRequiredProtocolDefinition
  • missing to_panpipe/1 for the Pandoc document matcher (the %{"blocks" => _, "pandoc-api-version" => _} map)

Although to_panpipe/1 was present in the defimpl_ex in lib/panpipe/document.ex, ProtocolEx's compile-time verification could fail to see the exported callback during compilation, causing a hard compilation failure.

  • Remove the standalone defimpl_ex from lib/panpipe/document.ex.
  • Handle Pandoc's top-level document map in the fallback implementation of Panpipe.Pandoc.AST.Node.to_panpipe/1 inside lib/panpipe/ast/nodes.ex using a case clause.

This keeps the conversion logic in one place and avoids the ProtocolEx per-implementation callback verification ordering issue on Elixir 1.19.

On Elixir 1.19, `mix compile` fails with:

```
== Compilation error in file lib/panpipe/document.ex ==
** (ProtocolEx.MissingRequiredProtocolDefinition) On Protocol `Elixir.Panpipe.Pandoc.AST.Node` missing a required protocol callback on `Panpipe.Pandoc.Document` of:  to_panpipe/1
    (protocol_ex 0.4.4) lib/protocol_ex.ex:692: anonymous fn/3 in ProtocolEx.verify_valid_spec_on_module/3
    (elixir 1.19.3) lib/enum.ex:1688: Enum."-map/2-lists^map/1-1-"/2
    (protocol_ex 0.4.4) lib/protocol_ex.ex:678: ProtocolEx.verify_valid_spec_on_module/3
    lib/panpipe/document.ex:36: (file)
```

- `ProtocolEx.MissingRequiredProtocolDefinition`
- missing `to_panpipe/1` for the Pandoc document matcher (the `%{"blocks" => _, "pandoc-api-version" => _}` map)

Although `to_panpipe/1` was present in the `defimpl_ex` in `lib/panpipe/document.ex`, ProtocolEx's compile-time verification could fail to see the exported callback during compilation, causing a hard compilation failure.

- Remove the standalone `defimpl_ex` from `lib/panpipe/document.ex`.
- Handle Pandoc's top-level document map in the fallback implementation of `Panpipe.Pandoc.AST.Node.to_panpipe/1` inside `lib/panpipe/ast/nodes.ex` using a `case` clause.

This keeps the conversion logic in one place and avoids the ProtocolEx per-implementation callback verification ordering issue on Elixir 1.19.
@marcelotto
Copy link
Owner

Sorry for the late response. This slipped through over the holidays.

Thanks. ❤️

@marcelotto marcelotto merged commit d296d5f into marcelotto:master Jan 14, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants