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
Report a missing match
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-09-10 (14:53)
From: Jean-Yves Moyen <jymoyen@e...>
Subject: Re: Report a missing match
On Thu, 9 Sep 1999, Don Syme wrote:

> It would be very helpful for me if the Caml compiler could report at least
> one missing match case when it says a match is non-exhaustive.  Is this
> feasible to implement fairly painlessly?  When working with very large
> datatypes, e.g. 100 constructors, it's very hard to know which case has been
> missed...

I think this can lead to a problem when using gards ('when' cases) in the
pattern matching.

let f=
     n when n >= 0 -> true
   | n when n < 0 -> false;;

is said to have a non exhaustive matching but the pattern matching is
actually exhaustive.

This is because it is sometimes really tricky to look into when-clauses in
order to check if there are exhaustive or not.

This is a bit more explained in the FAQ:

In your case, if your not using gards, I guess a little script may be able
to find which cases are not in the pattern matching.
(Maybe this can even be done using camlp4, I don't know)

Quand on est jeune, on croit que le monde est peuple de vieux cons.
En vieillissant, on s'appercoit qu'il est peuple de jeunes imbeciles.