Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7282] Typealias usage in generic extension crash in at least 3/26 snapshot #49830

Closed
swift-ci opened this issue Mar 27, 2018 · 6 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-7282
Radar None
Original Reporter benasher44 (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

macOS 10.13.3
swift snapshot org.swift.3020180326a

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @DougGregor
Priority Medium

md5: 46948ae1a97af89a3e7042c1f5554f7c

Issue Description:

The compiler crashes attempting to compile this file:

test.swift

struct S<T> {}

extension S where T == Int {
    typealias Callback = (Bool) -> Void

    func process(callback: Callback) {   
    }
}

When I run `swift test.swift`, I get this crash output:

Assertion failed: (static_cast<bool>(genericSig) == numSubstitutions > 0), function get, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/AST/ASTContext.cpp, line 2960.
0 swift 0x00000001127f32e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x00000001127f39f6 SignalHandler(int) + 694
2 libsystem_platform.dylib 0x00007fff59c00f5a _sigtramp + 26
3 libdyld.dylib 0x00007fff5997f249 dyldGlobalLockRelease() + 0
4 libsystem_c.dylib 0x00007fff59a2b312 abort + 127
5 libsystem_c.dylib 0x00007fff599f3368 basename_r + 0
6 swift 0x000000011014d823 swift::NameAliasType::get(swift::TypeAliasDecl*, swift::Type, swift::SubstitutionMap const&, swift::Type) + 563
7 swift 0x000000010ff64f27 swift::TypeChecker::substMemberTypeWithBase(swift::ModuleDecl*, swift::TypeDecl*, swift::Type) + 663
8 swift 0x000000010ff64af9 swift::TypeChecker::resolveTypeInContext(swift::TypeDecl*, swift::DeclContext*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*) + 553
9 swift 0x000000010ff6c8c6 resolveTypeDecl(swift::TypeChecker&, swift::TypeDecl*, swift::SourceLoc, swift::DeclContext*, swift::DeclContext*, swift::GenericIdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 214
10 swift 0x000000010ff6c482 resolveTopLevelIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, swift::ComponentIdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 1698
11 swift 0x000000010ff66b34 resolveIdentTypeComponent(swift::TypeChecker&, swift::DeclContext*, llvm::ArrayRef<swift::ComponentIdentTypeRepr*>, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 564
12 swift 0x000000010ff6652a swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 138
13 swift 0x000000010ff671c3 (anonymous namespace)::TypeResolver::resolveType(swift::TypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>) + 163
14 swift 0x000000010ff670ed swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 173
15 swift 0x000000010ff65acd swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 141
16 swift 0x000000010ff1759e validateParameterType(swift::ParamDecl*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver&, swift::TypeChecker&) + 142
17 swift 0x000000010ff17417 swift::TypeChecker::typeCheckParameterList(swift::ParameterList*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver&) + 487
18 swift 0x000000010ff0df5a checkGenericFuncSignature(swift::TypeChecker&, swift::GenericSignatureBuilder*, swift::AbstractFunctionDecl*, swift::GenericTypeResolver&) + 266
19 swift 0x000000010ff0dd82 swift::TypeChecker::validateGenericFuncSignature(swift::AbstractFunctionDecl*) + 2178
20 swift 0x000000010fee2a57 swift::TypeChecker::validateDecl(swift::ValueDecl*) + 6263
21 swift 0x000000010fef5822 (anonymous namespace)::DeclChecker::visitFuncDecl(swift::FuncDecl*) + 82
22 swift 0x000000010fede254 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 180
23 swift 0x000000010fef5a7b (anonymous namespace)::DeclChecker::visitExtensionDecl(swift::ExtensionDecl*) + 491
24 swift 0x000000010fede283 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 227
25 swift 0x000000010fede18f swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 47
26 swift 0x000000010ff75dce swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1630
27 swift 0x000000010fbb7b10 swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 416
28 swift 0x000000010fbb67d2 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 626
29 swift 0x000000010fbb6132 swift::CompilerInstance::performSema() + 466
30 swift 0x000000010f049dff performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1887
31 swift 0x000000010f04868e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3310
32 swift 0x000000010f006a63 main + 2051
33 libdyld.dylib 0x00007fff5997f115 start + 1
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2018-03-26-a.xctoolchain/usr/bin/swift -frontend -interpret test.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -module-name test

  1. While type-checking extension of S<Int> at test.swift:4:1
  2. While type-checking 'process(callback🙂' at test.swift:7:5
  3. While validating 'process(callback🙂' at test.swift:7:5
  4. While resolving type Callback at [test.swift:7:28 - line:7:28] RangeText="C"

By adjusting the code to not use the typealias, the code compiles without issue:

struct S<T> {}

extension S where T == Int {
    typealias Callback = (Bool) -> Void

    func process(callback: (Bool) -> Void) {   
    }
}
@belkadan
Copy link
Contributor

Was this a 4.1 snapshot or a master snapshot? It seems to work in my build of master.

@swift-ci
Copy link
Collaborator Author

Comment by Ben A (JIRA)

This was a master snapshot

@DougGregor
Copy link
Member

I see the issue on master; it looks like that new assertion is bogus. Fix coming, thanks!

@swift-ci
Copy link
Collaborator Author

Comment by Ben A (JIRA)

Wooo! No problem.

@DougGregor
Copy link
Member

#15541

@DougGregor
Copy link
Member

Fix merged into master; pulling it into 4.2 as well via #15576

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

4 participants