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-14893] Assertion failed: (underlyingType) in ConstraintSystem::buildDisjunctionForOptionalVsUnderlying #57240

Closed
ahoppen opened this issue Jul 7, 2021 · 1 comment

Comments

@ahoppen
Copy link
Collaborator

@ahoppen ahoppen commented Jul 7, 2021

Previous ID SR-14893
Radar rdar://80271666
Original Reporter @ahoppen
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 1e001e8e2a637dc8d1d9773ff1d28e77

Issue Description:

Typechecking the following code hits an assertion in the type checker.

enum Category {
    case first
}

protocol View2 {}

extension View2 {
    func sag(_ tag: Category) -> some View2 {
        fatalError()
    }
}

@resultBuilder public struct ViewBuilder2 {
  static func buildBlock<Content>(_ content: Content) -> Content where Content : View2 { fatalError() }
}

@frozen public struct Fmage : View2 {
}

struct UserListFormView {
    @ViewBuilder2 var body: some View2 {
        let icon: Category! = Category.first
        Fmage(icon).sag()
    }
}

Stack trace:

Stack dump:
0.  Program arguments: ./swift-frontend -typecheck /Users/alex/swift-src/swift/test/SourceKit/test.swift
1.  Swift version 5.5-dev (LLVM 3c96a2f1c42ab1c, Swift c3e9676cb1aac5d)
2.  
3.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/alex/swift-src/swift/test/SourceKit/test.swift")
4.  While evaluating request TypeCheckFunctionBodyRequest(test.(file).UserListFormView._@/Users/alex/swift-src/swift/test/SourceKit/test.swift:21:40)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010f5dc267 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010f5db148 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010f5dc896 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20552d7d _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603339973710496
5  libsystem_c.dylib        0x00007fff20462411 abort + 120
6  libsystem_c.dylib        0x00007fff204617e8 err + 0
7  swift-frontend           0x000000010fa3e763 swift::constraints::ConstraintSystem::buildDisjunctionForOptionalVsUnderlying(swift::Type, swift::Type, swift::constraints::ConstraintLocator*) (.cold.7) + 35
8  swift-frontend           0x000000010b7a9784 swift::constraints::ConstraintSystem::buildDisjunctionForOptionalVsUnderlying(swift::Type, swift::Type, swift::constraints::ConstraintLocator*) + 804
9  swift-frontend           0x000000010b79b331 swift::constraints::ConstraintSystem::bindOverloadType(swift::constraints::SelectedOverload const&, swift::Type, swift::constraints::ConstraintLocator*, swift::DeclContext*, llvm::function_ref<void (unsigned int, swift::Type, swift::constraints::ConstraintLocator*)>) + 2977
10 swift-frontend           0x000000010b79cde5 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 5269
11 swift-frontend           0x000000010b6caa29 swift::ASTVisitor<(anonymous namespace)::ConstraintGenerator, swift::Type, void, void, void, void, void>::visit(swift::Expr*) + 11449
12 swift-frontend           0x000000010b6c5e1b (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 171
13 swift-frontend           0x000000010bafec0b swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 315
14 swift-frontend           0x000000010bb00ee2 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 210
15 swift-frontend           0x000000010bafebdf swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 271
16 swift-frontend           0x000000010bb00e66 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 86
17 swift-frontend           0x000000010bafeb5d swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 141
18 swift-frontend           0x000000010bafe371 swift::Expr::walk(swift::ASTWalker&) + 81
19 swift-frontend           0x000000010b6c135d swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*, swift::DeclContext*, bool) + 237
20 swift-frontend           0x000000010b674458 (anonymous namespace)::BuilderClosureVisitor::captureExpr(swift::Expr*, bool, llvm::PointerUnion<swift::Stmt*, swift::Expr*>) + 104
21 swift-frontend           0x000000010b673496 (anonymous namespace)::BuilderClosureVisitor::visitBraceStmt(swift::BraceStmt*) + 1158
22 swift-frontend           0x000000010b66c24e swift::constraints::ConstraintSystem::matchResultBuilder(swift::AnyFunctionRef, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::constraints::ConstraintLocatorBuilder) + 1470
23 swift-frontend           0x000000010b66b310 swift::TypeChecker::applyResultBuilderBodyTransform(swift::FuncDecl*, swift::Type) + 784
24 swift-frontend           0x000000010b91eb49 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 281
25 swift-frontend           0x000000010bbf752c llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 428
26 swift-frontend           0x000000010bbf72a7 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 119
27 swift-frontend           0x000000010bb5b1d3 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 51
28 swift-frontend           0x000000010b955fed swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 333
29 swift-frontend           0x000000010b956f2d llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 429
30 swift-frontend           0x000000010b956cb2 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 114
31 swift-frontend           0x000000010b955d9e swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 46
32 swift-frontend           0x000000010ab7b9ce swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 158
33 swift-frontend           0x000000010ab7b87a swift::CompilerInstance::performSema() + 74
34 swift-frontend           0x000000010aa3aa9f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6367
35 swift-frontend           0x000000010a98bc66 main + 566
36 libdyld.dylib            0x00007fff20528f5d start + 1
37 libdyld.dylib            0x0000000000000003 start + 18446603339973882023
fish: Job 1, './swift-frontend -typecheck /Us…' terminated by signal SIGABRT (Abort)
@LucianoPAlmeida
Copy link
Collaborator

@LucianoPAlmeida LucianoPAlmeida commented Sep 3, 2021

Fixed by @xedin in #39096 and [#39142| #39142]

@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
Projects
None yet
Development

No branches or pull requests

2 participants