Version française
Home     About     Download     Resources     Contact us    
Browse thread
Why doesn't ocamlopt detect a missing ; after failwith statement?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement?
From: skaller <skaller@users.sourceforge.net>
> On Fri, 2004-11-26 at 08:14, Nicolas Cannasse wrote:
> > > All well and good, but I don't understand why it doesn't warn me about
> > > the missing ';' in the first case.
> > 
> > val failwith : string -> 'a
> > 
> > so failwith "error" prerr_endline "OK";
> > 
> > is a valid call since 'a unify with (string -> unit) -> string -> unit
> 
> .. a problem which could not occur were there a void type
> which couldn't unify with 'a, and prerr_endline had
> type string-> void.

But by definition 'a unifies with everything, including your void
type, or you get a noncommutative notion of unification...

The real problem here is the type of failwith, which is not
informative enough. Or to be more precise, it is informative enough,
but for this you must realize that 'a occurs only once, and so that
any further application is meaningless. The type checker is not that
clever (not good at detecting lone occurences.)

Jacques Garrigue