Skip to content

[5.7] Fix a few DSL APIs #583

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

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Jul 15, 2022

5.7 cherry-pick of #578 + #580

Fix CharacterClass.newlineSequence such that it doesn't crash, CharacterClass.any such that it matches newlines, and implement CharacterClass.anyNonNewline.

Also fix Anchor.startOfLine and Anchor.endOfLine such that they always match newlines.

Resolves #537
Resolves #553
Resolves #571
Resolves #539

Resolves rdar://97029702

Remove the DSL -> _CharacterClassModel conversion,
and _CharacterClassModel's custom character class
matching logic, none of which is being used.
`makeDSLTreeCharacterClass` was the last API
that required it to be public. Remove it, and
replace it with some static members on `_AST.Atom`.
Map to `.newlineSequence` instead of `.newline`,
which allows it to create the correct consumer.

rdar://96330096
Explicitly disambiguate the fact we're talking
about `.`, which does not match newlines unless in
single line mode.
This time as a "true any" that matches any
character, including newlines.
This should map to `.any`, not `.dot`.

rdar://96509234
This enum will start including cases that only the
DSL can use, so move it off the AST.
Introduce `startOfInput` and `endOfInput` assertion
kinds, and map the DSL to them such that they do
not depend on matching options.

rdar://97029630
@hamishknight hamishknight added the r5.7 5.7 Release Cherry Picks label Jul 15, 2022
Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

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

LGTM

@Azoy
Copy link
Contributor

Azoy commented Jul 21, 2022

Explanation:
The proposed CharacterClass.anyNonNewline was not yet implemented, and a few character classes and anchors were not behaving correctly as proposed. Specifically, Character.newlineSequence was crashing, Character.any was not matching newlines, and Anchor.startOfLine and Anchor.endOfLine were not always matching newlines.

Scope:
Part of this PR is purely additive in terms of .anyNonNewline, so existing clients are unaffected. The bug fixes in this PR should be purely bug fixes, existing clients who were relying on the buggy behavior will have different runtime behavior, but will otherwise still compile.

Main Branch PR:
#578 and #580

Resolves:
rdar://97029702

Risk:
Low

Reviewed By:
@milseman

Testing:
Added a bunch of tests to ensure that we are now correctly matching the various buggy character classes/anchors and added tests to ensure that .anyNonNewline works as intended.

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 8087a3d into swiftlang:swift/release/5.7 Jul 21, 2022
@hamishknight hamishknight deleted the character-work-5.7 branch July 21, 2022 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r5.7 5.7 Release Cherry Picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants