Thread overview
[Issue 19059] Invalid integer literal 08 and 09 allowed
Jul 04, 2018
ag0aep6g
Jul 04, 2018
Mike Franklin
Jul 05, 2018
Mathias LANG
Jul 05, 2018
ag0aep6g
Jul 05, 2018
Seb
Jul 05, 2018
Hiroki Noda
Jul 05, 2018
RazvanN
Jul 08, 2018
Hiroki Noda
July 04, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
Per the spec [1], `01` through `09` are all invalid since octal literals are gone. They all have obvious values, though. Which is probably why they've been kept around.

I see three ways forward:

1) Outlaw `01` through `09`. This would break existing code.

2) Let all literals that start with zero be decimals instead of octals. `01` would be 1, `08` would be 8, `000123` would be 123. This would break the rule that C code should either behave the same or fail compilation in D.

3) Allow only `01` through `09` as decimal literals. Not elegant, but it might be the best option.


[1] https://dlang.org/spec/lex.html#DecimalInteger

--
July 04, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #2 from Mike Franklin <slavo5150@yahoo.com> ---
If octal literals are gone, I vote for (2).  I don't think we should be too draconian about such C compatibility rules, especially to accommodate octals, which are even an oddity in C.

--
July 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #3 from Mathias LANG <pro.mathias.lang@gmail.com> ---
@ag0aep0g: AFAICS, solution 3 is what's currently implemented.

--
July 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

--- Comment #4 from ag0aep6g <ag0aep6g@gmail.com> ---
(In reply to Mathias LANG from comment #3)
> @ag0aep0g: AFAICS, solution 3 is what's currently implemented.

In DMD, yeah. For #3, the spec would need to be updated.

--
July 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

Seb <greeenify@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |greeenify@gmail.com

--
July 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

--- Comment #5 from Hiroki Noda <kubo39@gmail.com> ---
I am concerned about (2) and (3), is this behavior confusing with the use of
std.conv. octal?

---
assert(010 == 10); // Error: octal literals 010 are no longer supported, use
std.conv.octal!10 instead
assert(019 == 19); // Error: radix 8 digit expected, not 9
                       // Error: octal literals 021 are no longer supported,
use std.conv.octal!21 instead

--
July 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #6 from RazvanN <razvan.nitu1305@gmail.com> ---
Attemptive PR : https://github.com/dlang/dmd/pull/8451

--
July 08, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

--- Comment #7 from Hiroki Noda <kubo39@gmail.com> ---
I created another issue for invalid octal literals `01` through `07`. https://issues.dlang.org/show_bug.cgi?id=19070

--
July 12, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

--- Comment #8 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/90ab1b325f26d08bd770cd9fd44bed085c775ad9 Fix Issue 19059 - Disallow `08` and `09` in integer literal

https://github.com/dlang/dmd/commit/cdedafdd22b6eb2dd5eb550d913c851d11dd28dc Merge pull request #8451 from kubo39/disallow-invalid-octal-digital

Fix Issue 19059 - Disallow `08` and `09` in integer literal merged-on-behalf-of: Steven Schveighoffer <schveiguy@users.noreply.github.com>

--
August 24, 2018
https://issues.dlang.org/show_bug.cgi?id=19059

--- Comment #9 from Steven Schveighoffer <schveiguy@yahoo.com> ---
*** Issue 16396 has been marked as a duplicate of this issue. ***

--