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: 6982 Reporter: @sliquister Assigned to:@garrigue Status: closed (set by @xavierleroy on 2017-02-16T14:14:59Z) Resolution: fixed Priority: normal Severity: minor Version: 4.02.2 Fixed in version: 4.03.0+dev / +beta1 Category: typing Monitored by:@gasche@hcarty
Bug description
When building the code below, I get the error:
File "std_internal.ml", line 25, characters 18-25:
Error: The type t in this module cannot be exported.
Its type contains local dependencies:
(module %M.A_S)
As you can see in the test, it only happens when I pack an alias, not if I use the module pointed to by the alias, and not if I force the alias to be expanded. Since the code types when not using an alias, I would expect it to type when using an alias.
Apparently, in Typemod.type_package, the typer rewrites (module Some_alias) into (module let %M = Some_alias in %M), and then complains that %M is free in the package type.
I think if the pattern that matches Tmod_ident also matches aliases, that would fix the problem. Perhaps using nondep_supertype somewhere would also fix it, but that sounds more heavyweight.
Steps to reproduce
Build:
module A = struct
module type A_S = sig
end
type t = (module A_S)
end
module type S = sig type t end
let f (type a) (module X : S with type t = a) = ()
let _ = f (module A) (* ok *)
module A_annotated_alias : S with type t = (module A.A_S) = A
let _ = f (module A_annotated_alias) (* ok )
let _ = f (module A_annotated_alias : S with type t = (module A.A_S)) ( ok *)
module A_alias = A
module A_alias_expanded = struct include A_alias end
let _ = f (module A_alias_expanded : S with type t = (module A.A_S)) (* ok )
let _ = f (module A_alias_expanded) ( ok *)
let _ = f (module A_alias : S with type t = (module A.A_S)) (* doesn't type )
let _ = f (module A_alias) ( doesn't type either *)
The text was updated successfully, but these errors were encountered:
Fixed in trunk at revision 16410.
Indeed, module aliases require a coercion, which made the pattern-matching fail.
While the extra example shows that this had no impact on other code paths, they are probably not equivalent in expressiveness.
Original bug ID: 6982
Reporter: @sliquister
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2017-02-16T14:14:59Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.2
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Monitored by: @gasche @hcarty
Bug description
When building the code below, I get the error:
File "std_internal.ml", line 25, characters 18-25:
Error: The type t in this module cannot be exported.
Its type contains local dependencies:
(module %M.A_S)
As you can see in the test, it only happens when I pack an alias, not if I use the module pointed to by the alias, and not if I force the alias to be expanded. Since the code types when not using an alias, I would expect it to type when using an alias.
Apparently, in Typemod.type_package, the typer rewrites (module Some_alias) into (module let %M = Some_alias in %M), and then complains that %M is free in the package type.
I think if the pattern that matches Tmod_ident also matches aliases, that would fix the problem. Perhaps using nondep_supertype somewhere would also fix it, but that sounds more heavyweight.
Steps to reproduce
Build:
module A = struct
module type A_S = sig
end
type t = (module A_S)
end
module type S = sig type t end
let f (type a) (module X : S with type t = a) = ()
let _ = f (module A) (* ok *)
module A_annotated_alias : S with type t = (module A.A_S) = A
let _ = f (module A_annotated_alias) (* ok )
let _ = f (module A_annotated_alias : S with type t = (module A.A_S)) ( ok *)
module A_alias = A
module A_alias_expanded = struct include A_alias end
let _ = f (module A_alias_expanded : S with type t = (module A.A_S)) (* ok )
let _ = f (module A_alias_expanded) ( ok *)
let _ = f (module A_alias : S with type t = (module A.A_S)) (* doesn't type )
let _ = f (module A_alias) ( doesn't type either *)
The text was updated successfully, but these errors were encountered: