From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: caml-list@inria.fr
Subject: Re: Diagnostic bug?
Date: Tue, 27 Jul 1999 17:34:51 +0200 [thread overview]
Message-ID: <199907271534.RAA15742@ithif20.inf.tu-dresden.de> (raw)
In-Reply-To: <3.0.6.32.19990722165137.00976500@mail.triode.net.au>
Hi,
as an answer to John I am just telling my heuristics to track
down type errors:
Assuming, that John started with the following program:
type t = T;;
let rec g (x) =
let (aT : t) = f x in ()
and f x = ();;
then, he gets the error
File "t.ml", line 5, characters 10-12:
This expression has type unit but is here used with type t
Now this indicates, that there is something wrong with at least
one of ``f'', ``x'', or ``()''. The error occurs, because from
previous uses of the problematic identifiers the compiler
collected type information, which in incompatible with line 5.
Therefore my strategy is to add type annotations at the first use
of the problematic identifiers, which leads to
type t = T;;
let rec g (x) =
let (aT : t) = (f : 'a -> unit) x in ()
and f x = ();;
or alternatively
type t = T;;
let rec g (x) =
let (aT : t) = (f x : unit) in ()
and f x = ();;
For both programs the compiler generates a usable error message.
John Skaller writes:
In my actual code, I got an error
in a 5000 character expression, and it took three
days to figure out the error wasn't in that expression
at all.
You are right, error reporting is one of the weak points of the
ocaml system. You can find lots of strange examples in error
reporting. My favorite one is option -i, which prints the types
of top level identifiers, if the file can be compiled. Now, in
the situtation, where the inferred types would be most valuable
--a type error in the file-- the compiler prints just nothing :-(
Bye,
Hendrik
next prev parent reply other threads:[~1999-07-30 1:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-18 18:57 optimization and purity Markus Mottl
1999-07-22 6:51 ` Diagnostic bug? John Skaller
1999-07-27 15:34 ` Hendrik Tews [this message]
1999-07-30 14:55 ` John Skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199907271534.RAA15742@ithif20.inf.tu-dresden.de \
--to=tews@tcs.inf.tu-dresden.de \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox