From 673b29701b3768135b6cf7372f5c90b6cb2e2166 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 4 Jan 2017 14:30:34 +0100 Subject: [PATCH] [swiftc (23 vs. 5389)] Add crasher in swift::TypeChecker::resolveTypeInContext Add test case for crash triggered in `swift::TypeChecker::resolveTypeInContext`. Current number of unresolved compiler crashers: 23 (5389 resolved) /cc @slavapestov - just wanted to let you know that this crasher caused an assertion failure for the assertion `false && "Should have found context by now"` added on 2016-12-06 by you in commit fdaa88606 :-) Assertion failure in [`lib/Sema/TypeCheckType.cpp (line 325)`](https://github.com/apple/swift/blob/master/lib/Sema/TypeCheckType.cpp#L325): ``` Assertion `false && "Should have found context by now"' failed. When executing: std::tuple findDeclContextForType(swift::TypeChecker &, swift::TypeDecl *, swift::DeclContext *, TypeResolutionOptions) ``` Assertion context: ``` // or associated type from a context outside a ProtocolDecl. if (isa(parentDC) && isa(typeDecl)) return std::make_tuple(nullptr, nullptr, false); } assert(false && "Should have found context by now"); return std::make_tuple(nullptr, nullptr, false); } Type TypeChecker::resolveTypeInContext( TypeDecl *typeDecl, ``` Stack trace: ``` 0 0x0000000003512118 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/path/to/swift/bin/swift+0x3512118) 1 0x0000000003512856 SignalHandler(int) (/path/to/swift/bin/swift+0x3512856) 2 0x00007fa33d95b3e0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x113e0) 3 0x00007fa33c089428 gsignal /build/glibc-Qz8a69/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0 4 0x00007fa33c08b02a abort /build/glibc-Qz8a69/glibc-2.23/stdlib/abort.c:91:0 5 0x00007fa33c081bd7 __assert_fail_base /build/glibc-Qz8a69/glibc-2.23/assert/assert.c:92:0 6 0x00007fa33c081c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82) 7 0x0000000000c11d39 swift::TypeChecker::resolveTypeInContext(swift::TypeDecl*, swift::DeclContext*, swift::OptionSet, bool, swift::GenericTypeResolver*) (/path/to/swift/bin/swift+0xc11d39) 8 0x0000000000c19498 resolveTypeDecl(swift::TypeChecker&, swift::TypeDecl*, swift::SourceLoc, swift::DeclContext*, swift::GenericIdentTypeRepr*, swift::OptionSet, swift::GenericTypeResolver*, llvm::function_ref*) (/path/to/swift/bin/swift+0xc19498) 9 0x0000000000c1909d resolveTopLevelIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, swift::ComponentIdentTypeRepr*, swift::OptionSet, bool, swift::GenericTypeResolver*, llvm::function_ref*) (/path/to/swift/bin/swift+0xc1909d) 10 0x0000000000c138f9 resolveIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, llvm::ArrayRef, swift::OptionSet, bool, swift::GenericTypeResolver*, llvm::function_ref*) (/path/to/swift/bin/swift+0xc138f9) 11 0x0000000000c13323 swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet, bool, swift::GenericTypeResolver*, llvm::function_ref*) (/path/to/swift/bin/swift+0xc13323) 12 0x0000000000c14357 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::OptionSet) (/path/to/swift/bin/swift+0xc14357) 13 0x0000000000c1425c swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet, swift::GenericTypeResolver*, llvm::function_ref*) (/path/to/swift/bin/swift+0xc1425c) 14 0x0000000000c129fa swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet, swift::GenericTypeResolver*, llvm::function_ref*) (/path/to/swift/bin/swift+0xc129fa) 15 0x0000000000d37249 validateParameterType(swift::ParamDecl*, swift::DeclContext*, swift::OptionSet, swift::GenericTypeResolver&, swift::TypeChecker&) (/path/to/swift/bin/swift+0xd37249) 16 0x0000000000d370f9 swift::TypeChecker::typeCheckParameterList(swift::ParameterList*, swift::DeclContext*, swift::OptionSet, swift::GenericTypeResolver&) (/path/to/swift/bin/swift+0xd370f9) 17 0x0000000000d30eea checkGenericFuncSignature(swift::TypeChecker&, swift::ArchetypeBuilder*, swift::AbstractFunctionDecl*, swift::GenericTypeResolver&) (/path/to/swift/bin/swift+0xd30eea) 18 0x0000000000d3024e swift::TypeChecker::validateGenericFuncSignature(swift::AbstractFunctionDecl*) (/path/to/swift/bin/swift+0xd3024e) 19 0x0000000000d1aceb (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) (/path/to/swift/bin/swift+0xd1aceb) 20 0x0000000000d0a720 (anonymous namespace)::DeclChecker::visit(swift::Decl*) (/path/to/swift/bin/swift+0xd0a720) 21 0x0000000000d178fb (anonymous namespace)::DeclChecker::visitClassDecl(swift::ClassDecl*) (/path/to/swift/bin/swift+0xd178fb) 22 0x0000000000d0a5b4 (anonymous namespace)::DeclChecker::visit(swift::Decl*) (/path/to/swift/bin/swift+0xd0a5b4) 23 0x0000000000d1874b (anonymous namespace)::DeclChecker::visitProtocolDecl(swift::ProtocolDecl*) (/path/to/swift/bin/swift+0xd1874b) 24 0x0000000000d0a700 (anonymous namespace)::DeclChecker::visit(swift::Decl*) (/path/to/swift/bin/swift+0xd0a700) 25 0x0000000000d0a4e3 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) (/path/to/swift/bin/swift+0xd0a4e3) 26 0x0000000000c21bf5 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet, unsigned int, unsigned int) (/path/to/swift/bin/swift+0xc21bf5) 27 0x0000000000996736 swift::CompilerInstance::performSema() (/path/to/swift/bin/swift+0x996736) 28 0x000000000047c5aa swift::performFrontend(llvm::ArrayRef, char const*, void*, swift::FrontendObserver*) (/path/to/swift/bin/swift+0x47c5aa) 29 0x000000000043ade7 main (/path/to/swift/bin/swift+0x43ade7) 30 0x00007fa33c074830 __libc_start_main /build/glibc-Qz8a69/glibc-2.23/csu/../csu/libc-start.c:325:0 31 0x0000000000438229 _start (/path/to/swift/bin/swift+0x438229) ``` --- .../28599-false-should-have-found-context-by-now.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 validation-test/compiler_crashers/28599-false-should-have-found-context-by-now.swift diff --git a/validation-test/compiler_crashers/28599-false-should-have-found-context-by-now.swift b/validation-test/compiler_crashers/28599-false-should-have-found-context-by-now.swift new file mode 100644 index 0000000000000..07dfe38dd285d --- /dev/null +++ b/validation-test/compiler_crashers/28599-false-should-have-found-context-by-now.swift @@ -0,0 +1,10 @@ +// This source file is part of the Swift.org open source project +// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors + +// RUN: not --crash %target-swift-frontend %s -emit-ir +// REQUIRES: asserts +protocol a:A{{}class d{func b(a=}}protocol A:a{{}class a