Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Why warning?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] Why warning?

SooHyoung Oh writes:
 > Why is this warning occurred?
 > Where can I get infomation about this? (ex: 'nnn' page on manual, articles
 > or books)
 > # 1; 2;;
 > Warning: this expression should have type unit.
 > - : int = 2

In  the sequence  "expr1; expr2",  the result  of expr1  is discarded.
Thus, whenever the  result of expr1 is not "()" (i.e.  expr1 is not of
type "unit") the Caml compiler gives you a warning (you may have typed
";" instead of "," for instance, or any similar typo)

This warning may be disabled, as explained in the manual:

But you should rather write your code in a different way, having expr1
of type unit, or explicitly  ignoring its result. There are (at least)
two possibilities:

   let _ = expr1 in expr2

or better

   ignore (expr1); expr2

"ignore" is part of the Caml code library; see

Best regards,
Jean-Christophe Filliatre (

Bug reports:  FAQ:
To unsubscribe, mail  Archives: