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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] tpyping question
> From: skaller <skaller@ozemail.com.au>
> 
> > type x = [`A | `B of int | `V of float];;
> > let g (a:x) = a;;
> > let f a = match a with
> > | `A -> g a
> > (* | `B _ *) | _ -> g a;;
> > 
> > Compiles fine, but gives an error if the comments are
> > removed.
> 
> Indeed, there seems to be a bug here, since the non-commented version
> should be equivalent to
> 
> # let f a = match a with
>   | `A ->  g a
>   | `B _ -> g a
>   | _ -> g a;;
> val f : x -> x = <fun>

This is now fixed in CVS.
Redundant cases of or-patterns (i.e. subsumed by another case) are now
ignored in exhaustivity check.
This confirms what I said before: this was only a problem with
redundant patterns. These are completely superfluous now, as pattern
matching does not respect the order of patterns in or-patterns, but
this may indeed change in the future:
  let f = function
    | `A -> g `A
    | `B a | a -> g a
could become meaningful.

-------------------
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