And what if you go ahead and also fix tabSymbol.title to tabSymbol.description? Wouldn't be the first time the compiler gets confused and throws an unrelated error at you.
You are right! That fixed the problem. So the compile error is at that wrong place. This could be due to how ViewBuilder work or some kind of compiler bug?
I did try to use Refactor/Rename to change the property name but Xcode refactor failed.
I'd call it a bug in the sense that this error message is totally unhelpful for solving the 'real' underlying issue which seems like it could have been arbitrarily distant from the error location. I've definitely experienced this more with SwiftUI where the compiler gets confused typechecking the monster expressions that view body properties end up containing.
I have had similar experiences recently. Below is a very simple example, where error locations are marked with (1), (2), and (3).
ForEach (filteredRegions) { region in // (1)
NavigationLink {
RegionDetail (region: region) // (2)
} label: {
Text (region.name) // (3)
}
}
// (1) Cannot convert value of type '[Region]' to expected argument type 'Binding<C>'
// Generic parameter 'C' could not be inferred
// (2) Cannot convert value of type 'Binding<C.Element>' to expected argument type 'Region'
// (3) Initializer 'init(_:)' requires that 'Binding<Subject>' conform to 'StringProtocol'
Can you guess what is causing these errors?
I scratched my had several hours, trying to figure out what is causing them.
The real culprit is sitting on this line:
Text (region.name) // (3)
region didn't have a name property.
I am wondering what causes the compiler not to say so in this instance.