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-12019] Assert when calling dynamicallyCall(withArguments:) and parameter does not satisfy generic constraint #54456

Closed
swift-ci opened this issue Jan 13, 2020 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12019
Radar rdar://problem/58861161
Original Reporter owenvoorhees (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

master branch: 667fc05 (~Jan 7, 2020)

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

md5: cc225f930e48653d5fdb48fa8e8252b1

Issue Description:

Reduced test case:

@dynamicCallable public struct A {
    func dynamicallyCall<T: StringProtocol>(withArguments: [T]) {
        print("hi") 
    }
}


let a = A()
a(1)

Crash (w/ asserts enabled):

Assertion failed: (getRequirementDC() && "Couldn't find where the requirement came from?"), function RequirementFailure, file /Users/owenvoorhees/Documents/Development/swift-source/swift/lib/Sema/CSDiagnostics.h, line 227.Assertion failed: (getRequirementDC() && "Couldn't find where the requirement came from?"), function RequirementFailure, file /Users/owenvoorhees/Documents/Development/swift-source/swift/lib/Sema/CSDiagnostics.h, line 227.Stack dump:0. Program arguments: /Users/owenvoorhees/Documents/Development/swift-source/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift -frontend -interpret /Users/owenvoorhees/Desktop/hello.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name hello1. Swift version 5.2-dev (Swift b1aa6b8aa7)2. While evaluating request TypeCheckSourceFileRequest(source_file "/Users/owenvoorhees/Desktop/hello.swift", 0)3. While type-checking statement at [/Users/owenvoorhees/Desktop/hello.swift:8:1 - line:8:4] RangeText="a(1"4. While type-checking expression at [/Users/owenvoorhees/Desktop/hello.swift:8:1 - line:8:4] RangeText="a(1"0  swift                    0x0000000111ae8c65 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 371  swift                    0x0000000111ae7bd8 llvm::sys::RunSignalHandlers() + 2482  swift                    0x0000000111ae9266 SignalHandler(int) + 2783  libsystem_platform.dylib 0x00007fff7060342d _sigtramp + 294  libsystem_platform.dylib 0x0000000000004f60 _sigtramp + 24096346405  libsystem_c.dylib        0x00007fff704d8a1c abort + 1206  libsystem_c.dylib        0x00007fff704d7cd6 err + 07  swift                    0x0000000111d94a53 swift::constraints::RequirementFailure::RequirementFailure(swift::constraints::ConstraintSystem&, swift::Type, swift::Type, swift::constraints::ConstraintLocator*) (.cold.3) + 358  swift                    0x000000010e4920b6 swift::constraints::RequirementFailure::RequirementFailure(swift::constraints::ConstraintSystem&, swift::Type, swift::Type, swift::constraints::ConstraintLocator*) + 3909  swift                    0x000000010e491e5e swift::constraints::MissingConformanceFailure::MissingConformanceFailure(swift::constraints::ConstraintSystem&, swift::constraints::ConstraintLocator*, std::__1::pair<swift::Type, swift::Type>) + 3010 swift                    0x000000010e48b6de swift::constraints::MissingConformance::diagnose(bool) const + 7811 swift                    0x000000010e3ff24e swift::constraints::ConstraintSystem::applySolutionFixes(swift::constraints::Solution const&) + 193412 swift                    0x000000010e3ffa17 swift::constraints::ConstraintSystem::applySolutionImpl(swift::constraints::Solution&, swift::constraints::SolutionApplicationTarget, swift::Type, bool, bool) + 7113 swift                    0x000000010e55d9f9 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 95314 swift                    0x000000010e55d62b swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 10715 swift                    0x000000010e5febbd swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 777316 swift                    0x000000010e5fb870 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 12817 swift                    0x000000010e5fb975 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 18118 swift                    0x000000010e6286af swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*, unsigned int) const + 38319 swift                    0x000000010e5f8175 swift::SimpleRequest<swift::TypeCheckSourceFileRequest, bool (swift::SourceFile*, unsigned int), (swift::CacheKind)2>::evaluateRequest(swift::TypeCheckSourceFileRequest const&, swift::Evaluator&) + 2120 swift                    0x000000010e62b6ac llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 36421 swift                    0x000000010e62b468 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 5622 swift                    0x000000010e62a59b llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 10723 swift                    0x000000010e628425 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 3724 swift                    0x000000010dd3b3c5 swift::CompilerInstance::parseAndTypeCheckMainFileUpTo(swift::SourceFile::ASTStage_t) + 53325 swift                    0x000000010dd3a032 swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t) + 41826 swift                    0x000000010dd3989e swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 62227 swift                    0x000000010db1a4a6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 202228 swift                    0x000000010db18d33 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 513929 swift                    0x000000010dab4cfe main + 73430 libdyld.dylib            0x00007fff7040a7fd start + 1Abort trap: 6
@swift-ci
Copy link
Collaborator Author

Comment by Owen Voorhees (JIRA)

I haven't had time to investigate much, but I think this is the dynamic version of https://bugs.swift.org/browse/SR-11386

@beccadax
Copy link
Contributor

@swift-ci create

@LucianoPAlmeida
Copy link
Collaborator

Anyone working on this? I can take a look owenvoorhees (JIRA User) 🙂)

@LucianoPAlmeida
Copy link
Collaborator

Here is the PR #30277

@LucianoPAlmeida
Copy link
Collaborator

owenvoorhees (JIRA User) Can you please check and close? 🙂

@swift-ci
Copy link
Collaborator Author

Comment by Owen Voorhees (JIRA)

I can confirm this is fixed now. Thanks @LucianoPAlmeida!

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants