-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Accept underscore as numeric literal separator #6392
Conversation
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
I'd say open an issue on https://github.com/scala/bug/ to fix the problem on the Scala 2 side. |
It would be good to also include tests for the literals in java underscore literals. |
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.
Otherwise LGTM
Good idea surfaced that hex numbers with an leading underscore were allowed. Fixed in 8bdc6d0 |
Could you amend the commit message not to at-mention me? It generates notifications. |
Thanks for finding the Can we justify it while disallowing The Also please don't forget to |
The separator character is underscore as in Java. They may be mixed arbitrarily in a numeric literal, but only in the interior: the literal, and each part of double, must begin and end with a digit. Add spec for underscore numeric separator. This patch is a modification of a commit from som-snytt scala/scala@c359188
Sorry, just wanted to mention your patch, but not bother you. I removed the @ in the commit message. You shouldn't receive any further notifications, if I got everything right. |
The CI failed because we have a test that started to always timeout. We are working on fixing it. |
Thanks @Jentsch |
This is a port of scala/scala#6989 and should close #6332.
The syntax documentation wasn't update in the original patch, so I tried to fix it. While doing so I found a (corner?) case where Scala and Dotty with this patch behave differently: The float literal
0_1.1
fails in Scala but is OK here. The integer0_1
is OK for both Scala and Dotty. I found no case where Dotty coudn't parse a valid Scala number literal.I think the behaviour of Dotty is right more consistent, but I not sure how such issues should be resolved.