-
Notifications
You must be signed in to change notification settings - Fork 392
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
coq: test and fix duplicate theory prefix in COQPATH bug #7790
coq: test and fix duplicate theory prefix in COQPATH bug #7790
Conversation
Good catch @Alizter ! I think indeed it should be enough to merge empty paths when building the DB. However that's a bit tricky as then the example would need to add two flags, what would happen if a user has:
and
will Coq work with |
This was caught by nixpkgs by the way. That is the only packaging which uses COQPATH IINM. |
In fact I'm not sure if Coq's semantics do require to merge even non empty paths. |
The package in question are mathcomp packages. They all get installed under mathcomp.* but in different paths for Nix. There is no problem in user-contrib however. |
I figured mathcomp would be the culprit, what I wonder is about the case:
What does Coq expect us to do here? |
That case would not be consistent since the theory would have to both be A and we would be conflicting. The only time we can have A together is if it is a prefix and in that case it will be empty. So we shouldn't really care what Coq does in that case as we would be breaking the isolated install making it unsound anyway. |
Mmm, I'm afraid that
Coq has not problem with:
However if we do add a duplicate
Then Who knows, Coq semantics are messy. That's a nice testcase actually. |
Yeah I didn't doubt that Coq would accept it, but from the perspective of keeping user-contrib sane, having overlapping theories breaks the contract we make with the user about having a valid user-contrib. In the future we can enforce all installs to be done as a COQPATH like for OCaml, since then we would have an atomic garuntee. That will also mean theories will need to be picked from packages. Solving the original issue here by merging empty theory prefixes will give some restriction on valid COQPATHs that we can defo uostream to Coq. COQPATH is rarely used in Coq nowadays so a lack of validation shouldn'g be a guiding principle for us. |
What's the contract we make? Note that the first example for example doesn't seem invalid to me, if the semantics of COQPATH are unionfs alike.
If that would work I'd be fine with it, but the "empty theory" restriction makes me afraid that it could be too restrictive in the real world. I'm wary of committing to a particular semantics when several are possible. Maybe we should clarify the semantics upstream first? Another semantics that would make sense is to actually merge all COQPATH + user-contrib in union-like way, but duplicate-free. I believe that Haskell works that way? The use case seems important, as in math-comp, a package wants to extend a namespace, so I'm not sure the empty restriction is important here, as long as there are no conflicts. |
For 3.8.1 we can indeed filter empty prefixes, but it is not clear how some other setups may work with this restriction only (thinking of compcert + floc + vst) for example. |
I suppose then rather than merging the prefix paths we should try to do as Coq does and select the first candidate. We could emit a warning when this is done. If we have theories A.B and A.C then a user could put both in a Coq path. If A happens to be nonempty then we choose A of A.B whenever a user depends on a theory A. Otherwise we should be able to merge them no problem. |
32ec08b
to
0e0a763
Compare
I've made it so that we always merge and prefer the first coq path theory. |
Thanks @Alizter for the patch, it looks good to me; we could maybe improve the test cases to capture some other conflict in COQPATH, as a way of documentation, but I let you decide on that. |
By the way we should encourage dune users to contribute to inspect and contribute to the dune test suite so their use cases are fully covered. |
So one thing that this does change is the detection of duplicate theories that we had before. I suppose for now this is the best we can do if we want to keep as faithful as possible to Coq semantics, but I worry for our users who might have a silent overload of a theory. |
This bug happens when using COQPATH so it won't affect most users. When having two theories A.B and A.C installed, dune will erroneously fail saying that the theory A has been defined twice. Signed-off-by: Ali Caglayan <alizter@gmail.com>
Signed-off-by: Ali Caglayan <alizter@gmail.com>
0e0a763
to
7cc014a
Compare
I won't write any more tests for this since we plan to write a whole bunch of tests soon anyway. #7598 |
* test(coq): duplicate theory prefix in COQPATH bug This bug happens when using COQPATH so it won't affect most users. When having two theories A.B and A.C installed, dune will erroneously fail saying that the theory A has been defined twice. Signed-off-by: Ali Caglayan <alizter@gmail.com> Signed-off-by: Etienne Millon <me@emillon.org> * fix(coq): first theory in COQPATH takes precedence always Signed-off-by: Ali Caglayan <alizter@gmail.com> Signed-off-by: Etienne Millon <me@emillon.org> * coq: add missing changelog entry Signed-off-by: Ali Caglayan <alizter@gmail.com> Signed-off-by: Etienne Millon <me@emillon.org> --------- Signed-off-by: Ali Caglayan <alizter@gmail.com> Signed-off-by: Etienne Millon <me@emillon.org> Co-authored-by: Ali Caglayan <alizter@gmail.com>
CHANGES: - Fix a crash when using a version of Coq < 8.13 due to the native compiler config variable being missing. We now explicitly default to `(mode vo)` for these older versions of Coq. (ocaml/dune#7847, fixes ocaml/dune#7846, @Alizter) - Duplicate installed Coq theories are now allowed with the first appearing in COQPATH being preferred. This is inline with Coq's loadpath semantics. This fixes an issue with install layouts based on COQPATH such as those found in nixpkgs. (ocaml/dune#7790, @Alizter) - Revert ocaml/dune#7415 and ocaml/dune#7450 (Resolve `ppx_runtime_libraries` in the target context when cross compiling) (ocaml/dune#7887, fixes ocaml/dune#7875, @emillon)
This bug happens when using COQPATH so it won't affect most users. When having two theories A.B and A.C installed, dune will erroneously fail saying that the theory A has been defined twice.
I think the correct fix would be to merge the maps in the case where A has no immediate .vo files and is just a prefix.