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
Unable to override a value in a module type with ocamlc. #4487
Comments
Comment author: @garrigue Fixed by only keeping the last declaration in signatures. |
Comment author: ertai This issue is not completely resolved, the fix seems to work only on the first duplicate. $ cat bug.ml $ ocamlc -c bug.ml |
Comment author: @garrigue The problem did exist in an intermediate fix, but it is already corrected in 3.12. |
Comment author: ertai Sorry I made a mistake when reducing the bug (from around ~14000 lines of code), here is the new input: $ cat bug.ml $ ocamlc -c bug.ml This is the same output in 3.12, and today's trunk version. |
Comment author: @garrigue Sorry for the confusion: this problem is completely fixed only in the |
Original bug ID: 4487
Reporter: jm
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2012-03-24T14:01:41Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10+dev
Fixed in version: 3.12.1+dev
Category: ~DO NOT USE (was: OCaml general)
Duplicate of: #5164
Related to: #5037 #5061
Monitored by: "Julien Signoles"
Bug description
% ocamlc -v
The Objective Caml compiler, version 3.10.2+dev2 (2008-01-22)
Standard library directory: /usr/local/lib/ocaml
In a module where two values have the same name and type,
ocamlc does not complain if the related signature has two entries:
% cat m.ml
module M
: sig val x : int
val x : int end
= struct let x = 0
let x = 42 end;;
print_endline (string_of_int M.x)
% ocamlc -i m.ml
module M : sig val x : int end
% ocamlc -c m.ml
% ocaml m.ml
42
But if the signature is inside a module type,
ocamlc does complain:
% cat t.ml
module type T
= sig val x : int
val x : int end
module M
: T
= struct let x = 0
let x = 42 end;;
print_endline (string_of_int M.x)
% ocamlc -i t.ml
module type T = sig val x : int val x : int end
module M : T
% ocamlc -c t.ml
The implementation t.ml does not match the interface (inferred signature):
Module type declarations do not match:
module type T = sig val x : int val x : int end
does not match
module type T = sig val x : int val x : int end
Illegal permutation of structure fields
2% ocaml t.ml
42
I would have expected ocamlc to accept a redundant value in a module type,
as ocaml does. Also, note that I'm not posting this report for the sake of hair splitting, but in order to bring into awareness a real-life issue I've encountered while dealing with module type inclusions.
Thanks for considering.
Additional information
Currently I'm somehow avoiding my real-life problem with Piotr Wieczorek's sigops.patch at:
http://rainbow.mimuw.edu.pl/~pw189451/ocaml/
The text was updated successfully, but these errors were encountered: