Skip to content

SIL verification failure during optimization with generic constraints and associated type equality #84419

@csknns

Description

@csknns

Description

The compiler crashes when building with optimizations code having generic constraints and associated type equality

Reproduction

build with optimizations -O

struct a < b : RangeReplaceableCollection where b == Int {
    let c
}

Stack dump

CombinedZip2.swift:1:58: error: expected '>' to complete generic parameter list
1 | struct a < b : RangeReplaceableCollection where b == Int {
  |          |                                               `- error: expected '>' to complete generic parameter list
  |          `- note: to match this opening '<'
2 |     let c
3 | }

CombinedZip2.swift:1:43: error: 'where' clause next to generic parameters is obsolete, must be written following the declaration's type
1 | struct a < b : RangeReplaceableCollection where b == Int {
  |                                           `- error: 'where' clause next to generic parameters is obsolete, must be written following the declaration's type
2 |     let c
3 | }

CombinedZip2.swift:1:8: error: no type for 'b' can satisfy both 'b == Int' and 'b : RangeReplaceableCollection'
1 | struct a < b : RangeReplaceableCollection where b == Int {
  |        `- error: no type for 'b' can satisfy both 'b == Int' and 'b : RangeReplaceableCollection'
2 |     let c
3 | }

CombinedZip2.swift:1:8: error: no type for 'b' can satisfy both 'b == Int' and 'b : Collection'
1 | struct a < b : RangeReplaceableCollection where b == Int {
  |        `- error: no type for 'b' can satisfy both 'b == Int' and 'b : Collection'
2 |     let c
3 | }

CombinedZip2.swift:1:8: error: no type for 'b' can satisfy both 'b == Int' and 'b : Sequence'
1 | struct a < b : RangeReplaceableCollection where b == Int {
  |        `- error: no type for 'b' can satisfy both 'b == Int' and 'b : Sequence'
2 |     let c
3 | }

CombinedZip2.swift:1:8: warning: same-type requirement makes generic parameter 'b' non-generic; this is an error in the Swift 6 language mode
1 | struct a < b : RangeReplaceableCollection where b == Int {
  |        `- warning: same-type requirement makes generic parameter 'b' non-generic; this is an error in the Swift 6 language mode
2 |     let c
3 | }

Abstract conformance with bad subject type:
(struct_type decl="Swift.(file).Int")
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file CombinedZip2.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -color-diagnostics -Xcc -fcolor-diagnostics -O -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name CombinedZip2 -in-process-plugin-server-path /Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.5 -target-sdk-name macosx15.5 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -enable-default-cmo -o CombinedZip2.o
1.	Apple Swift version 6.2 (swift-6.2-RELEASE)
2.	Compiling with effective version 5.10
3.	While evaluating request TypeCheckPrimaryFileRequest(source_file "CombinedZip2.swift")
4.	While evaluating request TypeCheckFunctionBodyRequest(CombinedZip2.(file).a._@CombinedZip2.swift:2:9)
5.	While evaluating request ParseAbstractFunctionBodyRequest(CombinedZip2.(file).a._@CombinedZip2.swift:2:9)
 #0 0x0000000105b60f18 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1059dcf18)
 #1 0x0000000105b5f644 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1059db644)
 #2 0x0000000105b61560 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1059dd560)
 #3 0x0000000182c556a4 (/usr/lib/system/libsystem_platform.dylib+0x1804ad6a4)
 #4 0x0000000182c1b88c (/usr/lib/system/libsystem_pthread.dylib+0x18047388c)
 #5 0x0000000182b24a3c (/usr/lib/system/libsystem_c.dylib+0x18037ca3c)
 #6 0x0000000105bd90fc (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x105a550fc)
 #7 0x0000000101882938 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1016fe938)
 #8 0x0000000101c2c96c (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x101aa896c)
 #9 0x0000000101bf59a8 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x101a719a8)
#10 0x0000000101bf5738 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x101a71738)
#11 0x0000000101bf54ec (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x101a714ec)
#12 0x0000000101adb0b8 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1019570b8)
#13 0x00000001016741b8 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1014f01b8)
#14 0x00000001016787d4 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1014f47d4)
#15 0x00000001017d53dc (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1016513dc)
#16 0x0000000101a5af70 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1018d6f70)
#17 0x0000000101a5ad70 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1018d6d70)
#18 0x00000001019d42f0 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1018502f0)
#19 0x00000001019d3f1c (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10184ff1c)
#20 0x0000000101661598 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1014dd598)
#21 0x0000000101a5c220 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1018d8220)
#22 0x00000001019d442c (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10185042c)
#23 0x0000000101b0623c (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10198223c)
#24 0x00000001016aafa8 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x101526fa8)
#25 0x00000001016ac80c (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10152880c)
#26 0x00000001016aae8c (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x101526e8c)
#27 0x0000000100662904 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1004de904)
#28 0x00000001006599f0 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1004d59f0)
#29 0x0000000100659984 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1004d5984)
#30 0x0000000100424d60 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002a0d60)
#31 0x000000010041a3fc (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002963fc)
#32 0x0000000100419bb8 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100295bb8)
#33 0x00000001001bd6b4 (/Users/christoskoninis/Library/Developer/Toolchains/swift-6.2-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1000396b4)
#34 0x000000018287ab98

Expected behavior

The compiler build should succeed

Environment

Apple Swift version 6.2 (swift-6.2-RELEASE)
Target: arm64-apple-macosx15.0
Build config: +assertions

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions