Skip to content

Fix issue 19070 - some octal literals are actually allowed #3066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions spec/lex.dd
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,15 @@ $(GNAME IntegerSuffix):
$(B UL)

$(GNAME DecimalInteger):
$(B 0)
$(GLINK ZeroDigits)
$(GLINK ZeroDigits) $(GLINK OctalDigit)
$(GLINK NonZeroDigit)
$(GLINK NonZeroDigit) $(GLINK DecimalDigitsUS)

$(GNAME ZeroDigits):
$(B 0)
$(B 0) $(GSELF ZeroDigits)

$(GNAME BinaryInteger):
$(GLINK BinPrefix) $(GLINK BinaryDigitsNoSingleUS)

Expand Down Expand Up @@ -787,7 +792,8 @@ $(GNAME HexLetter):
)

$(P C-style octal integer notation was deemed too easy to mix up with decimal notation;
it is only fully supported in string literals.
it is only fully supported in string literals or when the decimal interpretation would be equivalent
(e.g. $(D 007) is accepted)
D still supports octal integer literals interpreted at compile time through the $(REF octal, std,conv)
template, as in $(D octal!167).)
$(P Hexadecimal integers are a sequence of hexadecimal digits preceded
Expand Down Expand Up @@ -861,12 +867,12 @@ $(GNAME Float):
$(GLINK HexFloat)

$(GNAME DecimalFloat):
$(GLINK LeadingDecimal) $(B .)
$(GLINK LeadingDecimal) $(B .) $(GLINK DecimalDigits)
$(GLINK DecimalDigits) $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
$(B .) $(GLINK DecimalInteger)
$(B .) $(GLINK DecimalInteger) $(GLINK DecimalExponent)
$(GLINK LeadingDecimal) $(GLINK DecimalExponent)
$(GLINK DecimalDigitsNoStartingUS) $(B .)
$(GLINK DecimalDigitsNoStartingUS) $(B .) $(GLINK DecimalDigitsNoStartingUS)
$(GLINK DecimalDigitsNoStartingUS) $(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
$(B .) $(GLINK DecimalDigitsNoStartingUS)
$(B .) $(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)
$(GLINK DecimalDigitsNoStartingUS) $(GLINK DecimalExponent)

$(GNAME DecimalExponent):
$(GLINK DecimalExponentStart) $(GLINK DecimalDigitsNoSingleUS)
Expand Down Expand Up @@ -916,10 +922,6 @@ $(GNAME RealSuffix):

$(GNAME ImaginarySuffix):
$(B i)

$(GNAME LeadingDecimal):
$(GLINK DecimalInteger)
$(B 0) $(GLINK DecimalDigitsNoSingleUS)
)

$(P Floats can be in decimal or hexadecimal format.)
Expand Down