opDispatch & with

John Chapman johnch_atms at hotmail.com
Fri Feb 17 19:30:02 UTC 2023


If I call opDispatch with a name that is also a type inside a 
```with``` statement, I get an error.

```d
enum Suit { clubs, spades, hearts, diamonds }

struct Card {
   void opDispatch(string s)(.Suit) {}
}

void main() {
   Card c;
   with (c) Suit = .Suit.diamonds; // Error: `Suit` is not an 
lvalue and cannot be modified
}
```

Is this a bug? It compiles without error if I call 
opDispatch!"Suit" directly.


More information about the Digitalmars-d mailing list