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-14082] Improve diagnostic on field name mismatch when using keypaths/property wrappers #56471

Open
typesanitizer opened this issue Jan 22, 2021 · 1 comment
Labels
compiler The Swift compiler in itself improvement

Comments

@typesanitizer
Copy link

Previous ID SR-14082
Radar rdar://problem/73482382
Original Reporter @typesanitizer
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement
Assignee None
Priority Medium

md5: e30a9df3ce3556174247cabd938e3797

Issue Description:

import SwiftUI

struct X {
  var myCoolField: Int
}

struct U: View {
  @Binding var a: Int
  var body: some View { Spacer() }
}

struct V: View {
  @State var x: X
  var body: some View {
    U(a: $x.myField) // error: value of type 'Binding<X>' has no dynamic member 'myField' using key path from root type 'X'
  }
}

We should try to improve this diagnostic, it is not obvious why it is saying "dynamic member" and "key path", even though the user has not written any dynamic member or key paths in their code. Maybe we can detect the typo and offer a fix-it with a rename?

@typesanitizer
Copy link
Author

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement
Projects
None yet
Development

No branches or pull requests

1 participant