Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
finagolfin opened this issue Dec 27, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself init Feature → declarations: Initializers overload resolution Area → compiler → type checker: Overload resolution (ranking) potentially source breaking type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error

Comments

@finagolfin
Copy link
Member

finagolfin commented Dec 27, 2024

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

@finagolfin finagolfin added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. potentially source breaking compiler The Swift compiler itself overload resolution Area → compiler → type checker: Overload resolution (ranking) init Feature → declarations: Initializers labels Dec 27, 2024
@AnthonyLatsis AnthonyLatsis added type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error labels Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself init Feature → declarations: Initializers overload resolution Area → compiler → type checker: Overload resolution (ranking) potentially source breaking type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

2 participants