Bug 13281 – Print type suffix of real/complex literals in pragma(msg) and error diagnostic
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-11T08:37:00Z
Last change time
2014-08-11T12:28:34Z
Keywords
diagnostic, pull
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2014-08-11T08:37:37Z
Compiler prints type suffix of integer literals in pramga(msg) and error diagnostic.
pragma(msg, 123); // print 123
pragma(msg, 123u); // print 123u
pragma(msg, 123L); // print 123L
pragma(msg, 123uL); // print 123LU
// Error: cannot implicitly convert expression ...
string x1 = 123; // ... (123) of type int to string
string x2 = 123u; // ... (123u) of type uint to string
string x3 = 123L; // ... (123L) of type long to string
string x4 = 123uL; // ... (123LU) of type ulong to string
But, it doesn't for real/complex values.
pragma(msg, 123.4f); // print 123.4
pragma(msg, 123.4); // print 123.4
pragma(msg, 123.4L); // print 123.4
pragma(msg, 123.4fi); // print 123.4i
pragma(msg, 123.4i); // print 123.4i
pragma(msg, 123.4Li); // print 123.4i
pragma(msg, 123.4f+5.6fi); // print (123.4+5.6i)
pragma(msg, 123.4 +5.6i); // print (123.4+5.6i)
pragma(msg, 123.4L+5.6Li); // print (123.4+5.6i)
// Error: cannot implicitly convert expression ...
int x1 = 123.4f; // ... (123.4) of type float to int
int x2 = 123.4; // ... (123.4) of type double to int
int x3 = 123.4L; // ... (123.4) of type real to int
int x4 = 123.4fi; // ... (123.4i) of type ifloat to int
int x5 = 123.4i; // ... (123.4i) of type idouble to int
int x6 = 123.4Li; // ... (123.4i) of type ireal to int
int x7 = 123.4f+5.6fi; // ... ((123.4+5.6i)) of type cfloat to int
int x8 = 123.4 +5.6i; // ... ((123.4+5.6i)) of type cdouble to int
int x9 = 123.4L+5.6Li; // ... ((123.4+5.6i)) of type creal to int
I think compiler should print type suffix in all cases, because of consistency.