Skip to content

Commit da5c565

Browse files
authored
Fix issue 19070 - some octal literals are actually allowed
1 parent d9bf60f commit da5c565

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

spec/lex.dd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,15 @@ $(GNAME IntegerSuffix):
660660
$(B UL)
661661

662662
$(GNAME DecimalInteger):
663-
$(B 0)
663+
$(GLINK ZeroDigits)
664+
$(GLINK ZeroDigits) $(GLINK OctalDigit)
664665
$(GLINK NonZeroDigit)
665666
$(GLINK NonZeroDigit) $(GLINK DecimalDigitsUS)
666667

668+
$(GNAME ZeroDigits):
669+
$(B 0)
670+
$(B 0) $(GSELF ZeroDigits)
671+
667672
$(GNAME BinaryInteger):
668673
$(GLINK BinPrefix) $(GLINK BinaryDigitsNoSingleUS)
669674

@@ -787,7 +792,8 @@ $(GNAME HexLetter):
787792
)
788793

789794
$(P C-style octal integer notation was deemed too easy to mix up with decimal notation;
790-
it is only fully supported in string literals.
795+
it is only fully supported in string literals or when the decimal interpretation would be equivalent
796+
(e.g. $(D 007) is accepted)
791797
D still supports octal integer literals interpreted at compile time through the $(REF octal, std,conv)
792798
template, as in $(D octal!167).)
793799
$(P Hexadecimal integers are a sequence of hexadecimal digits preceded

0 commit comments

Comments
 (0)