Browse Source

Lua: fix var arg iteration in new __anon method

Justin Donaldson 9 years ago
parent
commit
d2e34160b2
1 changed files with 3 additions and 3 deletions
  1. 3 3
      genlua.ml

+ 3 - 3
genlua.ml

@@ -1670,11 +1670,11 @@ let generate com =
 
 
 	spr ctx "__anon = function(...)"; newline ctx;
 	spr ctx "__anon = function(...)"; newline ctx;
 	spr ctx "   local ret = {__fields = {}};"; newline ctx;
 	spr ctx "   local ret = {__fields = {}};"; newline ctx;
-	spr ctx "   local fld = {...};"; newline ctx;
-	spr ctx "   for i,v in ipairs(fld) do"; newline ctx;
+	spr ctx "   for i=1, select('#', ...) do"; newline ctx;
+	spr ctx "	local v = select(i,...);"; newline ctx;
 	spr ctx "	if i % 2 == 1 then "; newline ctx;
 	spr ctx "	if i % 2 == 1 then "; newline ctx;
 	spr ctx "	    ret.__fields[v] = true;"; newline ctx;
 	spr ctx "	    ret.__fields[v] = true;"; newline ctx;
-	spr ctx "	    ret[v] =fld[i+1];"; newline ctx;
+	spr ctx "	    ret[v] =select(i+1,...);"; newline ctx;
 	spr ctx "	end"; newline ctx;
 	spr ctx "	end"; newline ctx;
 	spr ctx "   end"; newline ctx;
 	spr ctx "   end"; newline ctx;
 	spr ctx "   setmetatable(ret, {__newindex=function(t,k,v) t.__fields[k] = true; rawset(t,k,v); end})"; newline ctx;
 	spr ctx "   setmetatable(ret, {__newindex=function(t,k,v) t.__fields[k] = true; rawset(t,k,v); end})"; newline ctx;