ocsigen / ocsigen/tyxml

dune implicit_transitive_deps false leads to confusing errors

Open
#274 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
179
Forks
63
Avg merge
5h
Merged PRs (30d)
22

Description

test.ml:

open Tyxml.Html
let zz = p [ a [ txt "a" ] ]

dune-project:

(lang dune 2.5)
(implicit_transitive_deps false)

dune:

(executable
  (name test)
  (libraries tyxml))

This fails to build with hair-raising error :

$ dune build
File "test.ml", line 2, characters 13-26:
2 | let zz = p [ a [ txt "a" ] ]
                 ^^^^^^^^^^^^^
Error: This expression has type
         ([> ([> Html_types.txt ] as 'b) Html_types.a ] as 'a) elt
       but an expression was expected of type
         ([< Html_types.p_content_fun ] as 'c) elt
       Type 'a = [> `A of 'b ] is not compatible with type
         'c =
           [< `A of Html_types.phrasing_without_interactive
            | `Abbr
            | `Audio of Html_types.phrasing_without_media
            | `Audio_interactive of Html_types.phrasing_without_media
            | `B
            | `Bdo
            | `Br
            | `Button
            | `Canvas of Html_types.phrasing
            | `Cite
            | `Code
            | `Command
            | `Datalist
            | `Del of Html_types.phrasing
            | `Dfn
            | `Em
            | `Embed
            | `I
            | `Iframe
            | `Img
            | `Img_interactive
            | `Input
            | `Ins of Html_types.phrasing
            | `Kbd
            | `Keygen
            | `Label
            | `Map of Html_types.phrasing
            | `Mark
            | `Meter
            | `Noscript of Html_types.phrasing_without_noscript
            | `Object of Html_types.phrasing
            | `Object_interactive of Html_types.phrasing
            | `Output
            | `PCDATA
            | `Progress
            | `Q
            | `Ruby
            | `Samp
            | `Script
            | `Select
            | `Small
            | `Span
            | `Strong
            | `Sub
            | `Sup
            | `Svg
            | `Template
            | `Textarea
            | `Time
            | `U
            | `Var
            | `Video of Html_types.phrasing_without_media
            | `Video_interactive of Html_types.phrasing_without_media
            | `Wbr ] 
       Type 'b = [> `PCDATA ] is not compatible with type
         Html_types.phrasing_without_interactive 
       Types for tag `A are incompatible

I believe the reason is that tyxml.functor is not in scope during build, so some types become abstract (I am still confused why the build proceeds instead of failing), and then it leads to such an error.
Solution: explicitly add tyxml.functor to libraries stanza in my project
I believe this can be fixed on tyxml side by using (re_export tyxml.functor) (but requires upgrade to dune 2)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the provided test.ml, dune-project, and dune files with implicit_transitive_deps false, then run dune build. Inspect how the tyxml library exposes tyxml.functor; done means the example builds without explicitly adding tyxml.functor to the libraries stanza.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.