|Anonymous | Login | Signup for a new account||2018-01-17 12:27 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005911||OCaml||typing||public||2013-01-28 23:50||2015-12-11 19:18|
|Target Version||Fixed in Version||4.00.2+dev|
|Summary||0005911: Signature substitutions fail in submodules|
|Description||The 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
val x : t
module Good (X : S with type t := unit) = struct
let () = X.x
module type T = sig module M : S end
module Bad (X : T with type M.t := unit) = struct
let () = X.M.x
|Tags||No tags attached.|
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.
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!
|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|
|2015-12-11 19:18||xleroy||Status||resolved => closed|
|2017-02-23 16:45||doligez||Category||OCaml typing => typing|
|Copyright © 2000 - 2011 MantisBT Group|