opDispatch & with
drug007
drug2004 at bk.ru
Fri Feb 17 20:55:03 UTC 2023
17.02.2023 22:30, John Chapman пишет:
> 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.
you are trying to assign a value `Suit.diamonds` to a type `Suit`. Could
you describe what you want to do?
More information about the Digitalmars-d
mailing list