Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dune implicit_transitive_deps false leads to confusing errors #274

Open
ygrek opened this issue Jul 28, 2020 · 2 comments
Open

dune implicit_transitive_deps false leads to confusing errors #274

ygrek opened this issue Jul 28, 2020 · 2 comments

Comments

@ygrek
Copy link

ygrek commented Jul 28, 2020

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)

@ygrek ygrek changed the title dune implicit_transitive_deps false lead to confusing errors dune implicit_transitive_deps false leads to confusing errors Jul 28, 2020
@Drup
Copy link
Member

Drup commented Jul 29, 2020

What does this re_export command do exactly, in term of compilation object ?

I agree that the error is extremely weird, but your analysis sound plausible. At typechecking time, modules that are known to exist but have no definition become abstract, hence the lack of immediate failure.

@ygrek
Copy link
Author

ygrek commented Jul 29, 2020

ocaml/dune#2605
there is no documentation for now, but I assume it adds -I for re_export'ed deps when library is used.

slightly related ocaml/dune#2733

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

No branches or pull requests

2 participants