This code compiles fine on XCode 12.5.1 and 13
private func maskOtherLocalAccount(number: String?) -> String {
guard let number = number, number.count > 5 else { return number ?? "-"}
}
But on XCode 12.4, it gives this compile error:
Variable declared in 'guard' condition is not usable in its body
Though the fix is quite easy, I find it really strange that it works on XCode 12.5.1 and not on 12.4.
Can someone point to an official changelog documenting this change?
>Solution :
This is reported by SR-8669:
If you attempt to use a guard statement to declare a variable that shadows an existing variable, a compiler error prevents you from accessing the existing variable in the body of the guard.
This is already marked resolved almost a whole year ago, which matches the release date of Xcode 12.5.