Fix bug in compiler affecting functions with many locals.
This commit is contained in:
38
test/lua/manyupvals.lua
Normal file
38
test/lua/manyupvals.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
local t = {}
|
||||
local template = [[
|
||||
local f<i>
|
||||
do
|
||||
local result
|
||||
function f<i>()
|
||||
if not result then
|
||||
result = f<i-2>() + f<i-1>()
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
]]
|
||||
t[1] = [[
|
||||
local f1
|
||||
f1 = function() return 1 end
|
||||
]]
|
||||
t[2] = [[
|
||||
local f2
|
||||
f2 = function() return 1 end
|
||||
]]
|
||||
for i = 3, 199 do
|
||||
t[i] = template:gsub("<([^>]+)>", function(s)
|
||||
local c = assert(loadstring('return '..s), 'could not compile: '..s)
|
||||
setfenv(c, { i = i })
|
||||
return c()
|
||||
end)
|
||||
end
|
||||
t[200] = [[
|
||||
print("5th fibonacci number is", f5())
|
||||
print("10th fibonacci number is", f10())
|
||||
print("199th fibonacci number is", f199())
|
||||
]]
|
||||
|
||||
local s = table.concat(t)
|
||||
print(s)
|
||||
f = loadstring(s)
|
||||
f()
|
||||
Reference in New Issue
Block a user