This looks like a POB (plain ol' bug) in the version of Swift that shipped in Xcode 14.2 and the one in the 14.3 beta 2. This following crashes at runtime (in a playground, too):
let line = "abc <"
let match = line.firstRange(of: "] <")
It's something about the final "<" in the match string.
tera
2
Old? This API is not even in my Xcode 14 :-)
Try "range" instead of "firstRange" - this one works fine for me.
jeremyp
(Jeremy Pereira)
3
Actually, I can only reproduce it when both line and match end in < and the return value should be nil
xwu
(Xiaodi Wu)
4
Sure seems like! Can you file a bug?
bjhomer
(BJ Homer)
5
This looks very similar to a bug I filed here about a week ago.
1 Like
jeremyp
(Jeremy Pereira)
6
Yes. This is the same issue.
Thanks for finding the already-filed bug. I got distracted by something else for a few days, so I hadn't filed a bug but now it looks like I don't need to. 