swiftlang / swiftlang/swift-experimental-string-processing

Regex is not Sendable

Open
#792 1 comment 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Swift
Stars
308
Forks
52
Avg merge
12h 45m
Merged PRs (30d)
2

Description

Description

I was surprised to learn that Regex is not Sendable. The code below doesn't compile with Swift 6.

Reproduction
struct Parser {
    private static let number = /\d+/
}
Expected behavior

I would expect this to just work. Regex is a value type. Why would it have shared mutable state?

Environment

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: x86_64-apple-macosx15.0

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Parser reproduction under Swift 6 and inspect how Regex is represented and checked for Sendable conformance. Done means the shown static Regex declaration compiles without a Sendable diagnostic while preserving the expected regex behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.