opam-repository icon indicating copy to clipboard operation
opam-repository copied to clipboard

dolmen_type.0.5 lower bounds failure with seq

Open mseri opened this issue 3 years ago • 3 comments

Fails with

#=== ERROR while compiling dolmen_type.0.5 ====================================#
# context              2.1.2 | linux/x86_64 | ocaml-base-compiler.4.14.0 | file:///home/opam/opam-repository
# path                 ~/.opam/4.14/.opam-switch/build/dolmen_type.0.5
# command              ~/.opam/opam-init/hooks/sandbox.sh build dune build -p dolmen_type -j 31
# exit-code            1
# env-file             ~/.opam/log/dolmen_type-24-0fa409.env
# output-file          ~/.opam/log/dolmen_type-24-0fa409.out
### output ###
# (cd _build/default && /home/opam/.opam/4.14/bin/ocamlc.opt -w -40 -g -bin-annot -I src/typecheck/.dolmen_type.objs/byte -I /home/opam/.opam/4.14/lib/dolmen -I /home/opam/.opam/4.14/lib/dolmen/intf -I /home/opam/.opam/4.14/lib/dolmen/smtlib2 -I /home/opam/.opam/4.14/lib/dolmen/std -I /home/opam/.opam/4.14/lib/dolmen/tptp -I /home/opam/.opam/4.14/lib/spelll -I /home/opam/.opam/4.14/lib/uutf -intf-suffix .ml -no-alias-deps -open Dolmen_type -o src/typecheck/.dolmen_type.objs/byte/dolmen_type__Misc.cmo -c -impl src/typecheck/misc.ml)
# File "src/typecheck/misc.ml", line 241, characters 23-48:
# 241 |     match seq_to_list_ (I.retrieve ~limit:0 t s) with
#                              ^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: This expression has type 'a Seq/1.t
#        but an expression was expected of type
#          'b Stdlib.Seq.t = unit -> 'b Stdlib.Seq.node
#        Seq/1.t is abstract because no corresponding cmi file was found in path.
# (cd _build/default && /home/opam/.opam/4.14/bin/ocamlopt.opt -w -40 -g -I src/typecheck/.dolmen_type.objs/byte -I src/typecheck/.dolmen_type.objs/native -I /home/opam/.opam/4.14/lib/dolmen -I /home/opam/.opam/4.14/lib/dolmen/intf -I /home/opam/.opam/4.14/lib/dolmen/smtlib2 -I /home/opam/.opam/4.14/lib/dolmen/std -I /home/opam/.opam/4.14/lib/dolmen/tptp -I /home/opam/.opam/4.14/lib/spelll -I /home/opam/.opam/4.14/lib/uutf -intf-suffix .ml -no-alias-deps -open Dolmen_type -o src/typecheck/.dolmen_type.objs/native/dolmen_type__Misc.cmx -c -impl src/typecheck/misc.ml)
# File "src/typecheck/misc.ml", line 241, characters 23-48:
# 241 |     match seq_to_list_ (I.retrieve ~limit:0 t s) with
#                              ^^^^^^^^^^^^^^^^^^^^^^^^^
# Error: This expression has type 'a Seq/1.t
#        but an expression was expected of type
#          'b Stdlib.Seq.t = unit -> 'b Stdlib.Seq.node
#        Seq/1.t is abstract because no corresponding cmi file was found in path.

See discussion in https://github.com/ocaml/opam-repository/pull/21570#discussion_r901589037 (this is also where the issue was noticed)

mseri avatar Jun 20 '22 15:06 mseri

Is there a way to know what versions of the dependencies trigger this build failure ?

Gbury avatar Jun 20 '22 15:06 Gbury

It appeared downgrading seq from base to 0.2.2 on ocaml >= 4.12. I cannot find the old ci run due to the force push unfortunately, but you should be able to replicate by installing dolmen 0.5 on ocaml >= 4.12 and use https://github.com/ocaml/opam-repository/wiki/Lower-bound-check---DYI

mseri avatar Jun 20 '22 16:06 mseri

thanks, i'll look into that

Gbury avatar Jun 20 '22 16:06 Gbury

This issue has been open 90 days with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. If you come across this issue in the future, you may also find it helpful to visit our forum at https://discuss.ocaml.org where queries related to OCaml package management are very welcome.

github-actions[bot] avatar Sep 18 '22 16:09 github-actions[bot]

Sorry for being late on this one.

So after a bit of searching it appears that the main root of the problem is an unfortunate interaction between dune's implicit_transitive_deps and the seq compatibility package (plus a small mistake on my part of course, ^^).

Basically, the spelll package (used directly by dolmen_type) uses the seq compatibility package, and exposes some function returning a _ Seq.t which resolves the the definition of the seq package, which aliases it to _ Stdlib.Seq.t.

Now, the problem is that dolmen does not declare a dependance on seq because when reading the doc of spelll I naively assumed Seq.t referrred to the stdlib one, whereas it refers to the one from seq.

Since dolmen_type does not have seq in its dependencies, and it uses (implicit_transitive_deps false), then the cmis of seq are not visible when compiling dolmen_type and thus without the type equality between seq's Seq.t and the stdlib's, we have the type error.

The following patch fixes the build error locally:

diff --git a/dolmen_type.opam b/dolmen_type.opam
index 6ab32a1e..00e04a8f 100644
--- a/dolmen_type.opam
+++ b/dolmen_type.opam
@@ -13,6 +13,7 @@ depends: [
   "dolmen" {= version }
   "dune" { >= "2.7" }
   "spelll"
+  "seq"
   "uutf"
   "odoc" { with-doc }
 ]
diff --git a/src/typecheck/dune b/src/typecheck/dune
index 2c47267c..1dbbafe1 100644
--- a/src/typecheck/dune
+++ b/src/typecheck/dune
@@ -4,7 +4,7 @@
   (instrumentation (backend bisect_ppx))
   (libraries
     ; external deps
-    spelll uutf
+    spelll uutf seq
     ; dolmen standard deps
     dolmen dolmen.std dolmen.intf
     ; some additional explicit deps for version types

I don't know if you prefer that I create a version 0.5.1 with the patch, or if it's better to change the 0.5 release with this patch.

Gbury avatar Oct 05 '22 15:10 Gbury

The best course of action would be to simply add:

conflicts: [
  "seq" {!= "base"}
]

to dolmen_type.0.5. This is already the only way people are successfully compiling dolmen_type.0.5 so this would only enforce it.

kit-ty-kate avatar Oct 05 '22 15:10 kit-ty-kate

Ok, do you want me to make a PR for that ?

Gbury avatar Oct 05 '22 15:10 Gbury

Yes please, that would be highly welcome

kit-ty-kate avatar Oct 05 '22 17:10 kit-ty-kate