You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optional transformed capture has incorrect type when nil #827
When a RegexBuilder pattern includes an optional, transformed capture, and the capture is nil, converting the match to AnyRegexOutput and then accessing the capture's type shows Substring? instead of the transformed type.
letpattern=Regex{Capture(OneOrMore(.digit)){Int($0)!}Optionally{"."Capture(OneOrMore(.digit)){Int($0)!}}}forstrin["123.456","789"]{ifletmatch=str.wholeMatch(of:pattern){print(match.output)leterasedMatch=Regex<AnyRegexOutput>.Match(match)print(erasedMatch[1].type,erasedMatch[2].type)}}
// Output:
// ("123.456", 123, Optional(456))
// Int Optional<Int>
// ("789", 789, nil)
// Int Optional<Substring>
Activity
natecook1000 commentedon Sep 30, 2025
Fixed by #825.