Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005911OCamlOCaml typingpublic2013-01-28 23:502013-01-29 02:50
Reportermottl 
Assigned Togarrigue 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version4.00.2+dev 
Summary0005911: Signature substitutions fail in submodules
DescriptionThe following code snippet shows signatures "S" and "T" and two functors "Good" and "Bad":

The functor "Good" substitutes a type in its argument of signature "S" and then accesses a value having this type, proving that the substitution has worked.

The functor "Bad" uses an argument of signature "T", which merely contains a submodule of signature "S", performing the exact same substitution otherwise. This time the substitution fails. Running "ocaml" on this snippet yields:

  File "bug.ml", line 13, characters 11-16:
  Error: This expression has type t but an expression was expected of type unit

Here is the snippet:

----------
module type S = sig
  type t
  val x : t
end

module Good (X : S with type t := unit) = struct
  let () = X.x
end

module type T = sig module M : S end

module Bad (X : T with type M.t := unit) = struct
  let () = X.M.x
end
----------
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0008813)
garrigue (manager)
2013-01-29 02:24

Actually this is not supposed to work: if you look at the manual, this substitution is only defined for toplevel identifiers. Otherwise, doing a valid substitution gets much more complicated.
The problem was just that the parser accepted long identifiers, but the corresponding substitutions were just ignored.
So the solution is just to fix the parser so that it only accept single identifiers.

Fixed in trunk and 4.00 in revisions 13282 and 13283.
(0008814)
mottl (reporter)
2013-01-29 02:50

Indeed, reading the manual sometimes helps :-)

The error message was quite misleading, especially in contexts with many nested modules and type "t"s. It wasn't clear at first whether I was even referring to the right module. Fixing this at the parser level will surely greatly help. Thanks for the fast fix!

- Issue History
Date Modified Username Field Change
2013-01-28 23:50 mottl New Issue
2013-01-29 02:24 garrigue Note Added: 0008813
2013-01-29 02:24 garrigue Status new => resolved
2013-01-29 02:24 garrigue Fixed in Version => 4.00.2+dev
2013-01-29 02:24 garrigue Resolution open => fixed
2013-01-29 02:24 garrigue Assigned To => garrigue
2013-01-29 02:50 mottl Note Added: 0008814


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker