This is a mean to catch typos, not to write "Pure functions". I.e. it is designed to catch something like:
local anupvalue="upvalue"
function test()
local print=print
do <erroronfreename>
print("anupvalue=",AnUpvalue) -- error
end
end
test()
Yes, this is already covered by static.lua, but at runtime.
I think that you can avoid upvalues too with small changes. I tryed to do it in the attached patch, but since it was not my goal, I performed very minimal tests only. Please note:
- I kept the <erroronfreename> attribute, also if an upvalue name is not a free name
- _ENV is an upvalue, so you can no more access it anymore (copy it to a local if you need).