Browse thread
partial application warning unreliable?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jacques Garrigue <garrigue@m...> |
| Subject: | Re: [Caml-list] partial application warning unreliable? |
From: skaller <skaller@users.sourceforge.net>
> method add_nonterminal (s:string) (sr:range_srcref) (toks:
> Flx_parse.token list) (term:ast_term_t) =
>
> ...
> state#add_nonterminal tok (Flx_srcref.slift sr) t;
>
> Method has 4 arguments, but the call applies to only 3.
>
> Woops, no warning!! Bad! This error of mine caused a serious
> bug -- the method call didn't do anything!
Wait a minute, is there anything after the semicolon?
The point is that a trailing semicolon at the end of a method
definition does nothing: it still returns the result of the previous
expression!
I wonder whether this behaviour is good or not, but this also means
that there is no reason to have a warning here.
If there is an expression after the semicolon, and you have no
warning, then file a bug report: the type system is supposed to detect
all partial applications in statements, except for functions whose
result is a polymorphic type variable.
By the way, your other example with classes is wrong:
# class cc = object (self)
method f x y = x + y
method g () = self#f 1;
end;;
class cc :
object method f : int -> int -> int method g : unit -> int -> int end
No warning, for the reason stated above: the semicolon does nothing.
Jacques Garrigue