Skip to content

Swift Compiler Crash with sharing-grdb 0.5.0 and Swift 6.1.2 #82529

Open
@doozMen

Description

@doozMen

Description

Summary

The Swift compiler crashes with a signal 6 assertion failure when building a project that uses sharing-grdb 0.5.0 with Swift 6.1.2. The crash occurs during the compilation of StructuredQueriesCore's QueryBindable.swift file.

Environment

  • Swift Version: 6.1.2-RELEASE
  • Xcode Version: Swift toolchain swift-6.1.2-RELEASE.xctoolchain
  • Platform: macOS (darwin)
  • sharing-grdb Version: 0.5.0
  • GRDB Version: 7.5.0 (transitive dependency)

Steps to Reproduce

  1. Create a new Swift package with the following Package.swift:
// swift-tools-version: 6.1
import PackageDescription

let package = Package(
    name: "timestory-mcp",
    platforms: [
        .macOS(.v15)
    ],
    dependencies: [
        .package(url: "https://github.com/pointfreeco/sharing-grdb.git", from: "0.5.0"),
    ],
    targets: [
        .executableTarget(
            name: "timestory-mcp",
            dependencies: [
                .product(name: "SharingGRDB", package: "sharing-grdb"),
            ]
        ),
    ]
)
  1. Create a model using the @table macro:
import Foundation
import SharingGRDB
import GRDB

@Table("timesheets")
struct Timesheet: Codable, FetchableRecord, PersistableRecord {
    var id: String
    var date: Date
    // ... other properties
}
  1. Run swift build

Expected Behavior

The project should compile successfully.

Actual Behavior

The compiler crashes with the following assertion failure:

error: compile command failed due to signal 6 (use -v to see invocation)
Assertion failed: ((path.size() == 1 && path[0].getKind() == ConstraintLocator::SubscriptMember) || (path.size() == 2 && path[1].getKind() == ConstraintLocator::KeyPathDynamicMember)), function addKeyPathApplicationRootConstraint, file CSSimplify.cpp, line 15827.

Crash Details

Stack Trace (Abbreviated)

Stack dump:
0.	Program arguments: /Users/.../swift-6.1.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c 
    [...]/StructuredQueriesCore/QueryBindable.swift
1.	Swift version 6.1.2-dev
2.	Compiling with effective language version 6.0
3.	While evaluating request TypeCheckSourceFileRequest
4.	While evaluating request TypeCheckFunctionBodyRequest
5.	While type-checking statement
6.	While type-checking expression
7.	While type-checking-target starting at QueryBindable.swift:204:5

Full Error Location

The crash occurs while compiling:

  • File: .build/checkouts/swift-structured-queries/Sources/StructuredQueriesCore/QueryBindable.swift
  • During primary file compilation of multiple StructuredQueriesCore files

Assertion Details

  • File: CSSimplify.cpp
  • Line: 15827
  • Function: addKeyPathApplicationRootConstraint
  • Assertion: Path validation for ConstraintLocator

The error specifically occurs when compiling:

  • /Sources/StructuredQueriesCore/PrimaryKeyed.swift
  • At line 28-30 during type checking of TableDraft extension

Workaround

Reverting to plain GRDB without sharing-grdb allows the project to compile successfully:

dependencies: [
    .package(url: "https://github.com/groue/GRDB.swift.git", from: "7.0.0"),
],

Additional Context

  • The crash appears to be related to the swift-structured-queries dependency that sharing-grdb uses
  • The issue occurs specifically with Swift 6.1.2; compatibility with earlier Swift versions has not been tested
  • The crash happens during constraint solving in the type checker, suggesting it may be related to complex generic constraints or type inference
  • When building with xcodebuild (Xcode 16.4, Build version 16F6), it reports: error: Macro "StructuredQueriesMacros" from package "swift-structured-queries" must be enabled before it can be used

Related Issues

This may be related to other Swift 6.x compatibility issues with complex generic code or macro expansions.

Reproduction

clone https://github.com/pointfreeco/sharing-grdb
run swift test
I uses swiftly with 6.0,1.2 .. all of them and 6.2-snapshot

Expected behavior

xcodebuild has same error but xcode itself can build and run tests 🤯

Environment

swiftly installed 6.1.2 and 6.2-snapshot

Apple Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: arm64-apple-macosx15.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.type checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions