Bug 22940 – Underscore disallowed after decimal separator in floating point literals

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-26T12:26:20Z
Last change time
2023-06-26T11:35:15Z
Keywords
pull
Assigned to
No Owner
Creator
kdevel

Comments

Comment #0 by kdevel — 2022-03-26T12:26:20Z
https://dlang.org/spec/lex.html#floatliteral says: Floating literals can have embedded ‘_’ characters to improve readability, and which are ignored. This code (zzz2.d) void main () { real r = 1._0L; } when compiled with dmd 2.099 gives: $dmd zzz2 zzz2.d(3): Error: no property `_0L` for type `int` expected: Software should behave as the manual says or the other way round.
Comment #1 by moonlightsentinel — 2022-03-26T13:02:32Z
The paragraph is misleading but that behavior matches the grammar in the spec, hence marking it as an enhancement.
Comment #2 by moonlightsentinel — 2022-03-26T13:11:45Z
Changing the component to the spec because this issue most likely isn't fixable on the compiler side. `_0` is a valid identifier and hence would introduce an ambiguity for `1._0L` (is it a double literal or UFCS call `_0(1)`?)
Comment #3 by dlang-bot — 2023-06-21T13:49:07Z
@ntrel created dlang/dlang.org pull request #3642 "Lex float" fixing this issue: - Fix Issue 22940 - Underscore disallowed after decimal separator in floating point literals https://github.com/dlang/dlang.org/pull/3642
Comment #4 by dlang-bot — 2023-06-26T11:35:15Z
dlang/dlang.org pull request #3642 " [spec/lex] Improve floating point docs" was merged into master: - b1de8c3a4b46a908badbb4cb9914e27ff41dd04c by Nick Treleaven: Fix Issue 22940 - Underscore disallowed after decimal separator in floating point literals https://github.com/dlang/dlang.org/pull/3642