[MLton] type error messages
Matthew Fluet
fluet@cs.cornell.edu
Mon, 13 Dec 2004 22:48:09 -0500 (EST)
John came up with a few signature/structure pairs where the error message
reported could be improved.
signature t = sig
type y = int
end
structure t : t = struct
type y = char
end
Error: z.sml 5.15.
Type definition in structure disagrees with signature.
type: y
structure: [y]
signature: [int]
It would probably be more useful to print out the fact that within the
structure y is bound to char. We figured out that MLton consistently
prints a type by using the type name closest in scope with the same type.
However, in the above, it is less than illuminating. When printing out an
error about a particular type name, would it be possible to choose the
scope not including the type name?
signature s = sig
datatype y = Y
type x = y
end where type x = int
structure s : s = struct
datatype y = Y
type x = int
end
Error: y.sml 6.15.
Type y admits equality in signature but not in structure.
not equality:
Error: y.sml 6.15.
Variable type in structure disagrees with signature.
variable: Y
structure: [y]
signature: [x]
The first error is kind of misleading. It's really seems as though we
should get a type-error like the first example:
Error: y.sml 6.15.
Type definition in structure disagrees with signature.
type: y
structure: [y]
signature: [int]
Here, the y in the structure is really the datatype y, so can't be
improved in any meaningful way.
The second error is a little hard to follow, but I don't see any way to
improve it without breaking the "most recent name" convention, which seems
to be useful in other scenarios.