Skip to content

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

Open
@swift-ci

Description

@swift-ci
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    associated type inferencebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfconformancesFeature → protocol: protocol conformancesdeclarationsFeature: declarationsprotocolFeature → type declarations: Protocol declarationsswift 5.9type checkerArea → compiler: Semantic analysistypealiasFeature → type declarations: `typealias` declarationsunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions