Jelajahi Sumber

[lua] fix array.shift for lua 5.3

Justin Donaldson 8 tahun lalu
induk
melakukan
9bd0102b16
1 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 2
      std/lua/_std/Array.hx

+ 6 - 2
std/lua/_std/Array.hx

@@ -65,8 +65,12 @@ class Array<T> {
 	public function shift() : Null<T> {
 		if (this.length == 0) return null;
 		var ret = this[0];
-		this[0] = this[1];
-		lua.Table.remove(untyped this,1);
+		if (this.length == 1){
+			this[0] = null;
+		} else if (this.length > 1) {
+			this[0] = this[1];
+			lua.Table.remove(untyped this,1);
+		}
 		this.length-=1;
 		return ret;
 	}