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-11721] Compiler crash with type inference #54130

Closed
kateinoigakukun opened this issue Nov 6, 2019 · 4 comments
Closed

[SR-11721] Compiler crash with type inference #54130

kateinoigakukun opened this issue Nov 6, 2019 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@kateinoigakukun
Copy link
Member

Previous ID SR-11721
Radar None
Original Reporter @kateinoigakukun
Type Bug
Status Closed
Resolution Won't Do
Environment

5.1-DEVELOPMENT-SNAPSHOT-2019-11-05-a
Apple Swift version 5.1.1-dev (Swift b368b0d) Target: x86_64-apple-darwin18.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: c64a52988d26a4be317417d90f60ec04

Issue Description:

Minimal reproducible example is here.

https://github.com/kateinoigakukun/infinite-type-infer

Target.swift:13:12: error: use of undeclared type 'UndefinedType'
class B: A<UndefinedType>, P {}
           ^~~~~~~~~~~~~
Assertion failed: (ownerNominal == baseTy->getAnyNominal()), function getContextSubstitutions, file /Users/buildnode/jenkins/workspace/oss-swift-5.1-package-osx/swift/lib/AST/Type.cpp, line 3446.
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-11-05-a.xctoolchain/usr/bin/swift -frontend -typecheck -primary-file Target.swift Empty.swift -target x86_64-apple-darwin18.5.0 -enable-objc-interop -color-diagnostics -module-name main
1.  While type-checking protocol conformance to 'P' (at Target.swift:1:8) for type 'B' (declared at [Target.swift:13:1 - line:13:31] RangeText="class B: A<UndefinedType>, P {")
0  swift                    0x0000000111585105 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001115843f5 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001115856e8 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff68beeb5d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000004098 _sigtramp + 2537641304
5  libsystem_c.dylib        0x00007fff68aae6a6 abort + 127
6  libsystem_c.dylib        0x00007fff68a7720d basename_r + 0
7  swift                    0x00000001119ee7f3 swift::TypeBase::getContextSubstitutions(swift::DeclContext const*, swift::GenericEnvironment*) (.cold.6) + 35
8  swift                    0x000000010eab8699 swift::TypeBase::getContextSubstitutions(swift::DeclContext const*, swift::GenericEnvironment*) + 1433
9  swift                    0x000000010eab87ec swift::TypeBase::getMemberSubstitutions(swift::ValueDecl const*, swift::GenericEnvironment*) + 124
10 swift                    0x000000010e74cb08 getWitnessTypeForMatching(swift::TypeChecker&, swift::NormalProtocolConformance*, swift::ValueDecl*) + 152
11 swift                    0x000000010e74be44 swift::AssociatedTypeInference::inferTypeWitnessesViaValueWitness(swift::ValueDecl*, swift::ValueDecl*) + 100
12 swift                    0x000000010e74b0eb swift::AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(swift::ConformanceChecker&, llvm::SetVector<swift::AssociatedTypeDecl*, std::__1::vector<swift::AssociatedTypeDecl*, std::__1::allocator<swift::AssociatedTypeDecl*> >, llvm::DenseSet<swift::AssociatedTypeDecl*, llvm::DenseMapInfo<swift::AssociatedTypeDecl*> > > const&, swift::ValueDecl*) + 907
13 swift                    0x000000010e74c47b swift::AssociatedTypeInference::inferTypeWitnessesViaValueWitnesses(swift::ConformanceChecker&, llvm::SetVector<swift::AssociatedTypeDecl*, std::__1::vector<swift::AssociatedTypeDecl*, std::__1::allocator<swift::AssociatedTypeDecl*> >, llvm::DenseSet<swift::AssociatedTypeDecl*, llvm::DenseMapInfo<swift::AssociatedTypeDecl*> > > const&) + 1131
14 swift                    0x000000010e750fde swift::AssociatedTypeInference::solve(swift::ConformanceChecker&) + 494
15 swift                    0x000000010e751728 swift::ConformanceChecker::resolveTypeWitnesses() + 264
16 swift                    0x000000010e72eda9 swift::ConformanceChecker::checkConformance(swift::MissingWitnessDiagnosisKind) + 137
17 swift                    0x000000010e72dd8b swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 7467
18 swift                    0x000000010e72bef2 swift::MultiConformanceChecker::checkAllConformances() + 114
19 swift                    0x000000010e736aef swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 4335
20 swift                    0x000000010e781b78 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 200
21 swift                    0x000000010e782758 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1064
22 swift                    0x000000010df47501 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t)::$_1::operator()(swift::SourceFile&) const + 81
23 swift                    0x000000010df427bb swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 507
24 swift                    0x000000010df420ba swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 618
25 swift                    0x000000010dd2f9ae performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1678
26 swift                    0x000000010dd2e3fa swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3002
27 swift                    0x000000010dcd6ea8 main + 696
28 libdyld.dylib            0x00007fff68a093d5 start + 1
29 libdyld.dylib            0x000000000000000c start + 2539613240
@theblixguy
Copy link
Collaborator

On master, it does not crash and I get:

/Users/suyashsrijan/Desktop/test.swift:13:12: error: use of undeclared type 'UndefinedType'
class B: A<UndefinedType>, P {}
           ^~~~~~~~~~~~~
/Users/suyashsrijan/Desktop/test.swift:13:7: error: type 'B' does not conform to protocol 'P'
class B: A<UndefinedType>, P {}
      ^
/Users/suyashsrijan/Desktop/test.swift:9:9: note: candidate has non-matching type 'I' [with X = I]
    let x = I()
        ^
/Users/suyashsrijan/Desktop/test.swift:3:9: note: protocol requires property 'x' with type 'I'; do you want to add a stub?
    var x: X { get }

@beccadax
Copy link
Contributor

beccadax commented Nov 7, 2019

@slavapestov

@kateinoigakukun
Copy link
Member Author

After checking out master branch, this issue seems resolved. I'll close this ticket.

@kateinoigakukun
Copy link
Member Author

It seems already resolved on master branch

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants