Skip to content

[SR-11579] Compiler error when adding keypath @dynamicMemberLookup to protocol extension #53984

@swift-ci

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of software

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions