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-7122] Treat non-breaking spaces as regular spaces, with a warning #49670

Closed
belkadan opened this issue Mar 5, 2018 · 2 comments
Closed
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser

Comments

@belkadan
Copy link
Contributor

belkadan commented Mar 5, 2018

Previous ID SR-7122
Radar rdar://problem/20982969
Original Reporter @belkadan
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, Parser, StarterBug
Assignee hashemi (JIRA)
Priority Medium

md5: 7aaf5ce8bb056d1cdd2e4c1a2f231c43

Issue Description:

Sometimes a Unicode non-breaking space character (U+00A0) slips into a source file, which can lead to inscrutable errors like this:

<stdin>:1:7: error: '=' must have consistent whitespace on both sides
var x = 1
<stdin>:1:8: error: invalid character in source file
var x = 1

(Note that on the command line we can't even highlight the non-breaking space, because we don't know its display width. That's a separate problem.)

It would be nice™ if non-breaking spaces were recognized by the lexer and treated as spaces, with a dedicated warning and fix-it: "non-breaking space (U+00A0) used instead of regular space".

@belkadan
Copy link
Contributor Author

belkadan commented Mar 5, 2018

JIRA is politely replacing the non-breaking space in the above example with a normal space. You can copy the line of code from https://r12a.github.io/uniview/?charlist=var%20x%20%3D%C2%A01.

@swift-ci
Copy link
Collaborator

Comment by Ahmad Alhashemi (JIRA)

PR submitted
#16090

@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
compiler The Swift compiler in itself good first issue Good for newcomers improvement parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

2 participants