Skip to content

A unicode scalar initialization now errors about overflow since the Dec. 19 trunk snapshot #78371

Closed
@finagolfin

Description

@finagolfin

Description

I can no longer build the swift-experimental-string-processing package on linux x86_64 or Android AArch64:

> ../swift-DEVELOPMENT-SNAPSHOT-2024-12-19-a-fedora39/usr/bin/swift build
--- snip other output ---
swift-experimental-string-processing/Sources/Exercises/Participants/HandWrittenParticipant.swift:63:44: error: integer literal '2045' overflows when stored into 'UInt8'
 61 | 
 62 |   // For testing our framework
 63 |   if forceFailure, lower == Unicode.Scalar(0x07FD) {
    |                                            `- error: integer literal '2045' overflows when stored into 'UInt8'
 64 |     return nil
 65 |   }

Patching that call to force unwrap like so, Unicode.Scalar(0x07FD)!, now gets the compiler to choose the right overload that returns an optional and takes larger values to avoid this issue.

Whether this build issue should be fixed in the compiler or the regex package depends on whether this was a conscious decision to break such code, which I'm guessing is a consequence of @xedin's #63585 that was finally merged last week.

Expected behavior

Builds fine with the prior trunk Dec. 16 snapshot and the latest 6.0 and 6.1 releases

Environment

Swift 6.2 on Linux x86_64 and Android AArch64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfinitFeature → declarations: Initializersoverload resolutionArea → compiler → type checker: Overload resolution (ranking)potentially source breakingtype checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions