Identifiers recognition inside `do` blocks in Swift 3.1

Viewed 92

Swift seems to work out identifiers recognition line by line:

print(fox) // Error: Use of unresolved identifier 'fox'
let fox = ""

However, strange thing happens inside the do block:

do {
    print(dog) // Error: Use of local variable 'dog' before its declaration
    let dog = ""
}

How does the compiler know that I'm going to declare dog after trying to print it? Is identifier recognition handled differently inside do blocks?

2 Answers
Related