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-7674] Compiler crash while working on a type erasurer #50214

Open
swift-ci opened this issue May 13, 2018 · 8 comments
Open

[SR-7674] Compiler crash while working on a type erasurer #50214

swift-ci opened this issue May 13, 2018 · 8 comments
Labels
associated type inference bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances declarations Feature: declarations protocol Feature → type declarations: Protocol declarations swift 5.9 type checker Area → compiler: Semantic analysis typealias Feature → type declarations: `typealias` declarations unexpected error Bug: Unexpected error

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 13, 2018

Previous ID SR-7674
Radar None
Original Reporter guidomb (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode Version 9.3 (9E145)

macOS Version 10.13.4 (17E202)

ReactiveSwift 3.1.0 revision 46fb4d4a8285286e54929add1d12f384675895c6

Result 3.2.4 revision 7477584259bfce2560a19e06ad9f71db441fff11

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

md5: b6710c796fab2d8226271de84635e7dc

Issue Description:

The following code generates a compiler crash

import Foundation
import ReactiveSwift
import Result

protocol BehaviorEffectPerformer {

    associatedtype EffectType
    associatedtype EffectResponseType
    associatedtype EffectErrorType: Error

    typealias EffectResult = Result<EffectResponseType, EffectErrorType>
    typealias EffectResultProducer = SignalProducer<EffectResult, NoError>

    func perform(effect: EffectType) -> EffectResultProducer

}

struct AnyBehaviorEffectPerformer<EffectType, EffectResponseType, EffectErrorType: Error>: BehaviorEffectPerformer {

    private let performEffect: (EffectType) -> EffectResultProducer

    init<BehaviorEffectPerformerType: BehaviorEffectPerformer>(_ effectPerformer: BehaviorEffectPerformerType)
        where   BehaviorEffectPerformerType.EffectType == EffectType,
                BehaviorEffectPerformerType.EffectResponseType == EffectResponseType,
                BehaviorEffectPerformerType.EffectErrorType ==EffectErrorType {
        self.performEffect = effectPerformer.perform(effect:)
    }

    func perform(effect: EffectType) -> EffectResultProducer {
        return performEffect
    }

}

Compiler output:

CompileSwift normal x86_64 /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/File.swift
    cd /Users/guidomb/Documents/projects/wolox/Feebi
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/Behaviors/CreateSurvey.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/OutputRenderer.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/Services/GoogleAuth.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/BotBehaviorRunner.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/Behavior.swift -primary-file /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/File.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/Services/SlackService.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/main.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/JobExecutor.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/Effector.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Products/Debug -F /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -g -module-cache-path /Users/guidomb/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -fmodule-map-file=/Users/guidomb/Documents/projects/wolox/Feebi/Feebi.xcodeproj/GeneratedModuleMap/CHTTPParser/module.modulemap -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/swift-overrides.hmap -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Products/Debug/include -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/.build/checkouts/common-crypto-spm--132958532151328779 -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/.build/checkouts/zlib-spm.git-7042465659040932026 -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/.build/checkouts/http-5976992940601425903/Sources/CHTTPParser/include -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/Feebi.xcodeproj/GeneratedModuleMap/CHTTPParser -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/DerivedSources/x86_64 -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/DerivedSources -Xcc -working-directory/Users/guidomb/Documents/projects/wolox/Feebi -emit-module-doc-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File~partial.swiftdoc -serialize-diagnostics-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.dia -module-name Feebi -emit-module-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File~partial.swiftmodule -emit-dependencies-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.d -emit-reference-dependencies-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.swiftdeps -o /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.o -index-store-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Index/DataStore -index-system-modules

0  swift                    0x00000001058f3ffa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x00000001058f33b6 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff743cff5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007fe6820fa8c0 _sigtramp + 231909760
4  swift                    0x0000000102d67cb5 swift::Lowering::TypeConverter::getConstantInfo(swift::SILDeclRef) + 117
5  swift                    0x0000000102d8cf3b swift::SILModule::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter) + 91
6  swift                    0x0000000102800545 swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 325
7  swift                    0x0000000102801ca1 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 721
8  swift                    0x00000001028eb3f3 (anonymous namespace)::SILGenType::emitType() + 819
9  swift                    0x000000010280bba6 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 70
10 swift                    0x000000010280acdb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1371
11 swift                    0x000000010280c8c1 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 865
12 swift                    0x0000000101f513bc performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 27340
13 swift                    0x0000000101f48e64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
14 swift                    0x0000000101efd8b5 main + 18917
15 libdyld.dylib            0x00007fff740c1015 start + 1
Stack dump:
0.    Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/Behaviors/CreateSurvey.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/OutputRenderer.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/Services/GoogleAuth.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/BotBehaviorRunner.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/Behavior.swift -primary-file /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/File.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/Services/SlackService.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/main.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/JobExecutor.swift /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/Effector.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Products/Debug -F /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -g -module-cache-path /Users/guidomb/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 4 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D Xcode -serialize-debugging-options -Xcc -fmodule-map-file=/Users/guidomb/Documents/projects/wolox/Feebi/Feebi.xcodeproj/GeneratedModuleMap/CHTTPParser/module.modulemap -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/swift-overrides.hmap -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Products/Debug/include -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/.build/checkouts/common-crypto-spm--132958532151328779 -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/.build/checkouts/zlib-spm.git-7042465659040932026 -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/.build/checkouts/http-5976992940601425903/Sources/CHTTPParser/include -Xcc -I/Users/guidomb/Documents/projects/wolox/Feebi/Feebi.xcodeproj/GeneratedModuleMap/CHTTPParser -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/DerivedSources/x86_64 -Xcc -I/Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/DerivedSources -Xcc -working-directory/Users/guidomb/Documents/projects/wolox/Feebi -emit-module-doc-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File~partial.swiftdoc -serialize-diagnostics-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.dia -module-name Feebi -emit-module-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File~partial.swiftmodule -emit-dependencies-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.d -emit-reference-dependencies-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.swiftdeps -o /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Build/Intermediates.noindex/Feebi.build/Debug/Feebi.build/Objects-normal/x86_64/File.o -index-store-path /Users/guidomb/Library/Developer/Xcode/DerivedData/Feebi-fptzhdpcxzqcwreffszxemnslfki/Index/DataStore -index-system-modules 
1.    While emitting SIL for 'perform(effect:)' at /Users/guidomb/Documents/projects/wolox/Feebi/Sources/Feebi/BotBehaviors/File.swift:29:5
@swift-ci
Copy link
Collaborator Author

