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-7418] Generic subscript crash when witness is more abstract than requirement #49961

Closed
slavapestov opened this issue Apr 12, 2018 · 5 comments
Assignees
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

@slavapestov
Copy link
Member

Previous ID SR-7418
Radar rdar://problem/39364768
Original Reporter @slavapestov
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @rjmccall
Priority Medium

md5: 476c482fcc53a3fe5635b0686f1bc69e

Issue Description:

protocol P {
  subscript<T : Y>(_: T) -> Int { get set }
}

struct Q : P {
  subscript<T : X>(_ idx: T) -> Int {
    get { return 0 } set { idx.foo() }
  }
}
protocol Y : X {}
protocol X { func foo() }

struct Idx : Y {
  func foo() { print("Hello world") }
}

func foo<T : P>(_ t: inout T) {
  t[Idx()] += 1
}

var q = Q()
foo(&q)

The materializeForSet callback has an incompatible generic signature from the protocol requirement, because it expects the conformance to X but receives the conformance to Y.

@slavapestov
Copy link
Member Author

@rjmccall I'm assuming that coroutines will "just work" here, because the generic environment will be saved in the context and not passed to the continuation.

@slavapestov
Copy link
Member Author

@swift-ci create

@jckarter
Copy link
Member

#15890 should address this in the short term, but we might want to keep this ticket open as a reminder. If coroutines don't make the cut, we should look into making the materializeForSet ABI pass the generic environment through the context to systematically address this class of problems.

@rjmccall
Copy link
Member

Yes, I would expect coroutines to solve this.

@rjmccall
Copy link
Member

This is fixed.

@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

4 participants