Bug 21418 – Cannot use ref while iterating an immutable array in ctor

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-11-23T20:45:02Z
Last change time
2024-12-13T19:12:56Z
Assigned to
No Owner
Creator
Temtaime
Moved to GitHub: dmd#19827 →

Comments

Comment #0 by temtaime — 2020-11-23T20:45:02Z
class C { this() { arr = []; foreach(ref a; arr) {} // Error: immutable field `arr` initialized multiple times } void foo() { foreach(ref a; arr) {} // no error } immutable int[] arr; } foreach in ctor should compile fine like it does in foo.
Comment #1 by robert.schadek — 2024-12-13T19:12:56Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19827 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB