Skip to content

Builtin.Int leaking in diagnostics when matching UInt with negative integer literal #83877

@rintaro

Description

@rintaro

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

Labels

SILOptimizerArea → compiler: SIL optimization passescompilerThe Swift compiler itselfdiagnostics QoIBug: Diagnostics Quality of Implementationinteger literalsFeature → literals: Integer literalsliteralsFeature → expressions: Literals such as an integer or string literalswift 6.3

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions