Local function redefinition: feature or bug?

Please quote your code with backticks

This is indeed confusing and is a real change since earlier Julia versions: https://github.com/JuliaLang/julia/issues/15602#issuecomment-200410836

Fortunately, it’s also very easy to fix by using an anonymous function instead (which will perform just as well):

julia> function t()
         f = () -> 1
         print(f())
         f = () -> 2
         print(f())
       end
t (generic function with 1 method)

julia> t()
12