[swift-dev] Compiler crash: AST verification error: archetype Element not allowed in this context

Kenny Leung kenny_leung at pobox.com
Tue Jun 7 12:25:48 CDT 2016


Hi All.

I have some incorrect code that is causing a compiler crash. Can somebody comment on whether this is worth a bug report? I was unable to match anything in JIRA.

The code can be found here: https://github.com/pepperdog/PepperDogFetch/tree/CompilerCrash-1

With some guidance as to what’s wrong, I may be able to make an isolated test, but as it is, there are too many layers.

Thanks!

-Kenny

—— cut here 8<——8<——
CompileSwift normal x86_64 /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift
    cd /Users/kenny/Projects/PepperDogFetch/iOSProject
    /Users/kenny/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-05-31-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Constraint.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/PostgreSQLDatabase/PostgreSQLDatabase.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Column.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/SQLConvertible.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Row.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Table.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/PepperDogFetch.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/DatabaseConnection.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/Database.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/PostgreSQLDatabase/PostgreSQLConnection.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/ConnectionPool.swift -target x86_64-apple-ios9.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -I /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Products/Debug-iphonesimulator -F /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Products/Debug-iphonesimulator -F /Users/kenny/Projects/PepperDogFetch/iOSProject/../ThirdParty -enable-testing -g -import-underlying-module -module-cache-path /Users/kenny/build/ModuleCache -serialize-debugging-options -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-generated-files.hmap -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-own-target-headers.hmap -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-project-headers.hmap -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/DerivedSources/x86_64 -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kenny/Projects/PepperDogFetch/iOSProject -emit-module-doc-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet~partial.swiftdoc -Onone -module-name PepperDogFetch -emit-module-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet~partial.swiftmodule -serialize-diagnostics-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.dia -emit-dependencies-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.d -emit-reference-dependencies-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.swiftdeps -o /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.o

