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

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


* Tim Chevalier:

> To make this change possible, the typechecker now forbids local
> variable names that shadow the name of a tag that's in scope.

The "." was ugly, but doesn't this make the syntatic category of the
token dependent on the contents of imported modules?  I think this is
problematic for IDEs which want to go a bit beyond lexical syntax
highlighting.

This change also breaks exhaustiveness checks to some degree.  Here's
an example:

enum enum_type {
    a, b, c
}

fn repr(e: enum_type) -> str {
    alt e {
      a { "a" }
      b { "b" }
      c { "c" }
    }
}

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.


More information about the Rust-dev mailing list