Skip to content
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

compilation failed on module types with duplicated values #4296

Closed
vicuna opened this issue May 24, 2007 · 3 comments
Closed

compilation failed on module types with duplicated values #4296

vicuna opened this issue May 24, 2007 · 3 comments

Comments

@vicuna
Copy link

vicuna commented May 24, 2007

Original bug ID: 4296
Reporter: prevosto
Status: closed (set by @garrigue on 2010-04-30T04:42:55Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.0
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #4136
Monitored by: prevosto ertai

Bug description

--- test.ml
module type B = sig val x: int val y: int val x: int end

ocamlc -c test.ml
The implementation test.ml does not match the interface (inferred signature):
Module type declarations do not match:
module type B = sig val x : int val y : int val x : int end
does not match
module type B = sig val x : int val y : int val x : int end
Illegal permutation of structure fields

It seems like the duplicated fields are ordered differently when producing the interface and the bytecode. module type B above is quite silly, but the same thing happens of course when the duplication comes from included modules, in which case it is not possible to simply erase one of the fields in the source, such as in the example below:

--- test2.ml
module type A = sig val x: int val y: int end
module type B = sig val x: int val z: int end
module type C = sig include A include B end

@vicuna
Copy link
Author

vicuna commented May 25, 2007

Comment author: ertai

The error message is not ideal but the problem is that your signature is not satisfiable, so you should fix it.

@vicuna
Copy link
Author

vicuna commented May 25, 2007

Comment author: prevosto

According to the compiler, the signature is perfectly satisfiable. At least in the sense that you can use it as the signature of a module implementation:

module A: sig val x: int val y: int val x:int end =
struct let x = 0 let y = 1 end

is accepted by the compiler (and of course you can remove the sig from the .ml to put it in the .mli

@vicuna
Copy link
Author

vicuna commented Apr 30, 2010

Comment author: @garrigue

Fixed together with the introduction of destructive substitution (revision 10263).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant