- 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
som-snytt commented Dec 7, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
sjrd commented Dec 7, 2025
They should not be written at all, in fact. ;) |
965c5f3 to 3690e96Comparesom-snytt commented Dec 7, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
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 3fe96a5Compare3fe96a5 to 9754e00Compare| caseGivenSyntaxextendsMigrationVersion(future, future) | ||
| caseImplicitParamsWithoutUsingextendsMigrationVersion(`3.7`, future) | ||
| caseScala2ImplicitsextendsMigrationVersion(future, future) | ||
| caseIdentifierDollarsextendsMigrationVersion(`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
| caseIdentifierDollarsextendsMigrationVersion(`3.8`, `3.9`) | |
| caseIdentifierDollarsextendsMigrationVersion(`3.10`, `3.11`) |
at this point?
Or can we get away with
| caseIdentifierDollarsextendsMigrationVersion(`3.8`, `3.9`) | |
| caseIdentifierDollarsextendsMigrationVersion(`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) defcheckName: 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)defcheckName: nameTree.type= | |
| defcheckName(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