Skip to content

[SR-4555] Crash bridging objective-c dictionary when it contains NSErrors as the values #47132

Open
@swift-ci

Description

@swift-ci
Previous ID SR-4555
Radar None
Original Reporter tourultimate (JIRA User)
Type Bug
Environment

compiled on: macOS 10.12
run on: macOS 10.12
swift version: Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
xcode 8.2.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: 696d775b055c54e1feffaf4a1fcc4cfc

Issue Description:

Consider the following objective-c object:

```
NS_ASSUME_NONNULL_BEGIN
@interface BusinessObject : NSObject
@Property (nonatomic, copy, readonly) NSDictionary <NSNumber , NSError> *errorsDictionary;
@EnD
NS_ASSUME_NONNULL_END

#import "BusinessObject.h"
@implementation BusinessObject
-(NSDictionary<NSNumber *,NSError *> *)errorsDictionary{
NSError *error = [NSError errorWithDomain:@"blah" code:1234 userInfo:nil];
return @{@(1): error};
}
@EnD
```

When using this in swift like so:

```
let b = BusinessObject()
let errorsDictionary = b.errorsDictionary;
print("errorsDictionary: (errorsDictionary)")
```

you will get a crash with the following stack trace:

```

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during execution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions