Bug 9357 – Floating-point literal should always be printed with a period in diagnostic errors
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-20T10:00:00Z
Last change time
2013-02-09T02:53:58Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2013-01-20T10:00:30Z
void main()
{
int x = 1.0;
}
Error: cannot implicitly convert expression (1) of type double to int
It should be "expression (1.0)". Opened as a separate cause of: http://d.puremagic.com/issues/show_bug.cgi?id=8807
There are likely similar issues caused by this.
Comment #1 by andrej.mitrovich — 2013-01-20T10:15:32Z
Comment #2 by bearophile_hugs — 2013-01-20T10:19:17Z
Is this enhancement request only about error messages?
This prints "1":
import std.stdio: writeln;
void main() {
double x = 1.0;
writeln(x);
}
While in Python it always prints the leading ".0":
>>> x = 1.0
>>> x
1.0
I'd like writeln() to do the same. It helps tell part FP from integral values in printouts, etc.
Comment #3 by andrej.mitrovich — 2013-01-20T10:27:24Z
(In reply to comment #2)
> Is this enhancement request only about error messages?
>
>
> This prints "1":
>
> import std.stdio: writeln;
> void main() {
> double x = 1.0;
> writeln(x);
> }
>
>
> While in Python it always prints the leading ".0":
>
> >>> x = 1.0
> >>> x
> 1.0
>
> I'd like writeln() to do the same. It helps tell part FP from integral values
> in printouts, etc.
Nice catch. Please file this as another report since it's a library issue, I'll rename the current issue so it's obvious it's a compiler issue.
Comment #4 by bearophile_hugs — 2013-01-20T15:18:40Z
(In reply to comment #3)
> Nice catch. Please file this as another report since it's a library issue, I'll
> rename the current issue so it's obvious it's a compiler issue.
I can't find the number, but I think this ER is already in bugzilla :-)
Comment #5 by andrej.mitrovich — 2013-02-08T15:14:32Z