On Tuesday, 15 August 2023 at 17:36:13 UTC, Steven Schveighoffer
wrote:
On 8/12/23 5:55 AM, IchorDev wrote:
On Thursday, 10 August 2023 at 15:20:28 UTC, Steven
Schveighoffer wrote:
That shouldn't matter.
Well, it does here. The AA is mutated during the loop, so
perhaps this is an optimisation quirk where it works with
`for` but segfaults in `foreach`? I've pretty thoroughly
abused the `for` version and I haven't gotten it to segfault
yet.
oh yeah. That is not allowed. Any mutation of the AA during
iteration can invalidate existing foreach or ranges over the AA.
And yet this apparently doesn’t apply to an equivalent `for`
somehow. Perhaps `foreach` shouldn’t have this arbitrary problem
in the first place…
In fact, that statement is way too broad. Invalidation of
iteration should be based on the type's requirements.
We really should put a note in the AA spec page.
Probably yeah.
https://dlang.org/phobos/core_lifetime.html#.emplace
Any attribute requirements would be inferred based on the
attributes of your constructor, because emplace is a template.
-Steve
Well the docs don’t say that at all, and the code is an
unreadable mess. I dunno how anymore is meant to figure that out?