Closed
Description
Description
The compiler crashes when:
A
is a generic type with parameter packeach T
;B
is a generic type with parameterT
;A
has a member of type(repeat B<each T>)
;A
has no explicit initializers.
Steps to reproduce
Compile the following code with -Xfrontend -enable-experimental-feature -Xfrontend VariadicGenerics
:
@available(macOS 9999, *)
struct TupleOfArrays<each T> {
let underlying: (repeat Array<each T>)
}
Results in:
error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: (!silConv.useLoweredAddresses() || (dest->getType().isAddressOnly(F) == rvalue->getType().isAddress())), function emitSemanticStore, file SILGenLValue.cpp, line 4591.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-07-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file rep1.swift -target x86_64-apple-macosx13.0 -enable-objc-interop -sdk /Users/yr.chen/Developer/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -color-diagnostics -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-07-a.xctoolchain/usr/bin/swift-driver -enable-experimental-feature VariadicGenerics -empty-abi-descriptor -plugin-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-07-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-07-a.xctoolchain/usr/local/lib/swift/host/plugins -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2023-06-07-a.xctoolchain/usr/lib/swift -module-name rep1 -target-sdk-version 14.0 -target-sdk-name macosx14.0 -o /var/folders/wz/kh49r3x93r5f_lhf4xcd41rw0000gn/T/TemporaryDirectory.xfJZUW/rep1-1.o
1. Apple Swift version 5.9-dev (LLVM 677d82daa6d87d2, Swift 291fe21d5020234)
2. Compiling with the current language version
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "rep1.swift")
4. While silgen emitValueConstructor SIL function "@$s4rep113TupleOfArraysV10underlyingACyxxQp_QPGSayxGxQp_t_tcfC".
for 'init(underlying:)' (at rep1.swift:2:8)
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 0x0000000111772f97 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 swift-frontend 0x0000000111772375 llvm::sys::RunSignalHandlers() + 85
2 swift-frontend 0x00000001117735e0 SignalHandler(int) + 288
3 libsystem_platform.dylib 0x00007ff801fa55ed _sigtramp + 29
4 libsystem_platform.dylib 0x00007fa83e8bcf88 _sigtramp + 18446743731128334776
5 libsystem_c.dylib 0x00007ff801e9eb45 abort + 123
6 libsystem_c.dylib 0x00007ff801e9de5e err + 0
7 swift-frontend 0x00000001118d3a03 swift::Lowering::SILGenFunction::emitSemanticStore(swift::SILLocation, swift::SILValue, swift::SILValue, swift::Lowering::TypeLowering const&, swift::IsInitialization_t) (.cold.5) + 35
8 swift-frontend 0x000000010c5fbf98 swift::Lowering::SILGenFunction::emitSemanticStore(swift::SILLocation, swift::SILValue, swift::SILValue, swift::Lowering::TypeLowering const&, swift::IsInitialization_t) + 872
9 swift-frontend 0x000000010c53614a swift::Lowering::ManagedValue::forwardInto(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::SILValue) + 186
10 swift-frontend 0x000000010c5a4785 swift::Lowering::SingleBufferInitialization::copyOrInitValueIntoSingleBuffer(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, bool, swift::SILValue) + 117
11 swift-frontend 0x000000010c5a9250 swift::Lowering::SingleBufferInitialization::copyOrInitValueInto(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, bool) + 64
12 swift-frontend 0x000000010c59cbe7 void llvm::function_ref<void (swift::Lowering::Initialization*)>::callback_fn<emitImplicitValueConstructorArg(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, swift::DeclContext*, (anonymous namespace)::LoweredParamsInContextGenerator&, swift::Lowering::Initialization*)::$_0::operator()(swift::SILValue, swift::SILValue, swift::SILValue) const::'lambda'(swift::Lowering::Initialization*)>(long, swift::Lowering::Initialization*) + 263
13 swift-frontend 0x000000010c60bca4 swift::Lowering::InPlacePackExpansionInitialization::performPackExpansionInitialization(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::SILValue, llvm::function_ref<void (swift::Lowering::Initialization*)>) + 500
14 swift-frontend 0x000000010c59cacf void llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>::callback_fn<emitImplicitValueConstructorArg(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, swift::DeclContext*, (anonymous namespace)::LoweredParamsInContextGenerator&, swift::Lowering::Initialization*)::$_0>(long, swift::SILValue, swift::SILValue, swift::SILValue) + 111
15 swift-frontend 0x000000010c60b485 swift::Lowering::SILGenFunction::emitDynamicPackLoop(swift::SILLocation, swift::CanTypeWrapper<swift::PackType>, unsigned int, swift::SILValue, swift::SILValue, swift::GenericEnvironment*, bool, llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>) + 2437
16 swift-frontend 0x000000010c60b96e swift::Lowering::SILGenFunction::emitDynamicPackLoop(swift::SILLocation, swift::CanTypeWrapper<swift::PackType>, unsigned int, swift::GenericEnvironment*, llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>) + 46
17 swift-frontend 0x000000010c599b25 emitImplicitValueConstructorArg(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, swift::DeclContext*, (anonymous namespace)::LoweredParamsInContextGenerator&, swift::Lowering::Initialization*) + 1125
18 swift-frontend 0x000000010c599ce2 emitImplicitValueConstructorArg(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::CanType, swift::DeclContext*, (anonymous namespace)::LoweredParamsInContextGenerator&, swift::Lowering::Initialization*) + 1570
19 swift-frontend 0x000000010c5965a2 swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 1202
20 swift-frontend 0x000000010c54bc06 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 10454
21 swift-frontend 0x000000010c54d697 emitOrDelayFunction(swift::Lowering::SILGenModule&, swift::SILDeclRef) + 231
22 swift-frontend 0x000000010c54d9db swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 363
23 swift-frontend 0x000000010c652111 swift::ASTVisitor<(anonymous namespace)::SILGenType, void, void, void, void, void, void>::visit(swift::Decl*) + 321
24 swift-frontend 0x000000010c64eae3 (anonymous namespace)::SILGenType::emitType() + 147
25 swift-frontend 0x000000010c64ea49 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 25
26 swift-frontend 0x000000010c54ffab swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 2331
27 swift-frontend 0x000000010c6401a6 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&) + 134
28 swift-frontend 0x000000010c554177 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 407
29 swift-frontend 0x000000010c55158b swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 123
30 swift-frontend 0x000000010bf78daa swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 746
31 swift-frontend 0x000000010bf7c4d9 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1001
32 swift-frontend 0x000000010bf7b16f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3487
33 swift-frontend 0x000000010bd9032d swift::mainEntry(int, char const**) + 2365
34 dyld 0x00007ff801c1e41f start + 1903
error: fatalError
Expected behavior
This should be compiled successfully.
Environment
- Swift compiler version info: Apple Swift version 5.9-dev (LLVM 677d82daa6d87d2, Swift 291fe21)
- Xcode version info: Xcode 15.0 beta (15A5160n)
- Deployment target: x86_64-apple-macosx13.0
Additional context
Xcode generated autocompletion like this:
init(underlying: repeat Array<each T>) {
self.underlying = underlying
}
Which results in a compilation error:
error: cannot assign value of type 'Array<each T>' to type '(repeat Array<each T>)'
self.underlying = underlying
^~~~~~~~~~