[Issue 24211] Const nested function can mutate context
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 30 23:46:50 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24211
--- Comment #2 from Basile-z <b2.temp at gmx.com> ---
A bit more of analysis:
function attributes apply to the context. The fact that this works is more
related to another problem that is "function signatures are wrong"
```d
struct S
{
function f() const {}
}
```
is actually more like
```d
struct S {}
function f(const S* s){}
```
The storage class cannot be put on a parameter that dont exist, so the D
solution is to
make the hidden `this` const using trailing attributes.
That should apply to nested function too, those that captures `this`.
--
More information about the Digitalmars-d-bugs
mailing list