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

[SR-9083] Hide underscored names from typo-correction #51584

Closed
belkadan opened this issue Oct 25, 2018 · 4 comments
Closed

[SR-9083] Hide underscored names from typo-correction #51584

belkadan opened this issue Oct 25, 2018 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@belkadan
Copy link
Contributor

Previous ID SR-9083
Radar rdar://problem/39798037
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee adamshin (JIRA)
Priority Medium

md5: 57b6ac2a640faa0f61ac4071937dd5ac

Issue Description:

Both the Swift stdlib and Apple's SDKs use leading underscores to indicate that something is an implementation detail and not for direct use; double underscores in particular have special meaning according to the C standard. We should avoid showing these names to the user in typo-correction unless the name the user typed also starts with an underscore.

The relevant code for this is in TypeChecker::performTypoCorrection; the place to add this check is probably the getCallEditDistance helper.

@belkadan
Copy link
Contributor Author

The original motivation for this problem was the C macro __bool_true_false_are_defined, which lives in stdbool.h. Reportedly, someone playing with the Swift Playgrounds iOS app managed to typo-correct to this name, but had no idea what it was for.

It'd also be useful to avoid showing declarations that have been marked NS_REFINED_FOR_SWIFT.

@belkadan
Copy link
Contributor Author

Hm, we probably also want something like this for code completion if it's not there already…

@swift-ci
Copy link
Collaborator

Comment by Adam Shin (JIRA)

@belkadan I've got a fix for the typo correction issue. I looked at the code completion part as well, but I'm having a harder time figuring out where the changes would need to be. Would you be ok just merging the first part for now, or do you want both changes in one pull request?

@belkadan
Copy link
Contributor Author

Sorry for the delay! It sounds like code completion has their own version of this, so yes, we can take the typo-correction change on its own.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants