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-5036] Segfault using KeyPath with NSObject #47612
Comments
This seems like it might be an issue with bridged types. If I use an import Foundation
class A: NSObject {
let b: Int
init(b: Int) {
self.b = b
}
}
let a = A(b: 5)
// This prints 7310525559249068368 when A is an NSObject.
// Remove inheritance from NSObject and it correctly prints 5.
print(a[keyPath: \A.b]) |
@swift-ci create |
@jckarter is this in Xcode beta 3? Because I have a similar crasher when using the older #keyPath(…) with NSObject subclasses. (If the keypath is 'malformed' and contains `Self` for example) Without NSObject inheritance, I get a correct compiler error about the mistake – with it only a segfault. I can open a new bugreport if you like for it. // Remove NSObject inheritance and it doesn't crash
class Muppet: NSObject {
var identifier: String = "Kermit"
static func predicateForIdentifier(_ id: String) -> NSPredicate {
return NSPredicate(format: "%K = %@", #keyPath(Self.identifier), id)
}
} |
The string-based #keyPath syntax is unrelated. You should file another bug. |
There you go SR-5454 |
This should be fixed in the 4.0 branch now. |
Verified with Xcode 9.0.0 ß5. |
Environment
macOS 10.12.5
Swift Development Snapshot 5/27/17 (org.swift.3020170527a)
Additional Detail from JIRA
md5: 1f1bde21728e8936374b59d119c4e7b8
Issue Description:
crashes with
If
A
doesn't inherit fromNSObject
, then this works as expected.The text was updated successfully, but these errors were encountered: