[Issue 21856] Mutable base object returned as immutable from weakly pure function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 15 11:19:01 UTC 2024


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

--- Comment #4 from Nick Treleaven <nick at geany.org> ---
(In reply to RazvanN from comment #2)
> The safest and most restrictive solution would be to simply allow the
> conversion only if the function is strongly pure, thus disallowing the
> latter case, however, this may break code out there.

The fix for issue 15660 is related, which was changed to only disallow the
conversion with the -preview=fixImmutableConv switch:
https://dlang.org/changelog/2.101.0.html#dmd.fix-immutable-conv

That switch could be used to disallow this case too.

--


More information about the Digitalmars-d-bugs mailing list