Skip to content

Regex with positive lookahead crashes at runtime when accessing match.output #713

Closed
@AndreasVerhoeven

Description

@AndreasVerhoeven

Description

Using a regex with a positive lookahead sometimes crashes @ runtime. See the example in the reproduction

Reproduction

let regex = /(?=([1-9]|(a|b)))/
let input = "Something 9a"
let matches = input.matches(of: regex)
for match in matches {
	print(match.output) // accessing `.output` here crashes at runtime: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x225246848)
}

Stack dump

Thread 1: EXC_BREAKPOINT (code=1, subcode=0x225246848)

Expected behavior

No crash

Environment

swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions