Skip to content

An associatedtype for a constrained derived protocol's associatedtype crashes the compiler. #75591

Open
@JessyCatterwaul

Description

@JessyCatterwaul

Description

Sorry, I'm having a hard time coming up with a good title for this. Here's the simplest example I've been able to create:

Reproduction

protocol FloatingPointScalar: SIMDScalar & BinaryFloatingPoint & Codable {
  associatedtype Matrix2x2: Matrix2x2Protocol
}

protocol FloatingPointVector: SIMD where Scalar: FloatingPointScalar {
  // Uncomment this to crash the compiler.
//  associatedtype Matrix2
}

extension SIMD2: FloatingPointVector where Scalar: FloatingPointScalar {
  typealias Matrix2 = Scalar.Matrix2x2
}

protocol SquareMatrix {
  associatedtype Scalar
  associatedtype Vector: FloatingPointVector
}

protocol Matrix2x2Protocol: SquareMatrix where Vector == SIMD2<Scalar> {
//   I want to use `Vector.Matrix2` here.
//  static var test: Vector.Matrix2 { get }
}

Stack dump

Command SwiftCompile failed with a nonzero exit code

Expected behavior

I can use that associatedtype Matrix2.

Environment

swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-macosx14.0

Additional information

Here's the real use case:

https://github.com/Catterwaul/SIMDson/tree/main/Sources/FloatingPoint/Matrix

Metadata

Metadata

Assignees

Labels

assertion failureBug → crash: An assertion failureassociatedtypeFeature → declarations → protocol: `associatedtype` declarationsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaregenericsFeature: generic declarations and typesprotocolFeature → type declarations: Protocol declarationsswift 6.0type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions