[Issue 2701] New: Can't declare struct, assign lvalue to it in same statement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 1 17:34:41 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2701
Summary: Can't declare struct, assign lvalue to it in same
statement
Product: D
Version: 2.025
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: rejects-valid, spec
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: dsimcha at yahoo.com
struct Bar {
uint num;
Bar opAssign(uint otherNum) {
num = otherNum;
return this;
}
}
void main() {
uint foo = 1;
Bar bar = foo; // Error: e2ir: cannot cast from uint to Bar.
Bar bar2;
bar2 = foo; // Works.
}
Not sure if this is actually a valid bug, since the spec states that "The
assignment operator cannot be overloaded for rvalues that can be implicitly
cast to the lvalue type." However, if the previous sentence does implicitly
disallow this from working, it should be stated more clearly, instead of in a
single sentence of language legalese.
--
More information about the Digitalmars-d-bugs
mailing list