Skip to content

[Lex] Reject standalone dollars as identifiers #3901

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

Merged
merged 3 commits into from
Aug 9, 2016

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Aug 1, 2016

What's in this pull request?

Fixes a case where we accidentally accepted a single dollar as an identifier. This patch supersedes #3004.

Resolved bug number: (SR-1661)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

A smoke test on macOS does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library only for macOS. Simulator standard libraries and
    device standard libraries are not built.
  3. lldb is not built.
  4. The test and validation-test targets are run only for macOS. The optimized
    version of these tests are not run.

A smoke test on Linux does the following:

  1. Builds the compiler incrementally.
  2. Builds the standard library incrementally.
  3. lldb is built incrementally.
  4. The swift test and validation-test targets are run. The optimized version of these
    tests are not run.
  5. lldb is tested.

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2016

@swift-ci please smoke test.

@CodaFi CodaFi force-pushed the dolla-dolla-bills-yall branch from 5dd16b6 to 389f779 Compare August 1, 2016 02:28
@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2016

@swift-ci please smoke test.

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 1, 2016

@swift-ci please smoke test Linux platform.

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 6, 2016

Let's see if we can't get Linux green again?

@swift-ci please smoke test Linux platform.

@CodaFi
Copy link
Contributor Author

CodaFi commented Aug 8, 2016

I want to land this clean

@swift-ci please smoke test Linux platform.

@CodaFi CodaFi merged commit ad8bd43 into swiftlang:master Aug 9, 2016
@CodaFi CodaFi deleted the dolla-dolla-bills-yall branch August 9, 2016 08:28
@jtbandes
Copy link
Contributor

Should this be included in the Swift 3 branch? cc @tkremenek

@lattner
Copy link
Contributor

lattner commented Oct 12, 2016

This is source breaking, right?

@lattner
Copy link
Contributor

lattner commented Oct 12, 2016

Source breaking changes should wait until we have a framework to support them. Also, $ is commonly used by dollar.swift, so I'd suggest a targeted fixme that rewrites the $ to a valid identifier, e.g. "💲" (yes, I'm serious). This will allow the migrator Swift 3->4 migrator to handle the framework.

@jtbandes
Copy link
Contributor

Related proposal that's been waiting for a long time to be merged/closed: swiftlang/swift-evolution#354

@jtbandes
Copy link
Contributor

(I'm working with others on a proposal to refine the operator/identifier characters — there's been some interest in including $ as an operator, too, but I think our proposal will leave it as is: invalid except as part of $0 or LLDB variables $R1)

@jtbandes
Copy link
Contributor

jtbandes commented Oct 12, 2016

What does "a framework to support them" mean? Aren't source-breaking changes encouraged to happen ASAP (3.0.1 or 3.1) so we can avoid them in the future?

@jrose-apple
Copy link
Contributor

We already passed that deadline: it was 3.0. At this point source-breaking changes need to be justified and will be handled on a case-by-case basis.

@jrose-apple
Copy link
Contributor

…but the process for doing this hasn't been decided and written up yet.

@jtbandes
Copy link
Contributor

I see. And is the swift 3 branch still being used for 3.1? (Sorry for hijacking this PR thread...)

@jrose-apple
Copy link
Contributor

Most likely no, we will rebranch there. (Which may mean downgrading this to a warning.)

@lattner
Copy link
Contributor

lattner commented Oct 13, 2016

We discussed this topic today in the core team. Here are some specific requests:

  1. Please change this to reject $ with a fixit to $ instead of using the emoji I suggested above.
  2. Please conditionalize rejection on Swift 4 mode. This is now a thing, you can see an example of it being used here: 12fb0ba

As to deciding the fate of single $ identifiers, I'm working with a swift-evolution proposal to run this topic by the community. That could possibly lead to backtracking on our rejection of $, but in the meantime we should still reject it the right way. Thanks @CodaFi!

@lattner
Copy link
Contributor

lattner commented Oct 13, 2016

Sigh, please fixit this from $ to $... i.e. a dollar sign in backticks. :-)

@lattner
Copy link
Contributor

lattner commented Oct 13, 2016

Maybe this is how you spell it in markdown?? $

@lattner
Copy link
Contributor

lattner commented Oct 13, 2016

OMG, I win! :-)

@rintaro
Copy link
Member

rintaro commented Oct 13, 2016

$ spelled as $ spelled as `$` spelled as `` `$` `` ...

kateinoigakukun pushed a commit that referenced this pull request Aug 31, 2022
Resolve conflicts with upstream `main`
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.

6 participants