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
Soundness bug with non-generalized type variable and functors #7414
Original bug ID: 7414 Reporter:@lpw25 Assigned to:@garrigue Status: resolved (set by @garrigue on 2016-11-21T13:22:14Z) Resolution: fixed Priority: normal Severity: minor Version: 4.04.0 Fixed in version: 4.05.0 +dev/beta1/beta2/beta3/rc1 Category: typing Related to:#6752 Monitored by:@gasche@yallop
Bug description
The interplay between non-generalized type variables and functors seems ill defined and unsound. Using first-class modules we can get a segfault:
module type T=sigtypetvalx : tvalshow : t -> stringendmoduleInt=structtypet = intlet x =0letshowx= string_of_int x
endmoduleString=structtypet = stringlet x ="Hello"letshowx= x
endlet switch =reftruemoduleChoose()=structmoduleChoice=
(val if!switch then (moduleInt : T)
else (moduleString : T))
let r =ref (ref[])
endmodule type S=sigmoduleChoice : Tvalr : Choice.tlistrefrefendmoduleForce (X : functor () -> S) =structendmoduleM=Choose()let()= switch :=falsemoduleN=Choose()let()=N.r :=!M.r
moduleIgnore=Force(Choose)
moduleM'= (M : S)
let()= (!M'.r) := [M'.Choice.x]
moduleN'= (N : S)
let()=List.iter (funx -> print_string (N'.Choice.show x)) !(!N'.r)
I've created a pull-request #929 with a fix.
Note that the current fix is not very efficient, so I will revise it before merging,
to use an iterator rather than Subst.modtype.
Activity
vicuna commentedon Nov 19, 2016
Comment author: @garrigue
I've created a pull-request #929 with a fix.
Note that the current fix is not very efficient, so I will revise it before merging,
to use an iterator rather than Subst.modtype.
vicuna commentedon Nov 21, 2016
Comment author: @garrigue
Merged the pull request in commit 2bd2296.
Now handled by a visit of the signature rather than by Subst.