[Issue 18866] Overload from opDispatch ignored in WithStatement

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 17 21:00:46 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=18866

Paul Backus <snarwin+bugzilla at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla at gmail.com

--- Comment #8 from Paul Backus <snarwin+bugzilla at gmail.com> ---
Another example, from the forums:

---
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
}
---

It doesn't seem to matter whether the existing symbol is a function, a type, a
variable, or anything else; or whether it's declared at module scope or
locally. As long as any symbol with the requested name exists in any enclosing
scope, the with statement will not call opDispatch.

--


More information about the Digitalmars-d-bugs mailing list