If I try to assign to a pre-existing function name in the global scope, I get a reasonable error:
function foo(x) x end foo = foo(7) # ERROR: invalid redefinition of constant foo # Stacktrace: #  top-level scope at none:0
But if I do the same inside a function, I get an
function bar(x) foo = foo(x) x end bar(7) # ERROR: UndefVarError: foo not defined # Stacktrace: #  bar(::Int64) at ./REPL:2 #  top-level scope at none:0
"UndefVarError: foo not defined" does not make much sense to me, and makes the cause of the above exception much less obvious. Is this the expected exception here? If so, can someone explain to me why that’s the expected exception, instead of something like
"ERROR: invalid redefinition of constant foo"?