You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5911 Reporter:@mmottl Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:18:27Z) Resolution: fixed Priority: normal Severity: major Version: 4.00.1 Fixed in version: 4.00.2+dev Category: typing Monitored by:@mmottl
Bug 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
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
The text was updated successfully, but these errors were encountered:
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.
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!
Original bug ID: 5911
Reporter: @mmottl
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:18:27Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 4.00.1
Fixed in version: 4.00.2+dev
Category: typing
Monitored by: @mmottl
Bug 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
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
The text was updated successfully, but these errors were encountered: