소스 검색

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

Justin Donaldson 9 년 전
부모
커밋
2ab2967b91
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  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;