Confused function's outer
If a function is defined in an assignment (f = function...end function), its outer is the current locals. If a function is defined in a statement call (print function...end function) or after a return, its outer is globals.
Does it need to be fixed or described as a feature in the docs?
x = "bye"
f = function(x)
ff = function
print outer.x
end function
ff
end function
f "hi" // hi
f2 = function(x)
m = {"ff": "ff"}
m.replace "ff", function
print outer.x
end function
m.ff
end function
f2 "hi" // bye
f3 = function(x)
return function
print outer.x
end function
end function
a = f3("hi")
a // bye
Umm, I remember we had drawn the conclusion before that the outer space of an anonymous function is always globals, wherever it is defined.
https://discord.com/channels/646000428441534474/646000428441534478/1165859154590699541
That's right. But this might naturally change when we change how functions are parsed (#100). So, let's leave this ticket open to remind us to consider this behavior carefully.