Skip to content
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

Merged
merged 3 commits into from
May 6, 2019
Merged

Accept underscore as numeric literal separator #6392

merged 3 commits into from
May 6, 2019

Conversation

Jentsch
Copy link
Contributor

@Jentsch Jentsch commented Apr 29, 2019

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 integer 0_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.

Copy link
Member

@dottybot dottybot left a 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! ☀️

@smarter
Copy link
Member

smarter commented Apr 29, 2019

I think the behaviour of Dotty is right more consistent, but I not sure how such issues should be resolved.

I'd say open an issue on https://github.com/scala/bug/ to fix the problem on the Scala 2 side.

@nicolasstucki
Copy link
Contributor

It would be good to also include tests for the literals in java underscore literals.

Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@nicolasstucki nicolasstucki self-assigned this May 1, 2019
@Jentsch
Copy link
Contributor Author

Jentsch commented May 2, 2019

It would be good to also include tests for the literals in java underscore literals.

Good idea surfaced that hex numbers with an leading underscore were allowed. Fixed in 8bdc6d0

@som-snytt
Copy link
Contributor

Could you amend the commit message not to at-mention me? It generates notifications.

@som-snytt
Copy link
Contributor

Thanks for finding the 0x_42 anomaly. Opinion on the PR so far is that we like that syntax.

Can we justify it while disallowing 3_._14? Java is inconsistent in allowing 0_755, where leading zero is also just a special prefix.

The 0_1.1 bug was due to residual effects of octal support.

scala/scala#8020

Also please don't forget to git commit --amend and unmention me. For the same reason, mentioning the ticket in the commit message is now discouraged, because it creates noisy notifications. I'm glad to have been alerted to this PR, though.

Jentsch added 3 commits May 2, 2019 19:21
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
@Jentsch
Copy link
Contributor Author

Jentsch commented May 2, 2019

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.

@nicolasstucki
Copy link
Contributor

The CI failed because we have a test that started to always timeout. We are working on fixing it.

@nicolasstucki nicolasstucki merged commit 2a6ec8e into scala:master May 6, 2019
@nicolasstucki
Copy link
Contributor

Thanks @Jentsch

@Jentsch Jentsch deleted the 6332-numeric-underscore branch May 6, 2019 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accept underscore as numeric literal separator
5 participants