Possible Bug: Swift Closures Unable to Infer Types

Let's take a very simple example! We have a struct called Person which is defined below: 

struct Person {
    
    var firstName :String
    var lastName :String
    var active :Bool
}

And it is populated with some dummy values using the code below: 

var persons :[Person] = []

for var i = 1; i<=10; i++ {
    
    var person = Person(firstName: "John \(i)", lastName: "Doe \(i)", active: true)
    persons.append(person)
}

Now, I want to change the active property from true to false using the map function .. So, I write the code like this: 

let inActivePersons = persons.map { (var p) in
    
    p.active = false
    return p
}

The above code results with the following error message: 

Cannot invoke 'map' with an argument list of type @noescape Person. 

The error can be fixed by explicitly adding the returned type as shown below:

let inActivePersons = persons.map { (var p) -> Person in
    
    p.active = false
    return p
}

But it only requires the return type if I am changing the value of the element. The following code will work and as you can see it does not have any return type: 

let inActivePersons = persons.map { (var p) in

    p
    
}

And even this will work: 

let inActivePersons = persons.map {
    
    $0
}

But this WILL NOT WORK: 

let inActivePersons = persons.map {
    
    print("Hmm")
    return $0
}

Another thing I noted is that when you are using $0 syntax in a closure there is no way to define $0 as a var variable! If there is please let me know!