Unexpected Core.Box from functions within a function

It seems re-assigning to the variable used for the name of the closure is allowed:

function demo()
    function f()
    end
    f = 1
    f
end

So, function act2! acts like an assignment, too. Using the “let hack” seems to fix the problem:

function g3(A2)
    function act2!(B4, A4, ax4)
        for i in ax4
            B4[i] = A4[i]
        end
        nothing
    end
    make2 = let act2! = act2!
        function make2(A3)
            B3 = similar(A3)
            act2!(B3, A3, axes(A3, 1))
            B3
        end
    end
    B2 = make2(A2)
end
4 Likes