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-11579] Compiler error when adding keypath @dynamicMemberLookup to protocol extension #53984

Closed
swift-ci opened this issue Oct 7, 2019 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 7, 2019

Previous ID SR-11579
Radar None
Original Reporter glassomoss (JIRA User)
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 3fc20d850ccd3dcea6565567feb66ede

Issue Description:

When I am trying to implement @dynamicMemberLookup subscript having both protocol requirement and default implementation in extension, compiler produces a segfault 11 and "Command CompileSwift failed with a nonzero exit code".

struct Context {
    var points: [Int]
}

@dynamicMemberLookup
protocol Proxy: class {
    var context: Context { get set }
    
    subscript<T>(dynamicMember keyPath: WritableKeyPath<Context, T>) -> T { get set }
}

extension Proxy {
    subscript<T>(dynamicMember keyPath: WritableKeyPath<Context, T>) -> T {
        get {
            context[keyPath: keyPath]
        }
        set(newValue) {
            context[keyPath: keyPath] = newValue
        }
    }

}

However, in Xcode 11.0 GM Seed it was at least working correctly in playground. In Xcode 11.1 GM Seed (11A1027) it's not working in pg either: just running endlessly. The only way to make it work is to remove default implementation from extension, which in fact is rightly the opposite situation to SR-8077

@theblixguy
Copy link
Collaborator

Works for me on Xcode 11.1 GM, see: https://i.imgur.com/NUOAn03.png

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 7, 2019

Comment by Mefodiy Akatov (JIRA)

@theblixguy, thank you, I've tried your code and suddenly it started working in playground, but still have you tried inserting that in any Xcode project and compiling it?

@theblixguy
Copy link
Collaborator

Interesting, I get a crash when I put it in an Xcode project but not in Playgrounds:

Assertion failed: (Val && "isa<> used on a null pointer"), function doit, file /Users/buildnode/jenkins/workspace/oss-swift-5.1-package-osx/llvm/include/llvm/Support/Casting.h, line 106.

1.  While walking into decl extension of Proxy (at /Users/suyashsrijan/Documents/Playgrounds/SuperInit/Test1234/Test1234/ViewController.swift:19:1)
0  swift                    0x000000010f88c0a5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010f88b395 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010f88c688 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff69a23b1d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000115a10268 _sigtramp + 2885601128
5  libsystem_c.dylib        0x00007fff698f9a08 abort + 120
6  libsystem_c.dylib        0x00007fff698f8cc2 err + 0
7  swift                    0x000000010fbab971 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) (.cold.41) + 33
8  swift                    0x000000010c96ff48 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 10440
9  swift                    0x000000010c90a1b6 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 1126
10 swift                    0x000000010c90a945 swift::constraints::ConstraintSystem::simplifyDisjunctionChoice(swift::constraints::Constraint*) + 21
11 swift                    0x000000010c919ea9 swift::constraints::DisjunctionChoice::attempt(swift::constraints::ConstraintSystem&) const + 25
12 swift                    0x000000010c924d0e swift::constraints::DisjunctionStep::attempt(swift::constraints::DisjunctionChoice const&) + 158
13 swift                    0x000000010c92441f swift::constraints::BindingStep<swift::constraints::DisjunctionChoiceProducer>::take(bool) + 591
14 swift                    0x000000010c914192 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl<swift::constraints::Solution>&) + 354
15 swift                    0x000000010c913f7f swift::constraints::ConstraintSystem::solveSingle(swift::FreeTypeVariableBinding, bool) + 95
16 swift                    0x000000010c8dddf0 swift::resolveValueMember(swift::DeclContext&, swift::Type, swift::DeclName) + 448
17 swift                    0x000000010c2eda8a swift::canDeclProvideDefaultImplementationFor(swift::ValueDecl*, llvm::SmallVectorImpl<swift::ValueDecl*>&) + 138
18 swift                    0x000000010c2edd33 swift::getOverriddenDecls(swift::ValueDecl*, bool, bool) + 211
19 swift                    0x000000010c2eead6 (anonymous namespace)::IndexSwiftASTWalker::walkToDeclPre(swift::Decl*, swift::CharSourceRange) + 1318
20 swift                    0x000000010c2a08a4 (anonymous namespace)::SemaAnnotator::walkToDeclPre(swift::Decl*) + 1524
21 swift                    0x000000010ccc98ea (anonymous namespace)::Traversal::doIt(swift::Decl*) + 170
22 swift                    0x000000010ccce64b swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 1083
23 swift                    0x000000010ccc9917 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 215
24 swift                    0x000000010ccc982b swift::Decl::walk(swift::ASTWalker&) + 27
25 swift                    0x000000010cd824ba swift::SourceFile::walk(swift::ASTWalker&) + 170
26 swift                    0x000000010c29ebdd swift::SourceEntityWalker::walk(swift::SourceFile&) + 253
27 swift                    0x000000010c2ee3a2 (anonymous namespace)::IndexSwiftASTWalker::visitModule(swift::ModuleDecl&) + 370
28 swift                    0x000000010c2ee1fa swift::index::indexSourceFile(swift::SourceFile*, swift::index::IndexDataConsumer&) + 442
29 swift                    0x000000010c2f43e6 recordSourceFileUnit(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, llvm::ArrayRef<clang::FileEntry const*>, clang::CompilerInstance const&, swift::DiagnosticEngine&) + 1558
30 swift                    0x000000010c2f3d6b swift::index::indexAndRecord(swift::SourceFile*, llvm::StringRef, llvm::StringRef, bool, bool, llvm::StringRef, swift::DependencyTracker const&) + 219
31 swift                    0x000000010c03e548 emitIndexDataIfNeeded(swift::SourceFile*, swift::CompilerInvocation const&, swift::CompilerInstance&) + 328
32 swift                    0x000000010c03968a performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 14074
33 swift                    0x000000010c03506a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3002
34 swift                    0x000000010bfddb18 main + 696
35 libdyld.dylib            0x00007fff69822405 start + 1
36 libdyld.dylib            0x0000000000000048 start + 2524830788

@swift-ci
Copy link
Collaborator Author

swift-ci commented Oct 7, 2019

Comment by Mefodiy Akatov (JIRA)

@theblixguy, that's it! I'm getting the same thing all the time in any project

@theblixguy
Copy link
Collaborator

I think this has already been fixed by @DougGregor's PR: #27127

@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
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 crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

3 participants