> 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
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
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
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,
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
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
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
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
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