caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "David Allsopp" <dra-news@metastack.com>
To: "OCaml List" <caml-list@yquem.inria.fr>
Subject: More intelligent match warnings
Date: Thu, 8 Feb 2007 18:01:50 -0000	[thread overview]
Message-ID: <005501c74bab$369f5150$6a7ba8c0@treble> (raw)

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


             reply	other threads:[~2007-02-08 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08 18:01 David Allsopp [this message]
2007-02-08 18:06 ` [Caml-list] " Jon Harrop
2007-02-08 19:08 ` Luc Maranget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='005501c74bab$369f5150$6a7ba8c0@treble' \
    --to=dra-news@metastack.com \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).