Skip to content

Commit 829a541

Browse files
authored
Merge pull request #475 from Azoy/handle-aro-57
[5.7] Handle AnyRegexOutput when casting to new Regex
2 parents e80de62 + 7ef35d1 commit 829a541

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Sources/_StringProcessing/Utility/TypeVerification.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
@available(SwiftStdlib 5.7, *)
1515
extension Regex {
1616
internal func _verifyType() -> Bool {
17+
guard Output.self != AnyRegexOutput.self else {
18+
return true
19+
}
20+
1721
var tupleElements: [Any.Type] = [Substring.self]
1822
var labels = " "
1923

Tests/RegexBuilderTests/AnyRegexOutputTests.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ extension RegexDSLTests {
138138
) {
139139
let aro = Regex<AnyRegexOutput>(re)
140140

141-
// FIXME: The below fatal errors
142-
let casted = aro//try! XCTUnwrap(Regex(aro, as: Output.self))
141+
let casted = try! XCTUnwrap(Regex(aro, as: Output.self))
143142

144143
// contains(captureNamed:)
145144
checkContains(re, kind)
@@ -173,15 +172,15 @@ extension RegexDSLTests {
173172
(?x)
174173
(\p{hexdigit}{4}) -? (?<salient>\p{hexdigit}{4}) -?
175174
(\p{hexdigit}{4}) -? (\p{hexdigit}{4})
176-
"""#, as: (Substring, Substring, Substring, Substring, Substring).self),
175+
"""#, as: (Substring, Substring, salient: Substring, Substring, Substring).self),
177176
.salient,
178177
salientOutput
179178
)
180179
check(try! Regex(#"""
181180
(?x)
182181
(\p{hexdigit}{4}) -? (?<note>\p{hexdigit}{4}) -?
183182
(\p{hexdigit}{4}) -? (\p{hexdigit}{4})
184-
"""#, as: (Substring, Substring, Substring, Substring, Substring).self),
183+
"""#, as: (Substring, Substring, note: Substring, Substring, Substring).self),
185184
.note,
186185
noteOutput
187186
)

0 commit comments

Comments
 (0)