Version française
Home     About     Download     Resources     Contact us    
Browse thread
Warning wished
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julien SIGNOLES <julien.signoles@c...>
Subject: Re: Re : [Caml-list] Warning wished
Le mercredi 28 janvier 2009 à 14:07 +0000, Matthieu Wipliez a écrit :
> > Hello,
> > 
> > Is it a bug or a well-known feature that the above program does not emit
> > a warning (because "f x" should have type unit in the body of "g") ?
> > 
> > =====
> > let f x = x
> > let g x = f x; 1
> > (* let _ = g 2 *)
> > ====
> 
> I'm not familiar with the internals of the compiler, but what I suppose is happening is that it tries to unify the type of "f x" and "unit", and this succeeds because "f x" has type 'a, which can be unified with anything. The meaning of "a;b" seems to be let _ = a in b rather than let () = a in b.
> 
> But like I said, these are suppositions.

Sure. However in my real case, I had an "ok" code like this :

let f x : 'a -> unit = ...
let g x =
  f x;
  x

I changed a little bit the specification of f :

let f x : 'a -> 'a = ...

I just expected that caml helps me to find all the instances where I had
to take care of this specification change. Such a thing is one of the
very good features of caml. Unfortunatly, in this case, caml did not
help me while the old implementation of "g" became wrong with the new
specification of "f" :-(.

--
Julien