Procházet zdrojové kódy

[lua] fix unshift for empty array

Justin Donaldson před 8 roky
rodič
revize
cb959daa4f
1 změnil soubory, kde provedl 1 přidání a 0 odebrání
  1. 1 0
      std/lua/_std/Array.hx

+ 1 - 0
std/lua/_std/Array.hx

@@ -131,6 +131,7 @@ class Array<T> {
 	}
 	}
 
 
 	public function unshift( x : T ) : Void {
 	public function unshift( x : T ) : Void {
+		if (this.length == 0) this[0] = x;
 		lua.Table.insert(untyped this, 1, x);
 		lua.Table.insert(untyped this, 1, x);
 		var tmp = this[0];
 		var tmp = this[0];
 		this[0] = this[1];
 		this[0] = this[1];