New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-10146] Segmentation fault for AnyObject keypath #52548
Comments
Sorry, but could you provide the full code that leads to a crash or a reduced example code that leads to the same crash? The above code does not crash for me on 4.2 and 5.1. |
Add test project which leads to a crash in attachments |
Hmm this is very strange - we are emitting SIL for a keypath that is not valid? This should actually be getting diagnosed. I am having trouble while debugging this (seems like this is specific to UIKit/AppDelegate but I am trying to figure out a way to compile this on the Mac), but in the meantime, maybe @jckarter has some clue as to why there's a crash here. |
For me this crash also reproducible in playgrounds |
Could you post the code that crashes for you in the playgrounds? |
Add playground and crash log |
Ooops. I don't think we ever intended to support key paths through AnyObject, since they represent arbitrary Objective-C messages rather than a specific property declaration. Joe? |
Here's a reduced test case that also causes a crash: import Foundation
class Foo: NSObject {
@objc let bar: Int = 0
}
class Bar: Foo {
func crash() {
let keyPath = \AnyObject.bar
}
} The crash is in SILVerifier instead: SIL verification failed: keypath value type should match value type of keypath pattern: leafTy == pattern->getValueType().subst(patternSubs)->getCanonicalType() I have a fix for this, I'll create a PR shortly. |
Here's a fix: #23497 |
Resolved on master by PR #23820 and also cherry-picked to the 5.1 branch. |
Attachment: Download
Environment
Swift 5 Xcode 10.2 beta 4 (10P107d). Swift 4.2 Xcode 10.1
Additional Detail from JIRA
md5: 1bc5e45397b672fb1fa208066a1fd75a
Issue Description:
Segfault for this code:
The text was updated successfully, but these errors were encountered: