Skip to content

Commit 11b886a

Browse files
committed
Fix capture counting issue
1 parent 678bba6 commit 11b886a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Sources/_StringProcessing/Regex/DSLList.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ struct DSLList {
1616

1717
// experimental
1818
var hasCapture: Bool = false
19-
var hasChildren: Bool = false
19+
var hasChildren: Bool {
20+
(nodes.first?.directChildren ?? 0) > 0
21+
}
22+
2023
var captureList: CaptureList {
2124
.Builder.build(self)
2225
}

Tests/RegexTests/CaptureTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func captureTest(
157157
}
158158

159159
// Ensure DSLTree preserves literal captures
160-
var dslCapList = ast.dslTree.captureList
160+
var dslCapList = DSLList(ast: ast).captureList
161161
// Peel off the whole match element.
162162
dslCapList.captures.removeFirst()
163163
guard dslCapList == capList else {

0 commit comments

Comments
 (0)