Skip to content

Document that Trivia cannot represent invalid UTF-8 #1490

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 1 commit into from
Apr 5, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 4, 2023

No description provided.

@ahoppen ahoppen requested a review from rintaro April 4, 2023 17:45
@ahoppen
Copy link
Member Author

ahoppen commented Apr 4, 2023

@swift-ci Please test

/// Note: `Trivia` is not able to represent invalid UTF-8 sequences. To get
/// the leading trivia text including all invalid UTF-8 sequences, use
/// ```
/// node.syntaxTextBytes[(node.byteSize - node.trailingTriviaLength.utf8Length)...]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe

node.syntaxTextBytes.suffix(node.trailingTriviaLength.utf8Length)

looks easier. But it doesn't really matter

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, there is no suffix on Array. But I took the suggestion for prefix.

@ahoppen ahoppen force-pushed the ahoppen/trivia-invalid-utf8 branch from 8a82241 to fe6ab43 Compare April 4, 2023 22:26
@ahoppen
Copy link
Member Author

ahoppen commented Apr 4, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 5, 2023

@swift-ci Please test macOS

@ahoppen
Copy link
Member Author

ahoppen commented Apr 5, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 7c1c501 into swiftlang:main Apr 5, 2023
@ahoppen ahoppen deleted the ahoppen/trivia-invalid-utf8 branch April 5, 2023 22:54
ahoppen added a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 2023
…-utf8

Document that `Trivia` cannot represent invalid UTF-8
ahoppen added a commit to ahoppen/swift-syntax that referenced this pull request Apr 18, 2023
…-utf8

Document that `Trivia` cannot represent invalid UTF-8
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