Bug 6006 – Complex numbers initialized with 0

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-15T07:37:00Z
Last change time
2011-05-15T09:33:08Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-05-15T07:37:27Z
Just like float/double/real variables can be initialized with just a "0", I suggest to allow cdoubles/cfloats/creals too to be initialized with just a "0" (that equals to 0+0i): void main() { double d = 0; // OK cdouble c1 = 0+0i; // OK cdouble c2 = 0; // error } DMD 2.053 gives the error: test.d(4): Error: cannot implicitly convert expression (0) of type int to cdouble This is useful for generic code.
Comment #1 by kennytm — 2011-05-15T09:33:08Z
*** This issue has been marked as a duplicate of issue 692 ***