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
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
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 _ = g 2 *)
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 be
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 in the body of