Datatype (and co-datatype) constructors in Dafny have parentheses around their arguments, both in declarations of the constructors and in their uses. However, for nullary constructors, the parentheses are optional. Currently, nullary constructor are indeed allowed to have parentheses in nested `case`s. However, if the constructor is mentioned at the top level of a `case`, the Dafny parser complains.
```
datatype List = Nil | Cons(int, List)
method R(xs: List)
{
match xs
case Nil() => // currently produces a parsing error, but shouldn't
case Cons(x, Nil()) => // currently allowed
case Cons(x, Cons(y, tail)) =>
}
```
gives
```
test.dfy(30,11): Error: invalid CasePattern
```
The same problem occurs in both `match` statements and `match` expressions.
Rustan
```
datatype List = Nil | Cons(int, List)
method R(xs: List)
{
match xs
case Nil() => // currently produces a parsing error, but shouldn't
case Cons(x, Nil()) => // currently allowed
case Cons(x, Cons(y, tail)) =>
}
```
gives
```
test.dfy(30,11): Error: invalid CasePattern
```
The same problem occurs in both `match` statements and `match` expressions.
Rustan