Skip to content

CharacterSet.inverted crashes on mutation #5262

@WFT

Description

@WFT

This code (see below) crashes with the message void CFCharacterSetRemoveCharactersInRange(CFMutableCharacterSetRef, CFRange): Immutable character set passed to mutable function.

If you comment out either the .inverted or the remove call, it does not crash.

The same code works fine on macOS Sequoia.

I reproduced this crash on these docker images:

  • swiftlang/swift:nightly-6.2-jammy
  • swift:6.1.2

And I originally found the issue on GitHub Actions ubuntu-latest while trying to run SwiftGrammar() from https://github.com/JohnSundell/Splash.

Sample code:

import Foundation

var cs = CharacterSet.alphanumerics.inverted
cs.remove("_")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions