I'm seeing a weird issue while using result builders.
I've narrowed it down to an almost canonical implementation but the crash is still there:
public protocol Widget {
associatedtype Root
}
public protocol WidgetPanel {
associatedtype W: Widget
@WidgetBuilder var widget: W { get }
}
public struct SliderWidget<Root, Value: FloatingPoint>: Widget {
public let keyPath: KeyPath<Root, Value>
}
@resultBuilder
enum WidgetBuilder {
static func buildBlock<W1: Widget>(_ w1: W1) -> some Widget {
w1
}
}
class SomeModel {
let progress: Double = 0
var widget: some Widget {
SliderWidget(keyPath: \Self.progress)
}
}
The stack trace is not much, at least for an untrained eye:
1. Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
2.
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 0x0000000104aaf9c4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x0000000104aaeacc llvm::sys::RunSignalHandlers() + 128
2 swift-frontend 0x0000000104ab0004 SignalHandler(int) + 292
3 libsystem_platform.dylib 0x0000000197b084e4 _sigtramp + 56
4 swift-frontend 0x0000000102d92af0 llvm::ValueEnumerator::ValueEnumerator(llvm::Module const&, bool) + 4200
5 swift-frontend 0x0000000102d6fba4 (anonymous namespace)::ModuleBitcodeWriterBase::ModuleBitcodeWriterBase(llvm::Module const&, llvm::StringTableBuilder&, llvm::BitstreamWriter&, bool, llvm::ModuleSummaryIndex const*) + 60
6 swift-frontend 0x0000000102d6444c llvm::BitcodeWriter::writeModule(llvm::Module const&, bool, llvm::ModuleSummaryIndex const*, bool, std::__1::array<unsigned int, 5ul>*) + 272
7 swift-frontend 0x0000000102d6d214 llvm::WriteBitcodeToFile(llvm::Module const&, llvm::raw_ostream&, bool, llvm::ModuleSummaryIndex const*, bool, std::__1::array<unsigned int, 5ul>*) + 468
8 swift-frontend 0x0000000100c6b5dc swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 172
9 swift-frontend 0x000000010082e414 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 3184
10 swift-frontend 0x0000000100821574 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6520
11 swift-frontend 0x000000010077adf8 main + 932
12 dyld 0x0000000106ea10f4 start + 520
error: Segmentation fault: 11 (in target 'ResultBuilder' from project 'ResultBuilder')
Does anyone know what might be the cause of this? Or even better, workarounds?
I'd be happy to file a bug if it's not already filled.