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
Extraction inside a module #10739
Comments
Wow, thanks for the reduced test case! Maybe @pi8027 could be interested in this. |
The |
Not that I want to play Cassandra, but asking to be able to extract definitions in the middle of a module does look like giving a stick to get beaten with... |
I'm actually not asking for that feature. I think it would be okay to disallow it, and display a clear error instead of the current warning saying that extraction in a module is "experimental". The point is to clarify what should and what shouldn't be expected to work, as here are people who are unsure about the status of things unless they take the time to dig into it. |
What? Why? Extraction should absolutely work in the middle of a module (though feel free to disallow it in the middle of |
In the context of QuickChick, I can imagine you sometimes want to run a test (which uses extraction) while writing a module. TBH, I don't see why it would be difficult to support (especially if we forbid it in functors, like @JasonGross says). What risk do you have in mind? |
My main concern are functors indeed, although you can still get suspicious behaviours when extracting a module that is supposed to be sealed by a signature. What is the expected semantics of this, or more generally extraction inside a module? |
The semantics are the same as if you extract something at top-level in the middle of a file (which I model as just a module). I would be fine if extraction errored inside a sealed module, though I think the better thing is to probably just ignore the sealing while inside the module. |
I'd like to share the results of my investigation. Monolithic extraction tries to dump all the definitions in the current toplevel here: coq/plugins/extraction/extract_env.ml Line 59 in 02d9b43
In @Lysxia's example, toplevel_env () is the contents of Top but Lib.current_mp () is Top.M (which indeed must be Top ), then extract_structure uses that incorrect module name to reconstruct fully qualified names by make_cst :coq/plugins/extraction/extract_env.ml Lines 305 to 318 in 02d9b43
So the reconstructed name of |
This issue may have been introduced in f6d8fc1. We may need to check other uses of |
Since I checked how the extraction bypasses opaqueness of modules, here, I strongly agree with @ppedrot. But leaving extraction in modules as an experimental function and trying to fix it would also be fine. |
Another example of the anomaly, this time with Require Extraction.
Definition a:=0.
Module M.
Definition b:=a.
Recursive Extraction b. @pi8027: I worked from your line 59 above and added a kernel function that "flattens" the environment, i.e. that adds the necessary amount of |
(cherry picked from commit ad49766)
Description of the problem
The following snippet, with a definition at the toplevel, then a
Recursive Extraction
command inside a module, extracts to literally nothing:Related to #9365 which was redirected to QuickChick, but I've minimized the example to that, which is no longer within QuickChick's jurisdiction.
Coq Version
tested on 8.9 and 8.10+alpha (Aug 18 2019)
The text was updated successfully, but these errors were encountered: