Text of github.com › swiftlang › swift › issues › 55536 as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

[SR-13090] Runtime crash when conforming to unavailable protocol (Identifiable) · Issue #55536 · swiftlang/swift · GitHub

Skip to content You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert [SR-13090] Runtime crash when conforming to unavailable protocol (Identifiable) #55536 New issue Copy link New issue Copy link Closed Closed [SR-13090] Runtime crash when conforming to unavailable protocol (Identifiable) #55536 Copy link Labels bug A deviation from expected or documented behavior.

Also: expected but undesirable behavior. A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself The Swift compiler itself type checker Area → compiler: Semantic analysis Area → compiler: Semantic analysis Description robmaceachern opened on Jun 26, 2020 Issue body actions Previous ID SR-13090 Radar rdar://problem/64953120 Original Reporter @robmaceachern Type Bug Status Resolved Resolution Done Attachment: Download Environment Xcode 11.5 and Xcode 12 beta 1 Swift 5.1 and 5.3 Additional Detail from JIRA Votes 1 Component/s Compiler Labels Bug, TypeChecker Assignee None Priority Medium md5: fb7f8d30c8452a22e9ddddbf84515984 Issue Description: It's possible to build and run code (without warnings) where a type conforms to a protocol that isn't available for a deployment target which then crashes at runtime.

My example uses an `Identifiable` conformance in an app with an iOS 12 deployment target. It seems like the line `struct Store<T> where T: Animal` should be generating a compile error like: `'Animal' is only available in iOS 13 or newer`. Edit : See sample project. Couldn't get code formatted properly. The app crashes when run on the iOS 12 simulator. Activity typesanitizer commented on Jun 26, 2020 typesanitizer on Jun 26, 2020 More actions Confirming that I can reproduce using an iPhone 8 Plus iOS 12.4 simulator + Xcode 12 beta 1 toolchain.

With a master compiler + Xcode 12 beta 1, lldb itself crashes. @swift-ci create theblixguy commented on Jul 15, 2020 theblixguy on Jul 15, 2020 Member More actions Looks like the compiler isn't checking for availability in certain contexts. Here's an example that doesn't rely on a stdlib protocol. // Xcode 12 beta 1 // Deployment target: iOS 14 // ------------------------------------- @ available ( iOS 15 . 0 , * ) protocol Foo { } class A : Foo { } // This doesn't trigger an error class B { } extension B : Foo { } // No error class C { let foo : Foo ! // 'Foo' is only available in iOS 15.0 or newer init ( ) { fatalError ( ) } } let a1 = A ( ) // No error let a2 : Foo = A ( ) // ''Foo' is only available in iOS 15.0 or newer' func foo1 < T : Foo > ( ) -> T { fatalError ( ) } // ''Foo' is only available in iOS 15.0 or newer' func foo2 ( arg : Foo ) { fatalError ( ) } // ''Foo' is only available in iOS 15.0 or newer' I suppose this is fine because the error is eventually trigger later on (such as in the a2: Foo case).

It looks like this is one scenario where it doesn't trigger: @ available ( iOS 15 , * ) protocol P { var foo : Int { get } } protocol Q : P { } struct S : Q { let foo = 0 } class C < T : Q > { } let s = C < S > ( ) theblixguy commented on Jul 15, 2020 theblixguy on Jul 15, 2020 Member More actions I did a little bit of research and found this comment here : // We allow a type to conform to a protocol that is less available than // the type itself.

This enables a type to retroactively model or directly // conform to a protocol only available on newer OSes and yet still be used on // older OSes. // To support this, inside inheritance clauses we allow references to // protocols that are unavailable in the current type refinement context. slavapestov commented on Feb 25, 2022 slavapestov on Feb 25, 2022 Contributor More actions Swift 5.5 checks conformance availability. swift-ci transferred this issue from apple/swift-issues on Apr 25, 2022 Sign up for free to join this conversation on GitHub.

Already have an account? Sign in to comment Metadata Metadata Assignees No one assigned Labels bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself The Swift compiler itself type checker Area → compiler: Semantic analysis Area → compiler: Semantic analysis Type No type Projects No projects Milestone No milestone Relationships None yet Development No branches or pull requests Issue actions You can’t perform that action at this time.