May 24, 2022 [Issue 23136] New: closure in a loop should hold distinct values for each iteration | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23136 Issue ID: 23136 Summary: closure in a loop should hold distinct values for each iteration Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: bugzilla@digitalmars.com Reported by Timon Gehr. This compiles even with -dip1000: ```d import std.stdio; void main()@safe{ void delegate()@safe[] dgList; foreach(i; [1, 2, 3]) { immutable b = i; dgList ~= { writeln(b); }; } foreach(dg; dgList) dg(); } ``` -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply