[Issue 9372] New: Class member with @disabled ctor makes class ctor unusable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 22 12:00:46 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9372
Summary: Class member with @disabled ctor makes class ctor
unusable
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: hsteoh at quickfur.ath.cx
--- Comment #0 from hsteoh at quickfur.ath.cx 2013-01-22 12:00:45 PST ---
Code:
-----------SNIP-------------
import std.stdio;
struct Trouble {
@disable this();
@disable this(this);
int dummy;
this(int x) {
dummy = x;
}
}
class Room {
Trouble t;
this() {
t = Trouble(123);
}
}
void main() {
auto r = new Room; // this is line 23
}
-----------SNIP-------------
Compiler error:
-----------SNIP-------------
test.d(23): Error: default construction is disabled for type Room
-----------SNIP-------------
Commenting out the @disabled lines in Trouble makes the problem go away.
This behaviour makes no sense. The class ctor is a default ctor which calls the
Trouble ctor with non-default arguments, so it should be allowed. I can see
where this shouldn't be allowed (if Room is another struct for, example), but
since Room is a class, this should be allowed.
--
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