I think the subtlety here is that:
let x = ...
behaves differently than
let
x = ...
For example:
julia> let
x = 1
let x = 2
x = 3
end
@show x
end
x = 1
1
julia> let
x = 1
let
x = 2
x = 3
end
@show x
end
x = 3
3
The same issue is discussed in Variable declarations within let blocks
I actually don’t think the manual is very clear on this topic: Scope of Variables · The Julia Language
In particular, it says
An assignment modifies an existing value location, and
let
creates new locations. This difference is usually not important, and is only detectable in the case of variables that outlive their scope via closures.
I think something like the answer from Variable declarations within let blocks would be a good addition to that section of the manual.