Skip to content

[Sema] Hide underscored names from typo-correction #20125

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 2 commits into from
Nov 6, 2018

Conversation

adamshin
Copy link
Contributor

Identifiers with a leading underscore are now hidden from typo-correction unless the typed name also begins with an underscore.

Resolves SR-9083.

@slavapestov
Copy link
Contributor

We already have something similar in code completion -- should we share the logic between the two instead of adding new rules?

@adamshin
Copy link
Contributor Author

adamshin commented Oct 30, 2018

I was looking into the code completion side of things as well, but wasn't sure where that logic was located. Are you thinking there's existing logic around leading-underscore names that could be reused here?

@slavapestov slavapestov requested a review from rjmccall October 31, 2018 17:56
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

LGTM.

@adamshin
Copy link
Contributor Author

adamshin commented Nov 5, 2018

Anything else needed here?

@rjmccall
Copy link
Contributor

rjmccall commented Nov 5, 2018

@swift-ci Please test.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 5, 2018

Build failed
Swift Test OS X Platform
Git Sha - 45939f5789f4de16a4c966c69dc16c220ccec08c

@rjmccall
Copy link
Contributor

rjmccall commented Nov 5, 2018

That's definitely your failure to fix.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 5, 2018

Build failed
Swift Test Linux Platform
Git Sha - 45939f5789f4de16a4c966c69dc16c220ccec08c

@adamshin adamshin force-pushed the typo-correction-underscore branch from 0d4e1f9 to 45939f5 Compare November 5, 2018 20:39
Identifiers with a leading underscore are now hidden from typo-correction unless the typed name also begins with an underscore.
@adamshin adamshin force-pushed the typo-correction-underscore branch from 45939f5 to 9d23ba2 Compare November 5, 2018 20:42
@slavapestov
Copy link
Contributor

@adamshin It looks like code completion calls Decl::isPrivateStdlibDecl(), which has a number of checks in addition to leading underscore. Can you try using that instead?

@jrose-apple
Copy link
Contributor

Sorry, I was the one who wrote up the bug this way. We don't want to use isPrivateStdlibDecl for this, because (1) we want to opt out of it if the user actually writes an underscore, and (2) we want this to apply to all APIs, not just stdlib ones.

@jrose-apple
Copy link
Contributor

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 5, 2018

Build failed
Swift Test OS X Platform
Git Sha - 45939f5789f4de16a4c966c69dc16c220ccec08c

@adamshin
Copy link
Contributor Author

adamshin commented Nov 5, 2018

Looks like my changes broke a test (Parse/recovery.swift). I'm looking into that now.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 6, 2018

Build failed
Swift Test Linux Platform
Git Sha - 45939f5789f4de16a4c966c69dc16c220ccec08c

The unresolved identifier 'esp' used to have '_exp' as a typo-correction option. That's no longer the case, and the type checker now singles out 'test' as the unique correction.
@rjmccall
Copy link
Contributor

rjmccall commented Nov 6, 2018

@swift-ci Please test.

@swift-ci
Copy link
Contributor

swift-ci commented Nov 6, 2018

Build failed
Swift Test Linux Platform
Git Sha - 9d23ba2

@swift-ci
Copy link
Contributor

swift-ci commented Nov 6, 2018

Build failed
Swift Test OS X Platform
Git Sha - 9d23ba2

@jrose-apple
Copy link
Contributor

Failure looks unrelated; let's try again.

@swift-ci Please test Linux

@jrose-apple jrose-apple merged commit fcff56d into swiftlang:master Nov 6, 2018
@jrose-apple
Copy link
Contributor

Thanks, Adam!

@adamshin adamshin deleted the typo-correction-underscore branch November 6, 2018 18:55
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.

5 participants