English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
partial application warning unreliable?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-12-08 (03:10)
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
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;  
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