[MLton] sequenceNonUnit
Matthew Fluet
fluet@cs.cornell.edu
Fri, 5 Aug 2005 21:33:54 -0400 (EDT)
> > it does print an error/warning for sequence expressions with
> > non-unit types that are later constrained by a signature to be unit.
> ..
> > To fix the warning, you need to put a type annotation on cleanup. I
> > think this behavior is fine, because it would be fairly difficult (I
> > believe) to distinguish the above case from one where wind was also
> > used within the structure at non-unit type.
>
> Could this be accomplished by delaying the warnings a bit? Maybe not
> a good idea because then they would be out of place with other
> messages, but, to pick an extreme, it seems like delaying the warnings
> until after elaboration is done would prevent this issue.
I don't believe that fixes the issue. For example, what warnings would
you expect from the following:
structure S1 :
sig
val f : (unit -> unit) -> unit
end =
struct
fun f thunk = (thunk (); ())
end
structure S2 :
sig
val f : (unit -> unit) -> unit
val g : (unit -> int) -> unit
end =
struct
fun f thunk = (thunk (); ())
val g = f
end
structure S3 :
sig
val f : (unit -> unit) -> unit
end =
struct
fun f thunk = (thunk (); ())
val () = f (fn () => 1)
end
Constraining a structure by a signature does not alter the principal type
of the structure, so the inferred type of the expression in a sequence
position is not altered by the signature match.