Browse thread
Why doesn't ocamlopt detect a missing ; after failwith statement?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2004-11-29 (00:40) |
From: | Jacques Garrigue <garrigue@m...> |
Subject: | Re: [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement? |
From: Damien Doligez <damien.doligez@inria.fr> > > I believe the problem with failwith is solvable, albeit rather > > complicated. The idea is that you want to be warned when you apply a > > function of type (\forall 'a. 'a) to something, because no such > > function may exist, so that this application will never actually take > > place. > > More generally, you want to output a warning whenever the computation > of such a value is not immediately followed by a join in the control > flow graph, because at that point you know you're compiling dead code. > > Then you would also get a warning for things like this: > > failwith "foo"; > print_string "hello world" > > or > > f (a, b, failwith "foo", c, d) > > etc. > > Don't ask me to implement it, though. This is not specially hard to implement case by case. The problem is rather that the technique I use, based on type inference, is not foolproof (you can avoid the warning with a type annotation for instance) and is wrong in presence of Obj.magic. So the question is in which cases having a warning is worth the inconvenience and the extra code in the compiler. I would say your first example is reasonable (this may be a consequence of a dangling then), but much less the second one (where is the ambiguity?) Jacques Garrigue