swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.49k stars 10.35k forks source link

[SR-12353] [5.1] assertion: isa<SourceFile>(nominal->getModuleScopeContext()) #54787

Open swift-ci opened 4 years ago

swift-ci commented 4 years ago
Previous ID SR-12353
Radar rdar://problem/60832802
Original Reporter tannernelson (JIRA User)
Type Bug
Environment Happens on Linux and macOS
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 36cc7dda70cb5b4bf49c39270fc1afa8

Issue Description:

The following code change is causing an assertion in the 5.1 compiler:

struct Notification { 
    struct Message { }
}

Changed to:

struct Notification { }
extension Notification {
    struct Message { }
}

This compiler assertion doesn't happen in the module itself, but in a module that imports this module with `@testable`.

I'm unable to share the source code so I'm not sure how helpful this will be with just the stack trace.

CompileSwift normal x86_64 /Users/tanner/dev/nodes-projects/values-vapor/Tests/IntegrationTests/Repositories/Notification/NotificationRepositoryTests+getNotificationByID.swift (in target 'IntegrationTests' from project 'ValuesBackend')
    cd /Users/tanner/dev/nodes-projects/values-vapor
...
-Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name IntegrationTests -o /Users/tanner/Library/Developer/Xcode/DerivedData/values-vapor-ccuacjbqmkhizibhuxoutoaiheso/Build/Intermediates.noindex/ValuesBackend.build/Debug/IntegrationTests.build/Objects-normal/x86_64/NotificationRepositoryTests+getNotificationByID.o -index-store-path /Users/tanner/Library/Developer/Xcode/DerivedData/values-vapor-ccuacjbqmkhizibhuxoutoaiheso/Index/DataStore -index-system-modules

Assertion failed: (isa<SourceFile>(nominal->getModuleScopeContext())), function finalizeType, file /Users/buildnode/jenkins/workspace/oss-swift-5.1-package-osx/swift/lib/Sema/TypeCheckDecl.cpp, line 4436.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.1.5-RELEASE.xctoolchain/usr/bin/swift -frontend -c /Users/tanner/dev/nodes-projects/values-vapor/Tests/IntegrationTests/Helpers/Application+repository.swift /Users/tanner/dev/nodes-projects/values-vapor/Tests/IntegrationTests/Helpers/Application+testable.swift /Users/tanner/dev/nodes-projects/
...
Library/Developer/Xcode/DerivedData/values-vapor-ccuacjbqmkhizibhuxoutoaiheso/Build/Intermediates.noindex/ValuesBackend.build/Debug/IntegrationTests.build/Objects-normal/x86_64/SettingsRepositoryTests+getSettings.o -index-store-path /Users/tanner/Library/Developer/Xcode/DerivedData/values-vapor-ccuacjbqmkhizibhuxoutoaiheso/Index/DataStore -index-system-modules 
0  swift                    0x0000000110c5dff5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000110c5d2e5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000110c5e5d8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff65da742d _sigtramp + 29
4  swift                    0x0000000112f853d4 cmark_strbuf__initbuf + 124143
5  libsystem_c.dylib        0x00007fff65c7ca1c abort + 120
6  libsystem_c.dylib        0x00007fff65c7bcd6 err + 0
7  swift                    0x0000000110fa76e3 swift::TypeChecker::finalizeDecl(swift::ValueDecl*) (.cold.6) + 35
8  swift                    0x000000010ddc8c8b swift::TypeChecker::finalizeDecl(swift::ValueDecl*) + 1067
9  swift                    0x000000010de5ad0b typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 827
10 swift                    0x000000010de5b678 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1064
11 swift                    0x000000010d6203d1 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t)::$_1::operator()(swift::SourceFile&) const + 81
12 swift                    0x000000010d61b68b swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 507
13 swift                    0x000000010d61af8a swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 618
14 swift                    0x000000010d40881e performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1678
15 swift                    0x000000010d40726a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3002
16 swift                    0x000000010d3afd18 main + 696
17 libdyld.dylib            0x00007fff65bae7fd start + 1
error: Abort trap: 6 (in target 'IntegrationTests' from project 'ValuesBackend')
beccadax commented 4 years ago

@swift-ci create