-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Open
Copy link
Labels
SILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passescompilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationinteger literalsFeature → literals: Integer literalsFeature → literals: Integer literalsliteralsFeature → expressions: Literals such as an integer or string literalFeature → expressions: Literals such as an integer or string literalswift 6.3
Description
Description
The diagnostic is confusing when matching UInt with negative integer literal
Reproduction
func test(val: UInt) {
switch val { // error: integer literal '-24' overflows when stored into unsigned 'Builtin.Int64'
case 12: break
case -24: break
default: break
}
}
Expected behavior
Message should be at least integer literal '-24' overflows when stored into unsigned 'UInt'
, but preferably more like integer literal '-24' is invalid for unsigned type 'UInt'
.
The diagnostic location is also off, it should be on the -24
literal.
Environment
6.2
Additional information
No response
Metadata
Metadata
Assignees
Labels
SILOptimizerArea → compiler: SIL optimization passesArea → compiler: SIL optimization passescompilerThe Swift compiler itselfThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationinteger literalsFeature → literals: Integer literalsFeature → literals: Integer literalsliteralsFeature → expressions: Literals such as an integer or string literalFeature → expressions: Literals such as an integer or string literalswift 6.3