-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
NeverArea → standard library: The `Never` typeArea → standard library: The `Never` typeSILGenArea → compiler: The SIL generation stageArea → compiler: The SIL generation stageaccepts invalidBug: Accepts invalidBug: Accepts invalidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdefinite initializationArea → compiler → SIL: Definite initializationArea → compiler → SIL: Definite initializationlet & varFeature: constant and variable declarationsFeature: constant and variable declarationsstatementsFeature: statementsFeature: statementsswift 6.0switchFeature → statements: 'switch' statementsFeature → statements: 'switch' statements
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
NeverArea → standard library: The `Never` typeArea → standard library: The `Never` typeSILGenArea → compiler: The SIL generation stageArea → compiler: The SIL generation stageaccepts invalidBug: Accepts invalidBug: Accepts invalidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfdefinite initializationArea → compiler → SIL: Definite initializationArea → compiler → SIL: Definite initializationlet & varFeature: constant and variable declarationsFeature: constant and variable declarationsstatementsFeature: statementsFeature: statementsswift 6.0switchFeature → statements: 'switch' statementsFeature → statements: 'switch' statements