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

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions