caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* More intelligent match warnings
@ 2007-02-08 18:01 David Allsopp
  2007-02-08 18:06 ` [Caml-list] " Jon Harrop
  2007-02-08 19:08 ` Luc Maranget
  0 siblings, 2 replies; 3+ messages in thread
From: David Allsopp @ 2007-02-08 18:01 UTC (permalink / raw)
  To: OCaml List

Say I write the following rather pointless piece of code:

type t = A | B | C
let f x =
  match x with
    A -> 1
  | _ -> match x with
           B -> 2
         | C -> 3

The compiler emits Warning P for the second match because it's incomplete
over the constructors of type t. However, it's not really incomplete because
the branch cannot be hit if x = A so the warning is "sort of" incorrect. In
fact, it would also be good if one wrote:

type t = A | B | C
let f x =
  match x with
    A -> 1
  | _ -> match x with
           A -> 1 (* XX *)
         | B -> 2
         | C -> 3

to get a warning that the branch marked XX cannot be reached.

Are these two cases decidable in the general case? 


David


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-08 19:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-08 18:01 More intelligent match warnings David Allsopp
2007-02-08 18:06 ` [Caml-list] " Jon Harrop
2007-02-08 19:08 ` Luc Maranget

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).