From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA14011; Mon, 9 Sep 2002 23:26:22 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA14113 for ; Mon, 9 Sep 2002 23:26:21 +0200 (MET DST) Received: from leia.mandrakesoft.com (office.mandrakesoft.com [195.68.114.34]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g89LQL101423 for ; Mon, 9 Sep 2002 23:26:21 +0200 (MET DST) Received: by leia.mandrakesoft.com (Postfix, from userid 505) id 7853B3EFE; Mon, 9 Sep 2002 23:24:09 +0200 (CEST) To: caml-list@inria.fr Subject: [Caml-list] Re: unused variables warning In-Reply-To: <20010428095737.206C55722@leia.mandrakesoft.com> References: <20010428095737.206C55722@leia.mandrakesoft.com> From: Pixel Date: 09 Sep 2002 23:24:09 +0200 Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I've asked the following question one year ago: > Is there any way to ask ocamlc for an "unused variable" warning? > > let f x = > let x' = <...> in > x > > would issue something like > > File "test.ml", line 2, characters 3-18: > Unused variable x' I got an answer from Pascal Brisset sending me a nice incomplete piece of code doing this. After a small adaptation, I've been using it with 3.04. When "updating" it to 3.06, i tried to integrate in mandrake's package to ease my use of it: - i've added it when all warnings are enabled (-w A) - it's quite ugly, i've added the various things to make it compile on 3.06 without knowing what should be done. At least it somewhat works :) - i've dropped a functionality from Pascal Brisset's tool: it only checks local variables, not modules variables&functions. It was easier for me and does the checks I need (since my .mli are mostly auto-generated). - the comments from Pascal Brisset still apply - it is uncomplete (it does not handle local modules ...) - warning are not issued for identifiers starting with an underscore. So if it interests someone :) The patch on ocaml 3.06: http://people.mandrakesoft.com/~prigaux/ocaml-3.06-add-warning-for-unused-local-variables.patch The tool on ocaml 3.04: http://people.mandrakesoft.com/~prigaux/warn_unused.make http://people.mandrakesoft.com/~prigaux/warn_unused.ml (special thanks to Pascal Brisset of course) ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners