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: Martin Jambon <martin.jambon@e...>
Subject: Re: [Caml-list] Warning wished
Julien SIGNOLES wrote:
> 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 *)
> ====

The compiler could have a command-line switch that enforces the unit type in
sequences, i.e. it would add type annotations for you:

let f x = x
let g x = (f x : unit); 1

There's a camlp4/camlp5 syntax extension that does this (but I don't use it).


Martin

-- 
http://mjambon.com/