Skip to content
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

Signature substitutions fail in submodules #5911

Closed
vicuna opened this Issue Jan 28, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Jan 28, 2013

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jan 29, 2013

Comment author: @garrigue

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jan 29, 2013

Comment author: @mmottl

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!

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added the typing label Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.