Bug 23284 – Enhance floating point not representable error message
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2022-08-06T22:55:49Z
Last change time
2022-08-31T10:33:33Z
Keywords
pull
Assigned to
No Owner
Creator
Richard Cattermole
Comments
Comment #0 by alphaglosined — 2022-08-06T22:55:49Z
If a floating point number is not representable in the given type (float/real) but it is using a higher precision (real/double), the error message should include the suggestion to change types and use the L suffix.
Currently:
```d
real x = 0x1p-16383; // Error: number `0x1p-16383` is not representable
```
Example output:
```d
real x = 0x1p-16383; // Error: number `0x1p-16383` is not representable using `real` but can be represented by a `double` by adding the suffix `L`.
```
Comment #1 by dlang-bot — 2022-08-07T02:10:35Z
@maxhaton created dlang/dmd pull request #14354 "Fix Issue 23284 - better floating point error messages." fixing this issue:
- Fix Issue 23284 - better floating point error messages.
There was also a bug here in that real literals did not get a suffix attached.
https://github.com/dlang/dmd/pull/14354
Comment #2 by dlang-bot — 2022-08-31T10:33:33Z
dlang/dmd pull request #14354 "Fix Issue 23284 - better floating point error messages." was merged into master:
- 858ca50831942fd59bb93a464eca4db4439ae96b by mhh:
Fix Issue 23284 - better floating point error messages.
There was also a bug here in that real literals did not get a suffix attached.
https://github.com/dlang/dmd/pull/14354