-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Dollars in idents #24690
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
base: main
Are you sure you want to change the base?
Dollars in idents #24690
Conversation
They should not be written at all, in fact. ;) |
965c5f3 to
3690e96
Compare
|
This proposal aims to accommodate the two views, which are not entirely incompatible, that strict enforcement is required and yet Java doesn't need it so why does Scala?, where the question is posed with a large dosage of skepticism about warnings. Here, there is no forking compiler option. Definitions with suspect names are disallowed, with a migration warning now and an error later. However, the workaround, to permit the identifier in backquotes, is quite natural and pleasant, as we have all come to savor backquotes in new syntactic contexts. Backquotes are not required for references (usages). CB A |
3690e96 to
3fe96a5
Compare
3fe96a5 to
9754e00
Compare
| case GivenSyntax extends MigrationVersion(future, future) | ||
| case ImplicitParamsWithoutUsing extends MigrationVersion(`3.7`, future) | ||
| case Scala2Implicits extends MigrationVersion(future, future) | ||
| case IdentifierDollars extends MigrationVersion(`3.8`, `3.9`) |
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.
@Gedochao What's the warning policy for the feature freeze?
Should this be
| case IdentifierDollars extends MigrationVersion(`3.8`, `3.9`) | |
| case IdentifierDollars extends MigrationVersion(`3.10`, `3.11`) |
at this point?
Or can we get away with
| case IdentifierDollars extends MigrationVersion(`3.8`, `3.9`) | |
| case IdentifierDollars extends MigrationVersion(`3.8`, `3.10`) |
even though the warning would then be introduced in a patch version?
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.
my gut says the former (3.10, 3.11), but I probably could be convinced otherwise.
We haven't had a precedent for this, I guess.
let's discuss it on today's Scala Core.
| if checkable && name.toSimpleName.contains('$') then | ||
| report.errorOrMigrationWarning(IllegalIdentifier(name), start, MigrationVersion.IdentifierDollars) | ||
|
|
||
| extension (nameTree: NameTree) def checkName: nameTree.type = |
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.
Sometimes this method is called as a function, sometimes as an extension. That's confusing. Given that you sometimes need it just for the side effect, consider standardizing on the function variant:
| extension (nameTree: NameTree) def checkName: nameTree.type = | |
| def checkName(nameTree: NameTree): nameTree.type = |
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.
I will consider it. This was my first opportunity to use an extension "both ways", which I think is a feature of extensions.
Warns on definitions named with embedded dollars, which
shouldmust be written in backquotes, if at all.Fixes #18234
Test from #18563