Skip to content

Runtime crashes with NonEmptyStringΒ #72

@iDmitriyy

Description

@iDmitriyy

There is a hole allowing to initialize invalid NonEmptyString

let empty1: NonEmptyString = "" // crash πŸ’₯

let empty2 = NonEmptyString("") // crash πŸ’₯

let empty3: NonEmptyString = "\("")" // crash πŸ’₯

The problem seems to be with these conditional conformances:

extension NonEmpty: ExpressibleByStringLiteral where Collection: ExpressibleByStringLiteral

extension NonEmpty: ExpressibleByStringInterpolation where Collection: ExpressibleByStringInterpolation, Collection.StringLiteralType == DefaultStringInterpolation.StringLiteralType

The best approach I see for now is to remove these conformances and replace them with macro #NonEmptyString, which check at compile time.

Any ideas or plans about it?

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