swift
swift copied to clipboard
Compiler crash for `self` reference in enum with no cases
Description
import Foundation
enum MySwitch {
public var generatedExperimentKey: String {
switch self {
default: fatalError()
}
//return ""
}
}
Steps to reproduce
Save the code above to file. Run swiftc someFile.swift.
Note: Uncomment the return to fix the crash. It produces a "will never reach" warning, but also a "note: 'self' is of type 'MySwitch' which cannot be constructed because it is an enum with no cases"
Expected behavior Compiler should not crash.
Swift 5.9 (swiftlang-5.9.0.114.6 clang-1500.0.27.1) Xcode 15.0 Build version 15A5160n
Assertion failed: (SGF.B.hasValidInsertionPoint() && "changing cleanup state at invalid IP"), function setCleanupState, file Cleanup.cpp, line 261.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: bin/swift-frontend /Users/mac/Desktop/test.swift -emit-silgen
1. Swift version 5.9-dev (Swift c1d5118c21da49a9c2194734cbf9b6970bc63056)
2. Compiling with the current language version
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
4. While silgen emitFunction SIL function "@$s4test8MySwitchO22generatedExperimentKeySSvg".
for getter for generatedExperimentKey (at /Users/mac/Desktop/test.swift:96:16)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x000000010e295407 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 swift-frontend 0x000000010e2946e5 llvm::sys::RunSignalHandlers() + 85
2 swift-frontend 0x000000010e295a50 SignalHandler(int) + 288
3 libsystem_platform.dylib 0x00007ff815a94dfd _sigtramp + 29
4 libsystem_platform.dylib 0x0000000000000015 _sigtramp + 18446603370217517621
5 libsystem_c.dylib 0x00007ff8159cad24 abort + 123
6 libsystem_c.dylib 0x00007ff8159ca0cb err + 0
7 swift-frontend 0x000000010e412963 swift::Lowering::CleanupManager::forwardCleanup(swift::DiverseStackBase::stable_iterator) (.cold.4) + 35
8 swift-frontend 0x0000000108dda1fb swift::Lowering::CleanupManager::forwardCleanup(swift::DiverseStackBase::stable_iterator) + 299
9 swift-frontend 0x0000000108ddd245 swift::Lowering::ManagedValue::forward(swift::Lowering::SILGenFunction&) const + 37
10 swift-frontend 0x0000000108e34b06 swift::Lowering::SILGenBuilder::createLoadTake(swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::TypeLowering const&) + 134
11 swift-frontend 0x0000000108de78c2 (anonymous namespace)::ExplodeTupleValue::visitType(swift::CanType, swift::Lowering::ManagedValue) + 114
12 swift-frontend 0x0000000108de5057 swift::Lowering::RValue::RValue(swift::Lowering::SILGenFunction&, swift::Expr*, swift::Lowering::ManagedValue) + 183
13 swift-frontend 0x0000000108e769dd swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 24877
14 swift-frontend 0x0000000108e64605 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 37
15 swift-frontend 0x0000000108ee9b60 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 544
16 swift-frontend 0x0000000108ee76d6 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 10118
17 swift-frontend 0x0000000108ee6493 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 5443
18 swift-frontend 0x0000000108ee4f45 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
19 swift-frontend 0x0000000108e8b0b7 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 439
20 swift-frontend 0x0000000108df7573 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 10739
21 swift-frontend 0x0000000108df8de7 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef) + 231
22 swift-frontend 0x0000000108df4b68 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 168
23 swift-frontend 0x0000000108ef6405 (anonymous namespace)::SILGenType::visitFuncDecl(swift::FuncDecl*) + 21
24 swift-frontend 0x0000000109e2007a swift::AbstractStorageDecl::visitEmittedAccessors(llvm::function_ref<void (swift::AccessorDecl*)>) const + 90
25 swift-frontend 0x0000000108ef63b7 (anonymous namespace)::SILGenType::visitVarDecl(swift::VarDecl*) + 359
26 swift-frontend 0x0000000108ef2b04 (anonymous namespace)::SILGenType::emitType() + 116
27 swift-frontend 0x0000000108ef2a89 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
28 swift-frontend 0x0000000108dfb83b swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 2283
29 swift-frontend 0x0000000108ee4a18 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 120
30 swift-frontend 0x0000000108e00863 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 387
31 swift-frontend 0x0000000108dfcb21 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 161
32 swift-frontend 0x00000001087d8402 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2290
33 swift-frontend 0x00000001087db140 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 784
34 swift-frontend 0x00000001087d9f60 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3232
35 swift-frontend 0x000000010879f4f3 swift::mainEntry(int, char const**) + 1203
36 dyld 0x000000012c07d52e start + 462
Abort trap: 6