Constants of type Never used in switch statements do not trigger error for use of uninitialized constant, leading to runtime crash #74478
Labels
accepts invalid
Bug: Accepts invalid
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler itself
definite initialization
Area → compiler → SIL: Definite initialization
let & var
Feature: constant and variable declarations
Never
Area → standard library: The `Never` type
SILGen
Area → compiler: The SIL generation stage
statements
Feature: statements
swift 6.0
switch
Feature → statements: 'switch' statements
Description
When a constant is declared with type
Never
and subsequently used as the subject of aswitch
statement, the compiler fails to diagnose the use of an uninitialized constant, leading to a runtime crash.Reproduction
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.
The text was updated successfully, but these errors were encountered: