[rust-dev] Heads up: syntax change with nullary tags in patterns

Florian Weimer fw at deneb.enyo.de
Wed Jan 25 12:45:02 PST 2012


* Niko Matsakis:

>> We can remove the c variant from the enum_type definition, and the
>> program still compiles (even though this smells like a bug).  It keeps
>> compiling if we add a d variant to enum_type.  Flagging unused bound
>> variables as error isn't a reliable countermeasure because the
>> variant-now-variable might actually be used.
>
> This is because exhaustiveness checking is not implemented.

The last part also applies with exhaustiveness checking.  You can
reproduce this with Standard ML (which requires such checks and lacks
a lexical destinction between datacons and binders, or whatever the
technical terms are)"

datatype enum_type = a | b | c (* or: d *)

fun repr a = "a"
  | repr b  = "b"
  | repr c = "c"

Besides lexical distinction in one way or other, I'm not aware of a
solution.


More information about the Rust-dev mailing list