Hi,
Am I the only one to have the following 8 lines file make the Swift 6.1 compiler crash?
import Foundation
import SwiftData
@Model class Foo {
var date: Date?
init(date: Date?) {
self.date = date
}
}
Stack dump:
Stack dump:
0. Program arguments: /Applications/Xcode-16.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret test.swift -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-16.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk -color-diagnostics -new-driver-path /Applications/Xcode-16.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode-16.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name test -disable-clang-spi -target-sdk-version 15.4 -target-sdk-name macosx15.4 -external-plugin-path /Applications/Xcode-16.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-16.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-16.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-16.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -in-process-plugin-server-path /Applications/Xcode-16.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode-16.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode-16.3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins
1. Apple Swift version 6.1 (swiftlang-6.1.0.110.21 clang-1700.0.13.3)
2. Compiling with effective version 5.10
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
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 0x000000010afe6c28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x000000010afe4a60 llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x000000010afe7264 SignalHandler(int) + 360
3 libsystem_platform.dylib 0x00000001990b6de4 _sigtramp + 56
4 swift-frontend 0x00000001059f3404 swift::Lowering::SILGenTopLevel::TypeVisitor::visitPatternBindingDecl(swift::PatternBindingDecl*) + 180
5 swift-frontend 0x00000001059f3404 swift::Lowering::SILGenTopLevel::TypeVisitor::visitPatternBindingDecl(swift::PatternBindingDecl*) + 180
6 swift-frontend 0x00000001059f2604 swift::ASTVisitor<swift::Lowering::SILGenTopLevel, void, void, void, void, void, void>::visit(swift::Decl*) + 1168
7 swift-frontend 0x00000001059ef5b4 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*, swift::SILFunction*) + 1168
8 swift-frontend 0x00000001059f1f74 swift::Lowering::SILGenModule::emitEntryPoint(swift::SourceFile*) + 208
9 swift-frontend 0x00000001058a5998 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1380
10 swift-frontend 0x00000001059decc4 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
11 swift-frontend 0x00000001058aa5e0 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'()) + 728
12 swift-frontend 0x0000000104e386dc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2624
13 swift-frontend 0x0000000104e3be44 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3796
14 swift-frontend 0x0000000104e39fd8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3716
15 swift-frontend 0x0000000104dbe0bc swift::mainEntry(int, char const**) + 5428
16 dyld 0x0000000198d00274 start + 2840
fish: Job 1, 'swift test.swift' terminated by signal SIGSEGV (Address boundary error)
Any ideas how to work around it, or how to make sure it gets prioritized? That seems pretty bad to me that such any SwiftData model using optionals make the compiler crash.
I understand that discussions about SwiftData should probably be in the Apple Developers forums but it's a compiler crash so I thought here would be more suited.
I also created an issue on GitHub: Crash when building a simple SwiftData model with Swift 6.1 · Issue #81066 · swiftlang/swift · GitHub
Cheers