Open
Description
Description
When a constant is declared with type Never
and subsequently used as the subject of a switch
statement, the compiler fails to diagnose the use of an uninitialized constant, leading to a runtime crash.
Reproduction
let x: Never
switch x { }
I will provide the crash message shortly; at the moment, I am not at my computer.
Expected behavior
The compiler should produce an error.
Environment
I believe it is 5.10.1, but I am not sure as I am not at my computer. I downloaded the release about a week ago. I will report the version as soon as I am back at my computer.
I was running Swift in an Ubuntu 24.04 container. Swift was installed to /opt/swift
.
Additional information
I was informed this is not intentional in this thread on the forum.
Metadata
Metadata
Assignees
Labels
Area → standard library: The `Never` typeArea → compiler: The SIL generation stageBug: Accepts invalidA deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfArea → compiler → SIL: Definite initializationFeature: constant and variable declarationsFeature: statementsFeature → statements: 'switch' statements