Compiler exception when using Binding and Swift 6

In my code I use a binding that use 2 methods to get and get a value. There is no problem with swift 5 but when I swift to swift 6 the compiler fails : Here a sample example of code to reproduce the problem : `import SwiftUI

struct ContentView: View { @State private var isOn = false

var body: some View {
    VStack {
        Image(systemName: "globe")
            .imageScale(.large)
            .foregroundStyle(.tint)
        Text("Hello, world!")
        Toggle("change it", isOn: Binding(get: getValue, set: setValue(_:)))
    }
    .padding()
}

private func getValue() -> Bool {
    isOn
}

private func setValue(_ value: Bool) {
    isOn = value
}

}`

Xcode compiler log error : 1. Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5) 2. Compiling with the current language version 3. While evaluating request IRGenRequest(IR Generation for file "/Users/xavierrouet/Developer/TestCompilBindingSwift6/TestCompilBindingSwift6/ContentView.swift") 4. While emitting IR SIL function "@$sSbScA_pSgIeAghyg_SbIeAghn_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 0x000000010910ae24 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56 1 swift-frontend 0x0000000109108c5c llvm::sys::RunSignalHandlers() + 112 2 swift-frontend 0x000000010910b460 SignalHandler(int) + 360 3 libsystem_platform.dylib 0x0000000188e60624 _sigtramp + 56 4 libsystem_pthread.dylib 0x0000000188e2688c pthread_kill + 296 5 libsystem_c.dylib 0x0000000188d2fc60 abort + 124 6 swift-frontend 0x00000001032ff9a8 swift::DiagnosticHelper::~DiagnosticHelper() + 0 7 swift-frontend 0x000000010907a878 llvm::report_fatal_error(llvm::Twine const&, bool) + 280 8 swift-frontend 0x00000001090aef6c report_at_maximum_capacity(unsigned long) + 0 9 swift-frontend 0x00000001090aec7c llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) + 384 10 swift-frontend 0x000000010339c418 (anonymous namespace)::SyncCallEmission::setArgs(swift::irgen::Explosion&, bool, swift::irgen::WitnessMetadata*) + 892 11 swift-frontend 0x00000001035f8104 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 4792 12 swift-frontend 0x00000001035c876c (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2636 13 swift-frontend 0x00000001035c6614 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 15860 14 swift-frontend 0x00000001035c2368 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2788 15 swift-frontend 0x00000001033e7c1c swift::irgen::IRGenerator::emitLazyDefinitions() + 5288 16 swift-frontend 0x0000000103573d6c swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 4528 17 swift-frontend 0x00000001035c15c4 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 180 18 swift-frontend 0x000000010357d1b0 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 812 19 swift-frontend 0x0000000103576910 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 176 20 swift-frontend 0x0000000102f61af0 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156 21 swift-frontend 0x0000000102f5d07c 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*) + 2108 22 swift-frontend 0x0000000102f5c0a8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1036 23 swift-frontend 0x0000000102f5f654 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764 24 swift-frontend 0x0000000102f5dfd8 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3716 25 swift-frontend 0x0000000102ee20bc swift::mainEntry(int, char const**) + 5428 26 dyld 0x0000000188a86b98 start + 6076

Using Xcode 16.4 / Mac OS 16.4

Answered by DTS Engineer in 851916022

Right.

In general the compiler should not crash. No matter what you throw at it, it should either work or emit a helpful error. So, this sort of crash is, by definition, bugworthy.

Bug Reporting: How and Why? has lots of hints and tips about how to file effective bug reports. In this case, I have some specific recommendations:

  • Test with the current Xcode 26 beta. Swift moves forward quickly, so it’s possible that this bug is already fixed there.
  • If it still crashes, try to isolate the problem into a small test project and attach that to your bug report. That’ll greatly assist with the investigation.
  • If you can’t isolate it, you might consider adding your entire project to the bug report, or uploading it to a public repository and adding that URL. I understand, however, that this isn’t always possible.
  • Make sure you include a full build log with your bug report. For advice on how to get that, see Command [something] failed with a nonzero exit code.

And, as to reiterate darkpaw’s note, please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Have you raised a Feedback report? If not, please do so at https://feedbackassistant.apple.com/ then post the FB number here.

Right.

In general the compiler should not crash. No matter what you throw at it, it should either work or emit a helpful error. So, this sort of crash is, by definition, bugworthy.

Bug Reporting: How and Why? has lots of hints and tips about how to file effective bug reports. In this case, I have some specific recommendations:

  • Test with the current Xcode 26 beta. Swift moves forward quickly, so it’s possible that this bug is already fixed there.
  • If it still crashes, try to isolate the problem into a small test project and attach that to your bug report. That’ll greatly assist with the investigation.
  • If you can’t isolate it, you might consider adding your entire project to the bug report, or uploading it to a public repository and adding that URL. I understand, however, that this isn’t always possible.
  • Make sure you include a full build log with your bug report. For advice on how to get that, see Command [something] failed with a nonzero exit code.

And, as to reiterate darkpaw’s note, please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Feedback filled : FB19371948

Compiler exception when using Binding and Swift 6
 
 
Q