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
module extraction sometimes incorrectly prefixes record fields with generated file-module names #3846
Comments
Comment author: @JasonGross This occurs in both 8.4 and trunk: $ cat A.v Record aR := { aF : nat ; another : nat }. $ cat B.v Require Import A.
Module Bar.
Definition foo (x : aR) := x.(aF).
End Bar.
Module Application.
Include A.
Include Bar.
End Application.
Extraction "B" Application. $ coq_makefile -R . Top A.v B.v B.ml B.mli | make -f - all COQSRCLIBS= $ cat B.ml type nat =
| O
| S of nat
module Coq__1 = struct
type aR = { aF : nat; another : nat }
end
type aR = Coq__1.aR = { aF : nat; another : nat }
module Coq__2 = struct
(** val aF : aR -> nat **)
let aF x = x.aF
end
let aF = Coq__2.aF
module Application =
struct
type aR = Coq__1.aR = { aF : nat; another : nat }
(** val aF : aR -> nat **)
let aF a =
a.aF
(** val another : aR -> nat **)
let another a =
a.another
(** val foo : Coq__1.aR -> nat **)
let foo x =
x.Coq__2.aF
end From what I can tell, Coq decides to wrap top-level file-modules in their own generate modules when they are later [Include]d (why does Coq do this?). It incorrectly decides to prefix record field names with the name of the generated module when they are later used. |
…eld names. Fixes coq#3846 Fixes coq#14843 Fixes coq#16677 Fixes coq#12813 When dealing with collisions by means of encapsulation in a Coq_XX module, a field name should be bound to the name of the corresponding inductive type declaration. We use Table.repr_of_r to do that, but early enough to have the relevant information on how to bind a field to the name of the inductive that declares it. (In particular, we cannot rely on the global tables in structures.ml because they are not valid when inside a functor, see coq#17321.) Note that Haskell and Scheme do not use records and it is ok on their side.
Fixed in #17324. |
…eld names. Fixes coq#3846 Fixes coq#14843 Fixes coq#16677 Fixes coq#12813 When dealing with collisions by means of encapsulation in a Coq_XX module, a field name should be bound to the name of the corresponding inductive type declaration. We use Table.repr_of_r to do that, but early enough to have the relevant information on how to bind a field to the name of the inductive that declares it. (In particular, we cannot rely on the global tables in structures.ml because they are not valid when inside a functor, see coq#17321.) Note that Haskell and Scheme do not use records and it is ok on their side. (cherry picked from commit c19b2cd)
Note: the issue was created automatically with bugzilla2github tool
Original bug ID: BZ#3846
From: @JasonGross
Reported version: 8.4
CC: coq-bugs-redist@lists.gforge.inria.fr
The text was updated successfully, but these errors were encountered: