Răsfoiți Sursa

Lua: __newindex function needs to reference t.length instead of just length

Justin Donaldson 9 ani în urmă
părinte
comite
2ab2967b91
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      genlua.ml

+ 1 - 1
genlua.ml

@@ -1751,7 +1751,7 @@ let generate com =
 	spr ctx "   setmetatable(tab, {"; newline ctx;
 	spr ctx "	__index = Array.prototype,"; newline ctx;
 	spr ctx "	__newindex = function(t,k,v)"; newline ctx;
-	spr ctx "	    if _G.type(k) == 'number' and k >= length then"; newline ctx;
+	spr ctx "	    if _G.type(k) == 'number' and k >= t.length then"; newline ctx;
 	spr ctx "		t.length = k + 1"; newline ctx;
 	spr ctx "	    end"; newline ctx;
 	spr ctx "	    rawset(t,k,v)"; newline ctx;