The pattern _ has been extended to accept any number of arguments. If you think of it

  type foo = Foo of int * bool
  let f (Foo _) = ()

is already quite strange (replacing _ by a variable here doesn't work), but extremely convenient (you don't want to have to remember the constructor's arity just to ignore it). It was extended to 0-ary constructors for consistency, but you can disable this allowance by marking warning 28 (ocamlc -warn-help) as an error.


On Thu, Oct 24, 2013 at 3:47 PM, Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote:
Hi,

Today I noticed a strange compiler's tolerance.
The compiler will not protest here:

  type foo = Bar | Baz

  ;;

  match Bar with
    | Bar _ -> ()
    | Baz -> ()

Why doesn't the compiler protest that I used wildcard after "Bar" constructor?
(It does protest if I put any other pattern except for the wildcard).

This slightly breaks the logic. Doesn't it?

--
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs