Skip to content
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-9397] Failed to demangle witness for associated type (CF_ENUM) #51863

Closed
swift-ci opened this issue Dec 2, 2018 · 4 comments
Closed

[SR-9397] Failed to demangle witness for associated type (CF_ENUM) #51863

swift-ci opened this issue Dec 2, 2018 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression runtime The Swift Runtime swift 5.0

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 2, 2018

Previous ID SR-9397
Radar rdar://46423275
Original Reporter swhitty (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 5.0Regression, Runtime
Assignee @DougGregor
Priority Medium

md5: 964a83a758ac083db82c1cca841cc98f

Issue Description:

The Swift 5 toolchain includes a regression that results in a runtime error;

failed to demangle witness for associated type ....
Abort trap: 6

This occurs when a generic type references a nested associated type that is a CF_ENUM / NS_ENUM from Foundation (or possibly another module??). The issue does not occur within Swift 4.2.

Consider the following;

protocol CommandTypes {
    associatedtype Result
    associatedtype Message
}

struct EnumCommand: CommandTypes {
    typealias Result = ComparisonResult
    typealias Message = String
}

struct Command<T: CommandTypes> {
    var result: T.Result?
    var message: T.Message?
}

❌In Swift 5, declaring an array which references an associated type of CF_ENUM results in abort Trap 6. e.g.

let _ = [Command<EnumCommand>]()

✅Declaring an array with other types is fine;

struct BasicCommand: CommandTypes {
    typealias Result = String
    typealias Message = String
}

let _ = [Command<BasicCommand>]()

✅One workaround is to access the CF_ENUM type at least once prior e.g.

let _ = [ComparisonResult.self] as [Any]
let _ = [Command<EnumCommand>]()
@belkadan
Copy link
Contributor

belkadan commented Dec 3, 2018

@mikeash, @DougGregor, @slavapestov, sound familiar?

@slavapestov
Copy link
Member

@swift-ci create

@DougGregor
Copy link
Member

The full error message is:

failed to demangle witness for associated type 'Result' in conformance 't2.EnumCommand: CommandTypes' from mangled name 'So18NSComparisonResultV' 

We're not emitting type metadata that we need to be able to find NSComparisonResult at run time.

@DougGregor
Copy link
Member

Fixed by #21007

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression runtime The Swift Runtime swift 5.0
Projects
None yet
Development

No branches or pull requests

5 participants