Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] unused variables warning
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pixel <pixel@m...>
Subject: [Caml-list] Re: unused variables warning
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