Open
Description
Describe the bug
protocol P {
associatedtype A
func getA() -> A
}
struct S<T: P> {
var s: T
}
func openSesame(_ p: some P) -> S<some P> {
S(s: p)
}
func test(_ p: any P) {
let x = openSesame(p)
// print(x)
}
Unhandled coercion
UNREACHABLE executed at /home/build-user/swift/lib/Sema/CSApply.cpp:7219!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/swift-nightly/usr/bin/swift-frontend -frontend -S -primary-file <source> -target x86_64-unknown-linux-gnu -disable-objc-interop -g -new-driver-path /opt/compiler-explorer/swift-nightly/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /opt/compiler-explorer/swift-nightly/usr/lib/swift -enable-anonymous-context-mangled-names -Xllvm --x86-asm-syntax=intel -module-name output -o /app/output.s
1. Swift version 5.8-dev (LLVM befe8168eb51210, Swift 0daa5584f4a2471)
2. Compiling with the current language version
3. While evaluating request TypeCheckSourceFileRequest(source_file "<source>")
4. While evaluating request TypeCheckFunctionBodyRequest(output.(file).testOpenSimple(p:)@<source>:14:6)
5. While type-checking statement at [<source>:14:31 - line:19:1] RangeText="{
let x = openSesame(p)
// print(x)
"
6. While type-checking declaration 0xa816bf0 (at <source>:16:3)
7. While evaluating request PatternBindingEntryRequest((unknown decl), 0, 0)
8. While type-checking expression at [<source>:16:11 - line:16:23] RangeText="openSesame(p"
9. While type-checking-target starting at <source>:16:11
To Reproduce
Environment (please complete the following information):
- Swift version 5.8-dev (LLVM befe8168eb51210, Swift 0daa558)
- OS: Linux
Metadata
Metadata
Assignees
Labels
Bug → crash: An assertion failureA deviation from expected or documented behavior. Also: expected but undesirable behavior.The Swift compiler itselfBug: A crash, i.e., an abnormal termination of softwareFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: expressionsFeature: generic declarations and typesFeature → existentials: implicit opening of existentials when passed to parameters of generic typeFeature → types → opaque types: opaque result typesFeature → types: opaque typesArea → compiler: Semantic analysisFeature: types