Compiler crash

How to fix this crash?
this bug has been reported for long time ago. please check here https://bugs.swift.org/browse/SR-12736

I notice that different versions of swift have different behaviors.
latest-xxxx is the newest swift-5.4 docker images, and nightly-xxxx stand for master snapshots.

3. While evaluating request TypeCheckSourceFileRequest(source_file "/__w/Doggie/Doggie/Sources/DoggieGraphics/Color/Color.swift")

[519](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:519)4. While evaluating request TypeCheckFunctionBodyRequest(DoggieGraphics.(file).Color extension._@/__w/Doggie/Doggie/Sources/DoggieGraphics/Color/Color.swift:443:45)

[520](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:520)5. While type-checking statement at [/__w/Doggie/Doggie/Sources/DoggieGraphics/Color/Color.swift:443:45 - line:445:5] RangeText="{

[521](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:521) return Color<XYZColorModel>(colorSpace: colorSpace.cieXYZ, color: colorSpace.convertToXYZ(color), opacity: opacity)

[522](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:522) "

[523](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:523)6. While type-checking statement at [/__w/Doggie/Doggie/Sources/DoggieGraphics/Color/Color.swift:444:9 - line:444:123] RangeText="return Color<XYZColorModel>(colorSpace: colorSpace.cieXYZ, color: colorSpace.convertToXYZ(color), opacity: opacity"

[524](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:524)7. While type-checking expression at [/__w/Doggie/Doggie/Sources/DoggieGraphics/Color/Color.swift:444:16 - line:444:123] RangeText="Color<XYZColorModel>(colorSpace: colorSpace.cieXYZ, color: colorSpace.convertToXYZ(color), opacity: opacity"

[525](https://github.com/SusanDoggie/Doggie/runs/2481110351?check_suite_focus=true#step:7:525)8. While canonicalizing generic signature <τ_0_0, τ_1_0, τ_1_1 where τ_0_0 == τ_1_0.Model, τ_1_0 : ColorPixel, τ_1_1 : ColorPixel, τ_0_0.Float16Components == τ_1_0.Model.Float16Components.Model.Float16Components, τ_1_1.Model == XYZColorModel> in requirement #3

And this bug is still exists for the latest Xcode 12.5: https://bugs.swift.org/browse/SR-10532

I have minimized the code.

This code compile successful with macOS (Xcode 12.5 or SwiftPM), but not with linux swift 5.4.

public protocol ColorModel {
    
    associatedtype Float32Components: ColorComponents where Float32Components.Model == Self, Float32Components.Scalar == Float
    
    init<T: ColorComponents>(_ components: T) where T.Model == Self
    
    var float32Components: Float32Components { get set }
}

public protocol ColorComponents {
    
    associatedtype Model: ColorModel
    
    associatedtype Scalar
    
}

public protocol ColorPixel {
    
    associatedtype Model: ColorModel
    
    init(color: Model, opacity: Double)
    
    init<C: ColorPixel>(_ color: C) where Model == C.Model
}

Swift 5.4 linux throws following error:

swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-5.4-package-linux-ubuntu-18_04/swift/lib/AST/GenericSignature.cpp:251: static swift::CanGenericSignature swift::CanGenericSignature::getCanonical(TypeArrayView<swift::GenericTypeParamType>, ArrayRef<swift::Requirement>, bool): Assertion `isCanonicalAnchor(secondType)' failed.

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.

Stack dump:

0. Program arguments: /usr/bin/swift-frontend -frontend -interpret /test/test.swift -disable-objc-interop -color-diagnostics -module-name test

1. Swift version 5.4 (swift-5.4-RELEASE)

2. While evaluating request TypeCheckSourceFileRequest(source_file "/test/test.swift")

3. While type-checking 'ColorPixel' (at /test/test.swift:19:8)

4. While type-checking 'init(_:)' (at /test/test.swift:25:5)

5. While evaluating request InterfaceTypeRequest(test.(file).ColorPixel.init(_:)@/test/test.swift:25:5)

6. While canonicalizing generic signature <τ_0_0, τ_1_0 where τ_0_0 : ColorPixel, τ_1_0 : ColorPixel, τ_0_0.Model == τ_1_0.Model, τ_0_0.Model.Float32Components == τ_1_0.Model.Float32Components.Model.Float32Components> in requirement #3

/usr/bin/swift-frontend[0x5805744]

/usr/bin/swift-frontend[0x58031de]

/usr/bin/swift-frontend[0x580592c]

/lib/x86_64-linux-gnu/libpthread.so.0(+0x12980)[0x4000a45980]

/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7)[0x400202dfb7]

/lib/x86_64-linux-gnu/libc.so.6(abort+0x141)[0x400202f921]

/lib/x86_64-linux-gnu/libc.so.6(+0x3048a)[0x400201f48a]

/lib/x86_64-linux-gnu/libc.so.6(+0x30502)[0x400201f502]

/usr/bin/swift-frontend[0x1b31455]

/usr/bin/swift-frontend[0x1b306ad]

/usr/bin/swift-frontend[0x1b30674]

/usr/bin/swift-frontend[0x194ab71]

/usr/bin/swift-frontend[0x14ceda3]

/usr/bin/swift-frontend[0x1a60e59]

/usr/bin/swift-frontend[0x1a60ba9]

/usr/bin/swift-frontend[0x1a132d1]

/usr/bin/swift-frontend[0x1a06941]

/usr/bin/swift-frontend[0x14f6bd0]

/usr/bin/swift-frontend[0x14f62f1]

/usr/bin/swift-frontend[0x14f718b]

/usr/bin/swift-frontend[0x14f62f1]

/usr/bin/swift-frontend[0x14f6221]

/usr/bin/swift-frontend[0x15b7215]

/usr/bin/swift-frontend[0x15b844e]

/usr/bin/swift-frontend[0x15b81b5]

/usr/bin/swift-frontend[0x15b6f9e]

/usr/bin/swift-frontend[0x15b6f74]

/usr/bin/swift-frontend[0x6a0e04]

/usr/bin/swift-frontend[0x6a0c96]

/usr/bin/swift-frontend[0x510693]

/usr/bin/swift-frontend[0x49be53]

/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0x4002010bf7]

/usr/bin/swift-frontend[0x49b96a]
Terms of Service

Privacy Policy

Cookie Policy