[Issue 6522] New: [CTFE] Problem with opAssign call in foreach(ref)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 17 11:15:00 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6522
Summary: [CTFE] Problem with opAssign call in foreach(ref)
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-08-17 11:14:58 PDT ---
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
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list