Skip to content

[5.7-04182022] [Parse] Allow prefix operators containing / with /.../ regex literals #58863

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

Conversation

hamishknight
Copy link
Contributor

5.5-04182022 cherry-pick of #58835

When lexing a regex literal, treat a prefix operator containing / the same as the unapplied infix operator case, where we tentatively lex. This means that we bail if there is no closing / or the starting character is invalid. This leaves binary operator containing / in expression position as the last place where we know that we definitely have a regex literal.

Additionally, expand the starting ) character heuristic to cover the entire range of the regex literal, ensuring to take escapes and custom character classes into account. This means we will not lex a regex literal if there is an unbalanced ) somewhere in the body.

@hamishknight hamishknight requested a review from a team as a code owner May 12, 2022 17:29
Treat a prefix operator containing `/` the same as
the unapplied infix operator case, where we
tentatively lex. This means that we bail if there
is no closing `/` or the starting character is
invalid. This leaves binary operator containing
`/` in expression position as the last place where
we know that we definitely have a regex literal.
Previously we would only check for a starting
character of `)` when performing a tentative
lex of a regex literal. Expand this to cover the
entire range of the regex literal, ensuring to
take escapes and custom character classes into
account.
@hamishknight hamishknight force-pushed the allow-prefix-slash-5.7-04182022 branch from 64df42a to 342e065 Compare May 12, 2022 18:43
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit c200d39 into swiftlang:release/5.7-04182022 May 12, 2022
@hamishknight hamishknight deleted the allow-prefix-slash-5.7-04182022 branch May 12, 2022 22:05
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