XCode 12.5.1 (or swift?) is allowing guard to shadow a previous variable

Viewed 110

On my setup (XCode 12.5.1), I am able to shadow a previously declared variable using a guard statement. On a colleagues setup (XCode 12.4), this fails for a reason that eludes me.

Why does the following pass on XCode 12.5.1, and not on XCode 12.4? Which change between the two version is allowing for this?

import UIKit

var strings: [String] = ["hello", "good day", "greetings"]

func greetings(greetings: [String]) {
    let hello = greetings.first

    guard let hello = greetings.first else {
        assertionFailure("faillure...")
        return
    }

    print(hello)
}

greetings(greetings: strings)
0 Answers
Related