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: | -- (:) |
| From: | Jacques Garrigue <garrigue@m...> |
| Subject: | Re: [Caml-list] Why doesn't ocamlopt detect a missing ; after failwith statement? |
From: "Nicolas Cannasse" <warplayer@free.fr>
> > P.S.
> > 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.
> >
> > This could be done attempting to generalize the type of the function,
> > once we now it is a type variable.
> > I'll have a try.
>
> Wouldn't that break Obj.magic ? I can't see a clear solution to this
> problem, unless enabling arity specification into polymorphic variables :
No, because we only look at whether we are applying a function of type
(\forall 'a. 'a), while Obj.magic is of type (\forall 'a 'b. 'a -> 'b)
I've tried, and this seems to work. Actually the code is pretty short.
Objective Caml version 3.09+dev8 (2004-11-24)
# raise Exit 3;;
^
Warning X: this argument is passed to a never returning function.
There is indeed a problem with Obj.magic, but it concerns uses of the
form (Obj.magic f x), which are rather dangerous. Still, this is used
quite a bit in the distribution, and for this reason I disabled the
warning in applications of Obj.magic.
Eventhough, the changes are not so small, so the commit
will have to wait a bit.
Jacques Garrigue