-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Copy link
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuestype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistypesFeature: typesFeature: types
Description
Describe the bug
This input makes the compiler crash:
protocol P<D> {
associatedtype D
}
struct T: P {
typealias D = Int
}
extension P where Self == T {
static var t: T { T() }
}
enum U {
static let p: any P<Int> = .t
}
I ran this command:
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-10-a.xctoolchain/usr/bin/swiftc -c t.swift
I got this output:
subtype conversion in MetatypeConversionExpr is invalid: P<Int> to T
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-10-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file t.swift -target arm64-apple-macosx12.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -new-driver-path /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-10-a.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2022-08-10-a.xctoolchain/usr/lib/swift -module-name t -o t.o
1. Apple Swift version 5.8-dev (LLVM 1e58bcc5bf50ea9, Swift 42135e27c4cf80e)
2. Compiling with the current language version
3. While walking into decl 'U' (at t.swift:14:1)
4. While walking into initializer for declaration 0x1529ba090 (at t.swift:15:5)
5. While verifying MetatypeConversion expression at [t.swift:15:32 - line:15:32] RangeText=""
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x00000001071d717c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x00000001071d63dc llvm::sys::RunSignalHandlers() + 128
2 swift-frontend 0x00000001071d77e0 SignalHandler(int) + 304
3 libsystem_platform.dylib 0x00000001a3c8f4a4 _sigtramp + 56
4 libsystem_pthread.dylib 0x00000001a3c77ee0 pthread_kill + 288
5 libsystem_c.dylib 0x00000001a3bb2340 abort + 168
6 swift-frontend 0x0000000103c91af4 (anonymous namespace)::Verifier::checkTrivialSubtype(swift::Type, swift::Type, char const*) + 812
7 swift-frontend 0x0000000103c861fc (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 5832
8 swift-frontend 0x0000000103c95348 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 300
9 swift-frontend 0x0000000103c96314 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 4344
10 swift-frontend 0x0000000103c99588 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 2764
11 swift-frontend 0x0000000103c94f0c (anonymous namespace)::Traversal::doIt(swift::Decl*) + 108
12 swift-frontend 0x0000000103c99880 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 432
13 swift-frontend 0x0000000103c94f0c (anonymous namespace)::Traversal::doIt(swift::Decl*) + 108
14 swift-frontend 0x0000000103c94e94 swift::Decl::walk(swift::ASTWalker&) + 32
15 swift-frontend 0x0000000103e29104 swift::SourceFile::walk(swift::ASTWalker&) + 180
16 swift-frontend 0x0000000103c83c28 swift::verify(swift::SourceFile&) + 96
17 swift-frontend 0x0000000103f2103c swift::TypeCheckSourceFileRequest::cacheResult(std::__1::tuple<>) const + 76
18 swift-frontend 0x00000001039d5ca4 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 160
19 swift-frontend 0x00000001039d3d2c swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 44
20 swift-frontend 0x0000000102cd0a20 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_7>(long, swift::SourceFile&) + 16
21 swift-frontend 0x0000000102cccb04 swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 76
22 swift-frontend 0x0000000102ccca98 swift::CompilerInstance::performSema() + 76
23 swift-frontend 0x0000000102c7e0d8 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
24 swift-frontend 0x0000000102c71380 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3372
25 swift-frontend 0x0000000102aeb424 swift::mainEntry(int, char const**) + 3764
26 dyld 0x000000010fce908c start + 520
Environment (please fill out the following information)
- OS: macOS 12.5 (21G72)
- Xcode Version/Tag/Branch: swift-DEVELOPMENT-SNAPSHOT-2022-08-10-a.xctoolchain
Additional context
You can also reproduce this using standard library types (which is how I came across it):
let clock: any Clock<Duration> = .suspending
Metadata
Metadata
Assignees
Labels
compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexistentialsFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuesFeature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased valuestype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysistypesFeature: typesFeature: types