/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:73:100: error: reference to generic type 'ResultSet.Iterator' requires arguments in <...>
    public func filter(_ includeElement: @noescape (Iterator.Element) throws -> Bool) rethrows -> [Iterator.Element] {
                                                                                                   ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:104:18: note: generic type 'Iterator' declared here
    public class Iterator<Element> : IteratorProtocol {
                 ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:77:44: error: reference to generic type 'ResultSet.Iterator' requires arguments in <...>
    public func forEach(_ body: @noescape (Iterator.Element) throws -> Swift.Void) rethrows {
                                           ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:104:18: note: generic type 'Iterator' declared here
    public class Iterator<Element> : IteratorProtocol {
                 ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:96:96: error: reference to generic type 'ResultSet.Iterator' requires arguments in <...>
    public func split(maxSplits: Int, omittingEmptySubsequences: Bool, isSeparator: @noescape (Iterator.Element) throws -> Bool) rethrows -> [ResultSet] {
                                                                                               ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:104:18: note: generic type 'Iterator' declared here
    public class Iterator<Element> : IteratorProtocol {
                 ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:100:92: error: reference to generic type 'ResultSet.Iterator' requires arguments in <...>
    public func first(where: @noescape (Self.Iterator.Element) throws -> Bool) rethrows -> Iterator.Element?
                                                                                           ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:104:18: note: generic type 'Iterator' declared here
    public class Iterator<Element> : IteratorProtocol {
                 ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:104:18: error: generic type 'Iterator' nested in type 'ResultSet' is not allowed
    public class Iterator<Element> : IteratorProtocol {
                 ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:11:14: error: type 'ResultSet' does not conform to protocol 'Sequence'
public class ResultSet : Sequence {
             ^
Swift.Sequence:124:17: note: protocol requires function 'makeIterator()' with type '() -> ResultSet.Iterator'
    public func makeIterator() -> Self.Iterator
                ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:51:17: note: candidate has non-matching type '() -> ResultSet.Iterator' [with SubSequence = AnySequence<Element>]
    public func makeIterator() -> ResultSet.Iterator {
                ^
Swift.Sequence:5:17: note: candidate has non-matching type '<Self> () -> Self' (aka '<τ_0_0> () -> τ_0_0') [with SubSequence = AnySequence<Element>]
    public func makeIterator() -> Self
                ^
Swift.Sequence:3:17: note: candidate has non-matching type '<Self> () -> Self.Base.Iterator' (aka '<τ_0_0> () -> τ_0_0.Base.Iterator') [with SubSequence = AnySequence<Element>]
    public func makeIterator() -> Self.Iterator
                ^
/Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:52:34: error: cannot invoke value of type 'ResultSet.Iterator<_>.Type' with argument list '()'
        return ResultSet.Iterator()
               ~~~~~~~~~~~~~~~~~~^
AST verification error: archetype Element not allowed in this context
archetype came from:

0  swift                    0x000000010669366b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x00000001066928f6 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000106693d3f SignalHandler(int) + 383
3  libsystem_platform.dylib 0x00007fff8f45b52a _sigtramp + 26
4  swift                    0x0000000107274b18 clang::vfs::getNextVirtualUniqueID()::UID + 75840
5  swift                    0x0000000106693b16 abort + 22
6  swift                    0x0000000104357a8d (anonymous namespace)::Verifier::verifyChecked(swift::Type, llvm::SmallPtrSet<swift::ArchetypeType*, 4u>&) + 109
7  swift                    0x000000010435feba (anonymous namespace)::Verifier::verifyCheckedAlways(swift::ValueDecl*) + 154
8  swift                    0x0000000104355413 (anonymous namespace)::Verifier::walkToDeclPost(swift::Decl*) + 1331
9  swift                    0x000000010436775c (anonymous namespace)::Traversal::doIt(swift::Decl*) + 1580
10 swift                    0x000000010436985f (anonymous namespace)::Traversal::visitParameterList(swift::ParameterList*) + 95
11 swift                    0x000000010436bd9b (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 1003
12 swift                    0x0000000104367233 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 259
13 swift                    0x000000010436b984 (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 260
14 swift                    0x000000010436721f (anonymous namespace)::Traversal::doIt(swift::Decl*) + 239
15 swift                    0x000000010436711b swift::Decl::walk(swift::ASTWalker&) + 27
16 swift                    0x0000000104418dca swift::SourceFile::walk(swift::ASTWalker&) + 170
17 swift                    0x000000010434b8b1 swift::verify(swift::SourceFile&) + 65
18 swift                    0x000000010428f50e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1710
19 swift                    0x0000000103f4e4ff swift::CompilerInstance::performSema() + 5135
20 swift                    0x0000000103a64a40 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 448
21 swift                    0x0000000103a6397f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2895
22 swift                    0x0000000103a26ad0 main + 2688
23 libdyld.dylib            0x00007fff8adbe5ad start + 1
Stack dump:
0.	Program arguments: /Users/kenny/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-05-31-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Constraint.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/PostgreSQLDatabase/PostgreSQLDatabase.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Column.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/SQLConvertible.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Row.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/Table.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/PepperDogFetch.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/DatabaseConnection.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/Database.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/PostgreSQLDatabase/PostgreSQLConnection.swift /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/DatabaseLayer/ConnectionPool.swift -target x86_64-apple-ios9.3 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -I /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Products/Debug-iphonesimulator -F /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Products/Debug-iphonesimulator -F /Users/kenny/Projects/PepperDogFetch/iOSProject/../ThirdParty -enable-testing -g -import-underlying-module -module-cache-path /Users/kenny/build/ModuleCache -serialize-debugging-options -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-generated-files.hmap -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-own-target-headers.hmap -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/PepperDogFetch-project-headers.hmap -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/DerivedSources/x86_64 -Xcc -I/Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/kenny/Projects/PepperDogFetch/iOSProject -emit-module-doc-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet~partial.swiftdoc -Onone -module-name PepperDogFetch -emit-module-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet~partial.swiftmodule -serialize-diagnostics-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.dia -emit-dependencies-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.d -emit-reference-dependencies-path /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.swiftdeps -o /Users/kenny/build/PepperDogFetch-esuqrverwjrarebailkxzerpnzax/Build/Intermediates/PepperDogFetch.build/Debug-iphonesimulator/PepperDogFetch.build/Objects-normal/x86_64/ResultSet.o 
1.	While walking into decl 'ResultSet' at /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:11:8
2.	While walking into body of 'map' at /Users/kenny/Projects/PepperDogFetch/PepperDogFetch/RelationalLayer/ResultSet.swift:69:12
--------------------------------


More information about the swift-dev mailing list