firstMatch(of:) crash

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.

Old? This API is not even in my Xcode 14 :-)
Try "range" instead of "firstRange" - this one works fine for me.

Actually, I can only reproduce it when both line and match end in < and the return value should be nil

Sure seems like! Can you file a bug?

This looks very similar to a bug I filed here about a week ago.

1 Like

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. :slightly_smiling_face: