Skip to content

crash on initializer with illegal default value expression for thrown error type #90556

Description

@tayloraswift

Description

crashes on Swift 6.3.3 with compile command swiftc -language-mode 6 test.swift

Reproduction

struct S {
    init<E>(
        x: Int,
        throwing _: E.Type = Never.self,
        body: (inout Int) throws(E) -> () = { (_) throws(Never) in }
    ) throws(E) {
    }
}

S.init(x: 1)

Stack dump

error: compile command failed due to signal 11 (use -v to see invocation)
test.swift:4:30: warning: cannot use default expression for inference of 'E.Type' because it is inferrable from parameters #1, #2; this will be an error in a future Swift language mode
 2 |     init<E>(
 3 |         x: Int,
 4 |         throwing _: E.Type = Never.self,
   |                              `- warning: cannot use default expression for inference of 'E.Type' because it is inferrable from parameters #1, #2; this will be an error in a future Swift language mode
 5 |         body: (inout Int) throws(E) -> () = { (_) throws(Never) in }
 6 |     ) throws(E) {

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file test.swift -target arm64-apple-macosx26.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.5.sdk -color-diagnostics -Xcc -fcolor-diagnostics -language-mode 6 -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name test -disable-clang-spi -target-sdk-version 26.5 -target-sdk-name macosx26.5 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -in-process-plugin-server-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/7w/kjykz1hx7m1b16zdzxv0brlw0000gn/T/TemporaryDirectory.CuPYEp/test-1.o
1.      Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)
2.      Compiling with the current language version
3.      While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "test.swift")
4.      While emitting reabstraction thunk in SIL function "@$sSis5NeverOIeglzr_SiIegl_TR".
 for <<debugloc at "<compiler-generated>":0:0>>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           0x000000010ade508c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010ade252c llvm::sys::RunSignalHandlers() + 172
2  swift-frontend           0x000000010ade567c SignalHandler(int, __siginfo*, void*) + 356
3  libsystem_platform.dylib 0x0000000189883744 _sigtramp + 56
4  swift-frontend           0x0000000105453e24 swift::Lowering::SILGenFunction::emitApplyWithRethrow(swift::SILLocation, swift::SILValue, swift::SILType, swift::SubstitutionMap, llvm::ArrayRef<swift::SILValue>) + 2044
5  swift-frontend           0x000000010556e8ac buildThunkBody(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanType, llvm::function_ref<void (swift::Lowering::SILGenFunction&)>) + 3372
6  swift-frontend           0x00000001055702e8 createThunk(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeLowering const&) + 3860
7  swift-frontend           0x0000000105564c88 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 2116
8  swift-frontend           0x00000001054afa18 swift::Lowering::Conversion::emit(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::SGFContext) const + 624
9  swift-frontend           0x0000000105432268 (anonymous namespace)::ScalarResultPlan::finish(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::Initialization*, swift::SILFunctionTypeRepresentation) + 664
10 swift-frontend           0x0000000105431e88 (anonymous namespace)::ScalarResultPlan::finish(swift::Lowering::SILGenFunction&, swift::SILLocation, llvm::ArrayRef<swift::Lowering::ManagedValue>&, swift::SILValue) + 448
11 swift-frontend           0x0000000105452e70 swift::Lowering::SILGenFunction::emitApply(std::__1::unique_ptr<swift::Lowering::ResultPlan, std::__1::default_delete<swift::Lowering::ResultPlan>>&&, swift::Lowering::ArgumentScope&&, swift::SILLocation, swift::Lowering::ManagedValue, swift::SubstitutionMap, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::Lowering::CalleeTypeInfo const&, swift::optionset::OptionSet<swift::ApplyFlags, unsigned char>, swift::Lowering::SGFContext, std::__1::optional<swift::ActorIsolation>) + 3132
12 swift-frontend           0x00000001054d1050 swift::Lowering::SILGenFunction::emitApplyOfDefaultArgGenerator(swift::SILLocation, swift::ConcreteDeclRef, unsigned int, swift::CanType, bool, swift::Lowering::SGFContext) + 1196
13 swift-frontend           0x000000010546c36c (anonymous namespace)::DelayedArgument::emit(swift::Lowering::SILGenFunction&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, unsigned long&) + 296
14 swift-frontend           0x0000000105455300 emitDelayedArguments(swift::Lowering::SILGenFunction&, llvm::MutableArrayRef<(anonymous namespace)::DelayedArgument>, llvm::MutableArrayRef<llvm::SmallVector<swift::Lowering::ManagedValue, 4u>>) + 560
15 swift-frontend           0x0000000105472af0 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::ArrayRef<swift::LifetimeDependenceInfo>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 2124
16 swift-frontend           0x00000001054597b4 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1028
17 swift-frontend           0x000000010545810c swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2900
18 swift-frontend           0x00000001054d234c swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 992
19 swift-frontend           0x000000010559fde4 swift::ASTVisitor<swift::Lowering::SILGenTopLevel, void, void, void, void, void, void>::visit(swift::Decl*) + 612
20 swift-frontend           0x000000010559cf00 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*, swift::SILFunction*) + 1244
21 swift-frontend           0x000000010559f980 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*) + 208
22 swift-frontend           0x0000000105446aec swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 2168
23 swift-frontend           0x000000010558bb20 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 208
24 swift-frontend           0x000000010544b2fc swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 548
25 swift-frontend           0x000000010494e0d0 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) + 980
26 swift-frontend           0x0000000104953ab0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*, llvm::ArrayRef<char const*>) + 1740
27 swift-frontend           0x0000000104950818 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3308
28 swift-frontend           0x00000001048d0424 swift::mainEntry(int, char const**) + 5224
29 dyld                     0x00000001894bbe00 start + 6992

Expected behavior

it should not crash

Environment

swiftc --version
swift-driver version: 1.148.6 Apple Swift version 6.3.3 (swiftlang-6.3.3.1.3 clang-2100.1.1.101)
Target: arm64-apple-macosx26.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions