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
{{ message }}
Repository navigation
Generative functors are allowed to be applicative ! #7611
Original bug ID: 7611 Reporter: lavi Assigned to:@garrigue Status: resolved (set by @Octachron on 2017-12-13T19:52:31Z) Resolution: fixed Priority: normal Severity: minor Fixed in version: 4.07.0+dev/beta2/rc1/rc2 Category: typing Related to:#7726 Monitored by:@gasche@yallop
Bug description
in type expression, it is possible to use generative functors as applicative:
module F () = struct type t end
let f (x: F(List).t) (y: F(List).t) = x=y
Even if safe, I would expect the above program to be rejected !
I noticed this one a while ago and tried to use it to break soundness, but it appears that this bug is not sufficient to break soundness. Of course it is still a bug.
Indeed, there is no soundness problem here, since what this code says is just that "if there were values of type F(List).t, then we would be able to compare them". However, the code for generative functor does not allow to create values of this type.
A more correct statement would be "generative functors can be used as applicative constructors in type paths".
I agree that allowing to write this meaningless type is confusing, and this should be eventually rejected.
Well, you can actually create values of some of these nonsense types:
# module F () = struct
type t = T
end;;
module F : functor () -> sig type t = T end
# let x : F(List).t = T;;
Characters 20-21:
let x : F(List).t = T;;
^
Warning 40: T was selected from type F(List).t.
It is not visible in the current scope, and will not
be selected if the type becomes unknown.
val x : F(List).t = F(List).T
but I think it is still not enough to break soundness.
Activity
vicuna commentedon Aug 23, 2017
Comment author: @lpw25
I noticed this one a while ago and tried to use it to break soundness, but it appears that this bug is not sufficient to break soundness. Of course it is still a bug.
vicuna commentedon Aug 23, 2017
Comment author: @garrigue
Thanks for the report.
Indeed, there is no soundness problem here, since what this code says is just that "if there were values of type F(List).t, then we would be able to compare them". However, the code for generative functor does not allow to create values of this type.
A more correct statement would be "generative functors can be used as applicative constructors in type paths".
I agree that allowing to write this meaningless type is confusing, and this should be eventually rejected.
vicuna commentedon Aug 23, 2017
Comment author: @lpw25
Well, you can actually create values of some of these nonsense types:
but I think it is still not enough to break soundness.
vicuna commentedon Dec 13, 2017
Comment author: @Octachron
This was fixed in #1491,
now raises an error: