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-331: Diagnostic notes and fixits for unicode confusables #9070

Merged
merged 1 commit into from
May 6, 2017
Merged

SR-331: Diagnostic notes and fixits for unicode confusables #9070

merged 1 commit into from
May 6, 2017

Conversation

robinkunde
Copy link
Contributor

Addresses SR-331 by adding diagnostic notes and fixits for confusable unicode characters. The confusables check only runs after the lexer encounters an invalid character or an identifier fails to resolve.

With @amackworth permission, I took over the code he wrote for #732. From the discussion there, it seems like the PR stalled due to disagreements over whether to use gyb for compile time code gen. I reworked the code to address most of the feedback and removed gyb usage. The flow is now as follows:

  1. The latest confusables.txt file has been added at utils/UnicodeData/confusables.txt
  2. A python script has been added at utils/generate_confusables.py that takes the confusables file and generates include/swift/Parse/Confusables.def
  3. lib/Parse/Confusables.cpp then generates all the cases for its switch statement using the preprocessor

This way, the script only has to be rerun if we broaden the list of covered confusables or Unicode releases a new version (happens about once a year).

@CodaFi
Copy link
Contributor

CodaFi commented Apr 27, 2017

Fantastic!

@swift-ci please smoke test

@CodaFi CodaFi requested a review from lattner April 27, 2017 19:29
@CodaFi
Copy link
Contributor

CodaFi commented Apr 27, 2017

Since the approach is roughly the same (and the PR comments from last time have been addressed), over to @lattner for if this is what he had in mind back then.

@CodaFi
Copy link
Contributor

CodaFi commented Apr 27, 2017

@robinkunde Please lint the Python script and fix the errors.

@robinkunde
Copy link
Contributor Author

@CodaFi I can't seem to find a clean way to fix the error where it complains about the docstring line length. The leading and closing line for def file header are supposed to be 80 columns wide. The python linter insists lines be at most 79 wide.

For now I've broken it up into multiple write statements, but it looks ugly. If someone knows a better way, please chime in.

@CodaFi
Copy link
Contributor

CodaFi commented Apr 27, 2017

Sometimes the linter isn't always right - can we add specific exceptions for this @hughbe?

@CodaFi
Copy link
Contributor

CodaFi commented Apr 27, 2017

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented May 3, 2017

Just to check:

@swift-ci please test source compatibility

@CodaFi
Copy link
Contributor

CodaFi commented May 6, 2017

There's no reason to delay the inclusion of this feature any further. Thank you @robinkunde for carrying this over the goal line, and @amackworth for the original patch. Don't forget to resolve the SR. I'm going to close the original pull request as well.

⛵️

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.

2 participants