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-12313] Nested Dynamic Member Subscripts #54743

Closed
swift-ci opened this issue Mar 4, 2020 · 4 comments
Closed

[SR-12313] Nested Dynamic Member Subscripts #54743

swift-ci opened this issue Mar 4, 2020 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 4, 2020

Previous ID SR-12313
Radar rdar://problem/60230502
Original Reporter Wildchild9 (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee Wildchild9 (JIRA)
Priority Medium

md5: 8e1d1d6a047ddb90e998aaec66deab25

Issue Description:

@dynamicMemberLookup
struct A {
    var foo = [String]()
    subscript(dynamicMember member: String) -> A {
        A(foo: foo + [member])
    }
    subscript(dynamicMember keyPath: KeyPath<B, B>) -> A {
        A(foo: foo + B()[keyPath: keyPath].bar)
    }
}


@dynamicMemberLookup
struct B {
    var bar = [String()]
    subscript(dynamicMember member: String) -> B {
        B(bar: bar + [member])
    }
}


let a = A().hello.world

Potential Source of Error

I am pretty sure that this error occurs because, since A has a dynamic member subscript that takes KeyPath<B, B>, there is a conflict between the dynamic member subscripts that take a string defined on A and B.

Xcode Response

This makes Xcode display a banner saying "An internal error occurred. Source editor functionality is limited. Attempting to restore...". When running it, a "Segmentation fault: 11" error is emitted (the build log is attached).

Environment

I found this bug to be present from Xcode Version 11.3.1 (11C504) to Xcode Version 11.4 beta 3 (11N132i).

@beccadax
Copy link
Contributor

beccadax commented Mar 9, 2020

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by Noah Wilder (JIRA)

I isolated the bug from my much larger project and updated the issue accordingly.

@beccadax
Copy link
Contributor

Thank you for the short reproducer! Judging by the failure you get with a nightly toolchain, this looks like a bug in the type checker.

@xedin
Copy link
Member

xedin commented Mar 26, 2020

Fixed by #30646 Wildchild9 (JIRA User) Please use next available master snapshot to verify and close.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants