[Issue 9149] Disallow calling const delegates with a mutable context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 11 22:30:48 UTC 2024


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

--- Comment #16 from timon.gehr at gmx.ch ---
(In reply to timon.gehr from comment #11)
> 
> The fix I originally proposed in the first post removes the unsoundness in
> the const system, but it is ugly. It means the line "const x = y;" fails if
> y is a delegate, but not if y is an instance of a struct wrapping a
> delegate. A more elegant solution would be to disallow calling const
> delegates whose context is not typed const or immutable. I.e. const(int
> delegate()const) can be called, but const(int delegate()) cannot be called.
> 
> Basically the same problem exists for immutable.

I updated the title to reflect this more elegant solution.

--


More information about the Digitalmars-d-bugs mailing list