-
Notifications
You must be signed in to change notification settings - Fork 622
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
SwiftFormat 0.54.0: redundantSelf rule adds invalid "self." prefix #1729
Comments
@yanniks I'm not able to reproduce the bug with the code sample you've provided. Can you double check? |
Hi @nicklockwood , thanks for looking into this! I have investigated this once more and found out that the issue only occurs if the struct MyView: View {
@Environment(ViewModel.self) var viewModel
var body: some View {
@Bindable var viewModel = self.viewModel
ZStack {
MySubview(
navigationPath: $viewModel.navigationPath
)
}
}
} I have created a GitHub repo that includes an example project which reproduces the issue, including the |
@yanniks fixed in 0.54.1 |
After updating to SwiftFormat 0.54.0, we're facing an issue where an invalid
self.
prefix is added a variable reference.In our example, we're retrieving a view model from the environment and are using
@Bindable
inside the view to get a bindable reference, like in the following example:What happens with SwiftFormat 0.54.0, the
redundantSelf
rule now inserts aself.
before the$viewModel.navigationPath
which results in the following code:Unfortunately, as
self.viewModel
is not aBinding
, the compilation fails. The issue does not occur with SwiftFormat 0.53.10.The text was updated successfully, but these errors were encountered: