Assume that module names that are not in Env.t are persistent#2235
Conversation
|
Also: can you add your test(s) to the testsuite? |
|
Happy to write a test, however I'm not too sure how to proceed. |
Can't you produce a simplified version of what's happening on ocaml/dune#1792 ? |
|
it seems easy to write as a shell cram test. How can I write such a test with the current test infrastructure? |
|
You can launch a shell script from an ocamltest script: foo.ml: foo.sh: |
|
@damiendoligez thanks. However, the ocamlc I have access to inside the script is not the right one. It is the one accessible from the For instance, if I do |
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
The environment used to lookup global identifiers coming from loaded cmi files was incomplete, leading to identifiers that could not be resolved. This patch fixes the issue by assuming that module names that are not found in the environment are always external. Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
|
You don't really need to run a script though. |
|
How do I do that? FTR, this is my test: |
|
You do some variation of this. |
|
Sorry, I have very superficial knowledge of ocamltest and I don't really understand what test_locations.ml is doing or how to encode my test in ocamltest comments. I did the following manual testing: I tried to build dune with both trunk and this PR. It fails with trunk but passes with this PR. Do you mind if I don't add a test in the testsuite at this point? I'm happy to add a test in the future once I understand ocamltest better. |
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
|
I'd be happy to get this PR merged without a test for the moment. |
I do actually. Btw, your test is nice for the issue you're intending to fix, but I think you should also add the test of MPR#6886, since it looks like the initial version of this GPR was reintroducing that bug. |
|
The result would look less readable that the script anyway, so I'd rather make the script version work. |
|
Thanks @dra27! I updated the changelog. I definitely agree that such tests are important, though given that this is time sensitive, we might have to merge the fix without a test initially to not delay 4.08. |
This reverts commit 80a8882.
Thanks @dra27, but it's OK, I added the test. I'll add a test for MPR#6886 in a separate PR. |
|
Given the state of the history, I suggest that whoever merges this (when the CIs come back green) does a squash merge. |
|
Thanks @trefis! |
|
I merged onto trunk. I'll let someone else cherry-pick on 4.08. |
Fix bug introduced by #2041 The environment used to lookup global identifiers coming from loaded cmi files was incomplete, leading to identifiers that could not be resolved. This patch fixes the issue by assuming that module names that are not found in the environment are always external. Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
|
I cherry-picked the commit to 4.08 |
|
Thanks guys, now I can do the beta! |
When loading a
cmifile, we use a made up environment to interpret the global identifiers in this file. Additionally, since #2041 identifiers must be explicitly marked as persistent viaEnv.add_persistent_structurein order to be considered as persistent modules. This means that the made up environment must have the various global identifiers referenced in the cmi file marked as persistent.In #2041, we made the assumption that this list of global identifiers corresponded to the list of imports written in the cmi file (
Cmi_format.cmi_crcs). However, this is not true in the presence of module aliases. For instance:This is an issue as it breaks the compilation of anything using module aliases to namespace libraries.
This PR proposes to fix this issue by considering that any module that is not found at all in the environment is in fact a persistent module. This way, all global identifiers in cmi files will correctly be treated as persistent ones. It is no longer necessary to build the made up environment in
acknowledge_pers_structso I just used the empty environment instead.This patch needs to go in 4.08.