← Back to index
|
Original Bugzilla link
Bug 6522 – [CTFE] Problem with opAssign call in foreach(ref)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-08-17T11:14:00Z
Last change time
2011-11-16T11:54:31Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0
by bearophile_hugs — 2011-08-17T11:14:58Z
Reduced code (Foo originally was BigInt): struct Foo { bool b = false; void opAssign(int x) { this.b = true; } } int foo() { Foo[1] array; foreach (ref item; array) item = 1; return 0; } enum r = foo(); // error void main() { // const r = foo(); // OK } DMD 2.055beta gives: test.d(9): Error: variable __key4 is used before initialization test.d(10): Error: cannot evaluate item.opAssign(1) at compile time test.d(13): Error: cannot evaluate foo() at compile time
Comment #1
by bugzilla — 2011-11-16T11:54:31Z
https://github.com/D-Programming-Language/dmd/commit/beef649d9b19ce21e75f3d496af0a67844698c41
https://github.com/D-Programming-Language/dmd/commit/469b82d4ced0f6c7efc79f3f9953da83f2f87e63