Skip to content

Ban ] as literal first character of custom character class #404

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
May 12, 2022

Conversation

hamishknight
Copy link
Contributor

PCRE, Oniguruma, and ICU allow ] to appear as the first member of a custom character class, and treat it as literal, due to empty character classes being invalid.

However this behavior isn't particularly intuitive, and makes lexing heuristics such as swiftlang/swift#58835 harder to implement properly. Instead, reject such character classes as being empty, and require escaping if ] is meant as the first character.

PCRE, Oniguruma, and ICU allow `]` to appear as
the first member of a custom character class, and
treat it as literal, due to empty character classes
being invalid.

However this behavior isn't particularly intuitive,
and makes lexing heuristics harder to implement
properly. Instead, reject such character classes
as being empty, and require escaping if `]` is
meant as the first character.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight requested a review from milseman May 12, 2022 11:50
@hamishknight hamishknight merged commit d3ea692 into swiftlang:main May 12, 2022
@hamishknight hamishknight deleted the ban-empty-cc branch May 12, 2022 13:56
@johnno1962
Copy link

Wot?

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.

3 participants