Re : [Caml-list] Warning wished

2009-01-28 Thread Matthieu Wipliez
> 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 suppo

Re: [Caml-list] Warning wished

2009-01-28 Thread Dmitri Boulytchev
Hello Julien, no warning should be issued in this case since you have polymorphic function: applying g to () you will definitely have f x of type unit :) Try another one: let f x = x+1 let g x = f x; 1 Now you'll get the warning since the compiler can ensure that type of f

Re: [Caml-list] Warning wished

2009-01-28 Thread Julien SIGNOLES
Hello Dmitri, > no warning should be issued in this case since you have polymorphic > function: > applying g to () you will definitely have f x of type unit :) Applying g to 1 you will definitely have f x of type int and you have to take care of the returned integer. Unfortunatly caml emits

Re: [Caml-list] Warning wished

2009-01-28 Thread Dmitri Boulytchev
Applying g to 1 you will definitely have f x of type int and you have to take care of the returned integer. Unfortunatly caml emits no warning in this case (even if I understand why) :(. Sure :) But as far as I understand this warning means "this non-unit value will definitely be omitted,

Re: [Caml-list] Warning wished

2009-01-28 Thread Martin Jambon
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

Re: [Caml-list] Warning wished

2009-01-28 Thread Frédéric van der Plancke
Dmitri Boulytchev wrote: Applying g to 1 you will definitely have f x of type int and you have to take care of the returned integer. Unfortunatly caml emits no warning in this case (even if I understand why) :(. Sure :) But as far as I understand this warning means "this non-unit value w

Re: [Caml-list] Warning wished

2009-01-28 Thread Dmitri Boulytchev
There's the question of what the compiler _does_, what the compiler _could_ do and what the compiler _should_ do. The latter is mainly a matter of taste :) I don't think "this 'a could be unit" is a good reason for skipping the warning. On the contrary, "this 'a will probably sometimes b

Re: Re : [Caml-list] Warning wished

2009-01-28 Thread Julien SIGNOLES
Le mercredi 28 janvier 2009 à 14:07 +, 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

Re: Re : [Caml-list] Warning wished

2009-01-28 Thread Nicolas Pouillard
Excerpts from Julien SIGNOLES's message of Wed Jan 28 15:24:14 +0100 2009: > Le mercredi 28 janvier 2009 à 14:07 +, 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