Skip to content

Compiler crash at inout parameter pack #67091

Open
@xavierjurado

Description

@xavierjurado

Description
The following snippet crashes Swift 5.9 compiler. Same function without the inout keyword compiles just fine.

Steps to reproduce

import Foundation

struct CallbackModel {
  var boolCallback: (Bool) -> Void
}

func combineCallbacks<each T>(source: inout ((repeat each T) -> Void)) {
  
}

func test(model: inout CallbackModel) {
  combineCallbacks(source: &model.boolCallback)
}

Stack trace:

1.	Apple Swift version 5.9 (swiftlang-5.9.0.114.10 clang-1500.0.29.1)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/<path>/CombineCallbacks.swift")
4.	While silgen emitFunction SIL function "@$s17SwiftUIPlayground4test5modelyAA13CallbackModelVz_tF".
 for 'test(model:)' (at /<path>/CombineCallbacks.swift:11:1)
5.	While emitting reabstraction thunk in SIL function "@$sSb_QSiIegp_SbIegy_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           0x000000010652f828 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000010652e778 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010652fdbe SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff8123d05ed _sigtramp + 29
4  libsystem_platform.dylib 0x000000140000000a _sigtramp + 18446603456174291514
5  swift-frontend           0x0000000100cabf42 buildThunkBody(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::CanType) + 1186
6  swift-frontend           0x0000000100cab6f6 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&) + 4134
7  swift-frontend           0x0000000100c9feb8 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 1704
8  swift-frontend           0x0000000100ca1be2 (anonymous namespace)::Transform::transform(swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 322
9  swift-frontend           0x0000000100c9f097 swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 391
10 swift-frontend           0x0000000100c76eba (anonymous namespace)::SubstToOrigComponent::untranslate(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::RValue&&, swift::Lowering::SGFContext) && + 74
11 swift-frontend           0x0000000100c66411 swift::Lowering::TranslationPathComponent::set(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ArgumentSource&&, swift::Lowering::ManagedValue) && + 161
12 swift-frontend           0x0000000100c65d0f swift::Lowering::LogicalPathComponent::writeback(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::MaterializedLValue, bool) + 831
13 swift-frontend           0x0000000100c74eb1 swift::Lowering::ExclusiveBorrowFormalAccess::finishImpl(swift::Lowering::SILGenFunction&) + 145
14 swift-frontend           0x0000000100b7df05 swift::Lowering::FormalEvaluationScope::popImpl() + 357
15 swift-frontend           0x0000000100ba5cb6 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<swift::ApplyFlags, unsigned char>, swift::Lowering::SGFContext, llvm::Optional<swift::ActorIsolation>) + 1478
16 swift-frontend           0x0000000100bae2f8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 5640
17 swift-frontend           0x0000000100bab094 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 3156
18 swift-frontend           0x0000000100c30bb1 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 657
19 swift-frontend           0x0000000100c232b1 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 1105
20 swift-frontend           0x0000000100cbfbb6 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 6054
21 swift-frontend           0x0000000100c57034 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 868
22 swift-frontend           0x0000000100b962f4 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 8084
23 swift-frontend           0x0000000100b98235 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef) + 181
24 swift-frontend           0x0000000100b94348 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 264
25 swift-frontend           0x0000000100b9b568 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 3336
26 swift-frontend           0x0000000100cbe047 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&) + 183
27 swift-frontend           0x0000000100b9fb7d llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 669
28 swift-frontend           0x00000001004aaeca performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1706
29 swift-frontend           0x00000001004a8fdc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5532
30 swift-frontend           0x0000000100462e93 swift::mainEntry(int, char const**) + 2035
31 dyld                     0x00007ff81204941f start + 1903

Environment

  • Swift compiler version info: swift-driver version: 1.82.2 Apple Swift version 5.9 (swiftlang-5.9.0.114.10 clang-1500.0.29.1)
  • Xcode version info: Xcode 15.0, Build version 15A5161b
  • Deployment target: iOS 16.0

Metadata

Metadata

Assignees

Labels

SILGenArea → compiler: The SIL generation stageassertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarefunction parametersFeature → declarations: function parametersfunction typesFeature → types: function typesgenericsFeature: generic declarations and typesinoutFeature → types: `inout` typesparameter packsFeature → generics: Parameter packsswift 5.9typesFeature: types

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions