Fix bug in compiler affecting functions with many locals.

This commit is contained in:
Ian Farmer
2010-07-25 20:47:54 +00:00
parent ea931c1438
commit 97b4162423
5 changed files with 47 additions and 8 deletions

38
test/lua/manyupvals.lua Normal file
View 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()