[swift] expressionValueWithObject(_ object, context:context) crashes
| Originator: | cacaodev | ||
| Number: | rdar://23937671 | Date Originated: | 17-Dec-2015 02:50 PM |
| Status: | Open | Resolved: | No |
| Product: | OS X | Product Version: | 10.11.2 |
| Classification: | No Value | Reproducible: | YES |
Summary:
When the expected return value is nil, a call to expressionValueWithObject will crash the program at execution time.
Steps to Reproduce:
1. Open Xcode playground
2. Type NSExpression(forKeyPath: "keyNotFound").expressionValueWithObject(["key":"value"], context: nil)
OR NSExpression(forConstantValue:nil).expressionValueWithObject("object", context: nil)
Expected Results:
In Objective-C, no error and the return value is nil.
We could expect a different value in swift (NSNull() for exemple) but it should not crash and should be documented.
Actual Results:
Crashes with an error EXEC_BAD_ACCESS reported.
Version:
10.10.5 / 14F27
Notes:
In Yosemite and El Capitan, NSExpression header reveal it as been audited for swift. The method -expressionValueWithObject:context: is inside a NS_ASSUME_NON_NULL block. I believe the return value should be marked as nullable.
Configuration:
MacBook Intel 2009
OS 10.10.5
Xcode 7.2
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!