[MLton] cvs commit: different layout for type error messages
Stephen Weeks
sweeks@mlton.org
Tue, 25 May 2004 20:20:53 -0700
sweeks 04/05/25 20:20:52
Modified: mlton/control control.sml
Log:
MAIL different layout for type error messages
I was thinking that type error messages would be easier to read if we
didn't put the file position and error description all on the same
line. Instead, put the error description on its own line just after
the file position. So, instead of
Error: z.sml 1.9: function not of arrow type
function: [int]
in: 1 2
We would get
Error: z.sml 1.9.
Function not of arrow type.
function: [int]
in: 1 2
This isn't a great example since z.sml is such a small file name.
But, this approach has three visual advantages as I see it. First,
the error description is always in the same place, instead of having
its start being dependent on the length of the file position. Second,
the error description will be much less likely to go past 80 columns,
since it starts in column 3. Third, since one usually uses automated
tools to put the cursor at the appropriate file position, one doesn't
even usually look at the file position anyways -- this makes it easier
to jump to what you want to read.
Anyways, this checkin implements the change. Let me know what you
think.
Actually, with the extra space, I was thinking of writing out the
information on the file position, just to make it easier for beginners
(who might not use an automated tool), since I don't think it matters
for the rest of us. Something like
Error in z.sml on line 1 column 9.
Function not of arrow type.
function: [int]
in: 1 2
But I haven't checked that in yet.
Another format that I considered was the following, which redundandtly
displays "error", but is perhaps more uniform.
Error in z.sml on line 1 column 9.
error: function not of arrow type
function: [int]
in: 1 2
Revision Changes Path
1.118 +8 -3 mlton/mlton/control/control.sml
Index: control.sml
===================================================================
RCS file: /cvsroot/mlton/mlton/mlton/control/control.sml,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -r1.117 -r1.118
--- control.sml 19 May 2004 12:55:57 -0000 1.117
+++ control.sml 26 May 2004 03:20:51 -0000 1.118
@@ -745,10 +745,15 @@
case Region.left r of
NONE => "<bogus>"
| SOME p => SourcePos.toString p
+ val msg = Layout.toString msg
+ val msg =
+ Layout.str
+ (concat [String.fromChar (Char.toUpper (String.sub (msg, 0))),
+ String.dropPrefix (msg, 1),
+ "."])
in
- outputl (align [seq [str (concat [kind, ": "]),
- str p, str ": ", msg],
- indent (extra, 3)],
+ outputl (align [seq [str (concat [kind, ": "]), str p, str "."],
+ indent (align [msg, extra], 3)],
Out.error)
end
in