-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Fix issue 22882 - Floating-point literals with leading zeroes incorrectly throw octal errors #13827
Conversation
This is a simple fix to issue #22882, though I'm sure something cleaner could be done.
|
Thanks for your pull request and interest in making D better, @aposteriorist! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#13827" |
|
This needs a test to prevent any future regression. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing tests.
|
Thanks for the bugfix! As mentioned, this needs to be added to the test suite. Take the number literals from the bugzilla issue, and use them in the file float x = 08.0;
static assert(00077777.0 == 77777.0); |
|
Actually, I was mistaken. Floating-point literals with leading zeroes work as they should, completely corrected as of 2.098.1. I was testing from a lower version. This change is unnecessary and the pull request should be closed. Since we're here, |
It's not uncommon to have related positive and negative test cases in a single file in fail_compilation. There's no strict guideline on where to place test cases, it's usually judged on an individual basis based on properties like:
|
Fixes issue #22882.
Floating-point literals with leading zeroes incorrectly throw an octal digit error, as follows:
writeln(07.0);// 7writeln(08.0);// Error: octal digit expected, not8writeln(010.9);// 10.9writeln(018.9);// Error: octal digit expected, not8writeln(00077777.0);// 77777writeln(00077778.0);// Error: octal digit expected, not8The error is in lexer.d; errorDigit is set in number() in the initial switch statement, but when a '.' is subsequently handled later in the function, the error state is never unset.
The fix checks for
base == 8within the'.'case of the appropriate switch, and if true, unsetserrorDigitand setsbaseto10, as we are now working with a decimal float literal.