[Issue 1703] New: invariant(Class) does not work as expected
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 30 16:12:58 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1703
Summary: invariant(Class) does not work as expected
Product: D
Version: 2.008
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: markusle at gmail.com
Hi,
According to the docs I would have expected the following to
compile using dmd-2.008
class C
{
int x;
}
void main()
{
invariant(C) c;
c = new C; // (1) ok
}
However, dmd tells me that
test.d(9): Error: cannot implicitly convert expression (new C) of type test.C
to invariant(C)
Also, am I assuming correctly that the following should also compile?
If not, how else would one initialize the class?
class C
{
this(int x) { x_ = x; }
int x_;
}
void main()
{
invariant(C) c;
c = new C(10); // ok ??
}
Thanks,
Markus
--
More information about the Digitalmars-d-bugs
mailing list