swift-ci commented May 13, 2018

Comment by Guido Marucci Blas (JIRA)

OK I found a work-around, instead of declaring performEffect inside AnyBehaviorEffectPerformer as

private let performEffect: (EffectType) -> EffectResultProducer  

I declare it without using the typealias inherited from the protocol comformance to BehaviorEffectPerformer as

private let performEffect: (EffectType) -> SignalProducer<Result<EffectResponseType, EffectErrorType>, NoError>

and it compiled. Maybe something clashing when trying to expand the typealias?

@swift-ci
Copy link
Collaborator Author

swift-ci commented May 14, 2018

Comment by Guido Marucci Blas (JIRA)

Here are swift build crash output for Swift version in Xcode 9.3 and latest 4.2 snapshot. I've also attached a project that reproduces the issue.

Apple Swift version 4.1 (swiftlang-902.0.48 clang-902.0.37.1)
Target: x86_64-apple-darwin17.5.0

Compile Swift Module 'Foo' (2 sources)
0  swift                    0x000000010d264ffa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x000000010d2643b6 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff743cff5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007ff448967300 _sigtramp + 3562632128
4  swift                    0x000000010a6d8cb5 swift::Lowering::TypeConverter::getConstantInfo(swift::SILDeclRef) + 117
5  swift                    0x000000010a6fdf3b swift::SILModule::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, swift::ProfileCounter) + 91
6  swift                    0x000000010a171545 swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 325
7  swift                    0x000000010a172ca1 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 721
8  swift                    0x000000010a25c3f3 (anonymous namespace)::SILGenType::emitType() + 819
9  swift                    0x000000010a17cba6 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 70
10 swift                    0x000000010a17bcdb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1371
11 swift                    0x000000010a17d8c1 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 865
12 swift                    0x00000001098c23bc performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 27340
13 swift                    0x00000001098b9e64 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908
14 swift                    0x000000010986e8b5 main + 18917
15 libdyld.dylib            0x00007fff740c1015 start + 1
16 libdyld.dylib            0x0000000000000027 start + 2348019731
Stack dump:
0.    Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/File.swift /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/main.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/ModuleCache -swift-version 4 -Onone -D SWIFT_PACKAGE -color-diagnostics -emit-module-doc-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File~partial.swiftdoc -module-name Foo -emit-module-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File~partial.swiftmodule -emit-dependencies-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File.d -emit-reference-dependencies-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File.swiftdeps -num-threads 8 -o /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File.swift.o 
1.    While emitting SIL for 'perform(effect:)' at /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/File.swift:32:5
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
error: terminated(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/debug.yaml main output:

Apple Swift version 4.2-dev (LLVM ae60dc0632, Clang 91ee593a0d, Swift 9f28451)
Target: x86_64-apple-darwin17.5.0

Compile Swift Module 'Foo' (2 sources)
Assertion failed: ((HadError || !M.is<SourceFile*>() || M.get<SourceFile*>()->ASTStage < SourceFile::TypeChecked) && "UnresolvedDeclRef" "in wrong phase"), function walkToExprPre, file /Users/buildnode/jenkins/workspace/oss-swift-4.2-package-osx/swift/include/swift/AST/ExprNodes.def, line 90.
0  swift                    0x0000000108d4a068 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000108d4a776 SignalHandler(int) + 694
2  libsystem_platform.dylib 0x00007fff743cff5a _sigtramp + 26
3  libsystem_platform.dylib 0x00007ffeea6a00c8 _sigtramp + 1982661000
4  libsystem_c.dylib        0x00007fff7416d1ae abort + 127
5  libsystem_c.dylib        0x00007fff741351ac basename_r + 0
6  swift                    0x000000010672796a (anonymous namespace)::Verifier::walkToExprPre(swift::Expr*) + 1034
7  swift                    0x000000010673ce14 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 36
8  swift                    0x000000010673dc74 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 2996
9  swift                    0x000000010673d187 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 199
10 swift                    0x000000010673f755 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 725
11 swift                    0x0000000106739da6 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 310
12 swift                    0x000000010673efbb (anonymous namespace)::Traversal::visitNominalTypeDecl(swift::NominalTypeDecl*) + 475
13 swift                    0x0000000106739d98 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 296
14 swift                    0x0000000106739c5b swift::Decl::walk(swift::ASTWalker&) + 27
15 swift                    0x00000001067e55ea swift::SourceFile::walk(swift::ASTWalker&) + 170
16 swift                    0x000000010672700b swift::verify(swift::SourceFile&) + 59
17 swift                    0x00000001064e578b swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2187
18 swift                    0x000000010611a7e2 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 834
19 swift                    0x000000010611a068 swift::CompilerInstance::performSema() + 472
20 swift                    0x00000001055a4a20 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1904
21 swift                    0x00000001055a32a6 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3318
22 swift                    0x000000010555f6ed main + 2317
23 libdyld.dylib            0x00007fff740c1015 start + 1
24 libdyld.dylib            0x0000000000000029 start + 2348019733
Stack dump:
0.    Program arguments: /Library/Developer/Toolchains/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-12-a.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/File.swift /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/main.swift -emit-module-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File~partial.swiftmodule -emit-module-doc-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File~partial.swiftdoc -emit-dependencies-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File.d -emit-reference-dependencies-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File.swiftdeps -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -I /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/ModuleCache -swift-version 4 -Onone -D SWIFT_PACKAGE -D DEBUG -color-diagnostics -module-name Foo -num-threads 8 -o /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/x86_64-apple-macosx10.10/debug/Foo.build/File.swift.o 
1.    While walking into decl 'AnyBehaviorEffectPerformer' at /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/File.swift:18:1
2.    While walking into body of 'perform(effect:)' at /Users/guidomb/Documents/projects/wolox/Feebi/Foo/Sources/Foo/File.swift:32:5
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
error: terminated(1): /Library/Developer/Toolchains/swift-4.2-DEVELOPMENT-SNAPSHOT-2018-05-12-a.xctoolchain/usr/bin/swift-build-tool -f /Users/guidomb/Documents/projects/wolox/Feebi/Foo/.build/debug.yaml main output:

@swift-ci
Copy link
Collaborator Author

Comment by Guido Marucci Blas (JIRA)

Here is a twitter thread were I discussed this in case there some replies that can help with this issue -> https://twitter.com/guidomb/status/995810518735753218

@belkadan
Copy link
Contributor

@slavapestov, @rudkx, sound familiar?

@slavapestov
Copy link
Member

I need to come up with a stand-alone test case, but the problem might even be with associated type inference.

@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
@fibrechannelscsi
Copy link
Contributor

I hit this today in our codebase:
Assertion failed: ((HadError || !M.is<SourceFile*>() || M.get<SourceFile*>()->ASTStage < SourceFile::TypeChecked) && "UnresolvedDot" "in wrong phase"), function walkToExprPre, file ExprNodes.def, line 104.
I don't have a reproducer yet.

@fibrechannelscsi
Copy link
Contributor

Now that I look at it, this may be a different issue. If we look at ExprNodes.def, UnresolvedDeclRef used to be in line 90, but is now line 93.
I'm hitting UnresolvedDot in line 104 in the same file.

@AnthonyLatsis AnthonyLatsis added type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances associated type inference protocol Feature → type declarations: Protocol declarations typealias Feature → type declarations: `typealias` declarations unexpected error Bug: Unexpected error declarations Feature: declarations swift 5.9 and removed crash Bug: A crash, i.e., an abnormal termination of software labels May 2, 2023
@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented May 2, 2023

Apparently this no longer crashes, but still unexpectedly errors out due to what feels like a circularity between associated type inference and type alias resolution.

Reduced:

protocol P {
  associatedtype A

  typealias Alias = A

  func req(_: Alias)
}

struct Conformer<A>: P {
  func nonReq(_: Alias) {}
  func req(_: Alias) {} // error: reference to invalid type alias 'Alias' of type 'Conformer<A>'
}

Funnily enough the error can be hacked around by swapping nonReq and req (performEffect and perform(effect:) in the original example).


Tested with Swift 5.9-dev (c1d5118).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
associated type inference bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances declarations Feature: declarations protocol Feature → type declarations: Protocol declarations swift 5.9 type checker Area → compiler: Semantic analysis typealias Feature → type declarations: `typealias` declarations unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

6 participants
@slavapestov @belkadan @swift-ci @AnthonyLatsis @fibrechannelscsi and others