Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005037OCamlOCaml generalpublic2010-04-24 06:472010-04-30 17:23
Reporterkaustuv 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version3.12.0+dev 
Summary0005037: 3.12.0+dev18: "module type of" produces unusable signatures for repeated definitions
Description   # module type S = module type of (struct
                                       let x = 42
                                       let x = "abc"
                                     end) ;;
   module type S = sig val x : int val x : string end
   # module T : S = struct let x = "abc" end ;;
   Characters 15-39:
     module T : S = struct let x = "abc" end ;;
                    ^^^^^^^^^^^^^^^^^^^^^^^^
   Error: Signature mismatch:
          Modules do not match: sig val x : string end is not included in S
          Values do not match: val x : string is not included in val x : int

These don't work either:

   # module T : S = struct let x = 42 end ;;
   # module T : S = struct let x = 42 let x = "abc" end ;;

Since repeated module level definitions with the same name are very common, "module type of" should use the same heuristic as "sig ... end" and retain only the last one of repeated definitions.
TagsNo tags attached.
Attached Filespatch file icon signature-duplicate-filtering.patch [^] (1,307 bytes) 2010-04-26 17:48 [Show Content]

- Relationships
related to 0001441closed Inclusion d'une structure dans une signature 
related to 0004487closedgarrigue Unable to override a value in a module type with ocamlc. 
related to 0004974closed manque de verifications dans les .mli 
related to 0005061acknowledged mutiple value components in signatures should produce a warning or an error 

-  Notes
(0005373)
Julien Signoles (reporter)
2010-04-26 13:39

This issue is not specific to "module type of". See BTS entries 0001441, 0004487 and 0004974.
(0005376)
kaustuv (reporter)
2010-04-26 13:50

0001441 and 0004487 are not relevant because their error conditions are no longer reproducible:

   # module type S = sig val x : int val x : string end ;;
   module type S = sig val x : string end

That is, it appears that sig ... end now drops all but the last of duplicate definitions.

0004974 is possibly not relevant either, but there isn't enough code there for me to judge.
(0005379)
kaustuv (reporter)
2010-04-26 17:49

Attached patch against r10311 that suggests a possible fix. There is probably a better way to do it, though.
(0005397)
garrigue (manager)
2010-04-28 07:04

Just needed to call simplify_modtype on the generated signature.
Fixed for 3.12.

- Issue History
Date Modified Username Field Change
2010-04-24 06:47 kaustuv New Issue
2010-04-26 13:39 Julien Signoles Note Added: 0005373
2010-04-26 13:50 kaustuv Note Added: 0005376
2010-04-26 17:48 kaustuv File Added: signature-duplicate-filtering.patch
2010-04-26 17:49 kaustuv Note Added: 0005379
2010-04-28 07:04 garrigue Note Added: 0005397
2010-04-28 07:04 garrigue Status new => closed
2010-04-28 07:04 garrigue Resolution open => fixed
2010-04-28 07:04 garrigue Fixed in Version => 3.12.0+dev
2010-04-30 17:22 doligez Relationship added related to 0001441
2010-04-30 17:23 doligez Relationship added related to 0004487
2010-04-30 17:23 doligez Relationship added related to 0004974
2011-06-01 22:54 doligez Relationship added related to 0005061


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker