Skip to content

[DNM] 5.7 batch test #605

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/_StringProcessing/ByteCodeGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fileprivate extension Compiler.ByteCodeGen {
}

// Fast path for eliding boundary checks for an all ascii quoted literal
if optimizationsEnabled && s.allSatisfy(\.isASCII) {
if optimizationsEnabled && s.allSatisfy(\.isASCII) && !s.isEmpty {
let lastIdx = s.unicodeScalars.indices.last!
for idx in s.unicodeScalars.indices {
let boundaryCheck = idx == lastIdx
Expand Down Expand Up @@ -1061,6 +1061,8 @@ extension DSLTree.Node {
case .atom(let atom):
switch atom {
case .changeMatchingOptions, .assertion: return false
// Captures may be nil so backreferences may be zero length matches
case .backreference: return false
default: return true
}
case .trivia, .empty:
Expand Down
7 changes: 7 additions & 0 deletions Tests/RegexTests/MatchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2465,6 +2465,9 @@ extension RegexTests {

// case insensitive tests
firstMatchTest(#"(?i)abc\u{301}d"#, input: "AbC\u{301}d", match: "AbC\u{301}d", semanticLevel: .unicodeScalar)

// check that we don't crash on empty strings
firstMatchTest(#"\Q\E"#, input: "", match: "")
}

func testCase() {
Expand Down Expand Up @@ -2534,4 +2537,8 @@ extension RegexTests {
expectCompletion(regex: #"(a{,4})*"#, in: "aa")
expectCompletion(regex: #"((|)+)*"#, in: "aa")
}

func testFuzzerArtifacts() throws {
expectCompletion(regex: #"(b?)\1*"#, in: "a")
}
}