Open swift-ci opened 4 years ago
No longer crashes on master. You get the following error:
error: cannot convert value of type 'Test.Type' to expected argument type 'AnyClass' (aka 'AnyObject.Type')
let foo = Bundle(for: type(of: self))
^
Please verify using the latest trunk snapshot and close this ticket.
Environment
Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51) Target: x86_64-apple-darwin19.4.0Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, TypeChecker | |Assignee | None | |Priority | Medium | md5: dd33f0356817ca47cc66d8f079c436edIssue Description:
Attempting to compile the following will cause the swift compiler to segfault. Obviously the code is invalid but it seems like this should be an error and not a crash.
```
import Foundation
struct Test {
func crashSwiftCompiler() {
let foo = Bundle(for: type(of: self))
}
}
```
let foo = Bundle(for: type(of: self))
"
0 swift 0x000000010f8d74ea PrintStackTraceSignalHandler(void*) + 42
1 swift 0x000000010f8d6cc0 SignalHandler(int) + 352
2 libsystem_platform.dylib 0x00007fff701f15fd _sigtramp + 29
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2413881888
4 swift 0x000000010c0fe6ee swift::constraints::MissingConformance::diagnose(bool) const + 382
5 swift 0x000000010c0450c9 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool) + 5849
6 swift 0x000000010c2085c9 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet\<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 1033
7 swift 0x000000010c20b3b5 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 1029
8 swift 0x000000010c20c3d2 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 210
9 swift 0x000000010c2c3eea swift::SimpleRequest\<swift::PatternBindingEntryRequest, swift::PatternBindingEntry const* (swift::PatternBindingDecl*, unsigned int), (swift::CacheKind)2>::evaluateRequest(swift::PatternBindingEntryRequest const&, swift::Evaluator&) + 698
10 swift 0x000000010c21d4ac llvm::Expected\<swift::PatternBindingEntryRequest::OutputType> swift::Evaluator::getResultUncached\<swift::PatternBindingEntryRequest>(swift::PatternBindingEntryRequest const&) + 524
11 swift 0x000000010c21d207 swift::PatternBindingEntryRequest::OutputType swift::evaluateOrDefault\<swift::PatternBindingEntryRequest>(swift::Evaluator&, swift::PatternBindingEntryRequest, swift::PatternBindingEntryRequest::OutputType) + 55
12 swift 0x000000010c23a7b2 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 2930
13 swift 0x000000010c2d7711 swift::ASTVisitor\<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 8577
14 swift 0x000000010c2d4f29 bool (anonymous namespace)::StmtChecker::typeCheckStmt\<swift::BraceStmt>(swift::BraceStmt*&) + 121
15 swift 0x000000010c2cce7f swift::SimpleRequest\<swift::TypeCheckFunctionBodyUntilRequest, bool (swift::AbstractFunctionDecl*, swift::SourceLoc), (swift::CacheKind)1>::evaluateRequest(swift::TypeCheckFunctionBodyUntilRequest const&, swift::Evaluator&) + 2879
16 swift 0x000000010c2d36ee swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault\<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 718
17 swift 0x000000010c30224e swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*, unsigned int) const + 6270
18 swift 0x000000010c2d16c7 swift::SimpleRequest\<swift::TypeCheckSourceFileRequest, bool (swift::SourceFile*, unsigned int), (swift::CacheKind)2>::evaluateRequest(swift::TypeCheckSourceFileRequest const&, swift::Evaluator&) + 23
19 swift 0x000000010c2ffb4e swift::performTypeChecking(swift::SourceFile&, unsigned int) + 1006
20 swift 0x000000010b933bcb swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 5915
21 swift 0x000000010b61fd99 swift::performFrontend(llvm::ArrayRef\<char const*>, char const*, void*, swift::FrontendObserver*) + 10281
22 swift 0x000000010b5a0f53 main + 1283
23 libdyld.dylib 0x00007fff6fff8cc9 start + 1
24 libdyld.dylib 0x000000000000000b start + 2415948611
Segmentation fault: 11