-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software
Description
Previous ID | SR-10441 |
Radar | None |
Original Reporter | @theblixguy |
Type | Bug |
Environment
Swift 5.1 (near master), macOS 10.14.4
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, CompilerCrash |
Assignee | None |
Priority | Medium |
md5: fe28a105cf1569245add499d28117e10
Issue Description:
This code causes a crash in the demangler:
protocol Foo {
associatedtype ErrorType: Error
}
extension Array: Error where Element: Error {}
class Bar<A: Foo> {
func doSomething(with result: Result<Any, [A.ErrorType]>) {}
}
Assertion failed: (false && "cannot add child"), function addChild, file /Users/suyashsrijan/Documents/swift-src/swift/lib/Demangling/Demangler.cpp, line 355
Removing the where clause on the Array extension fixes the crash. The following code also leads to a crash, however it happens in the ASTMangler when calling `swift::Mangle::ASTMangler::getSpecialManglingContext()`:
extension Array: Error where Element: Error {}
class Bar {
func doSomething(with result: Result<Any, [Error]>) {}
}
Assertion failed: (is<T>() && "Invalid accessor called"), function get, file /Users/suyashsrijan/Documents/swift-src/llvm/include/llvm/ADT/PointerUnion.h, line 136.
I think this has to do with passing an Array<Error> to the Result type and adding the constrained extension on Array.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of software