[Issue 20808] [regression] opDispatch error disappears!

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 5 18:33:52 UTC 2020


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

--- Comment #4 from Adam D. Ruppe <destructionator at gmail.com> ---
It modifies a const inside the opAssign which is why it fails. That's not
supposed to be allowed so the error should happen.

All opDispatch does is forward directly to opIndexAssign, so if opIndexAssign
doesn't compile, opDispatch shouldn't either.

You can call the assigned function by adding

    globals.printInt()(); //  be sure to use double parens thanks @property

if you take that const off the function definition, it works fine in either
case showing the assignment was successful. But the const back on and you get
error in the direct opIndexAssign and... silence on opDispatch.

You can even do

    globals.opDispatch!"printInt" = &printInt;

to get the error.

--


More information about the Digitalmars-d-bugs mailing list