浏览代码

Lua: Add some null guards in Reflect.compare

Justin Donaldson 9 年之前
父节点
当前提交
a12528e371
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      std/lua/_std/Reflect.hx

+ 5 - 2
std/lua/_std/Reflect.hx

@@ -98,7 +98,10 @@ import lua.Boot;
 	}
 	}
 
 
 	public static function compare<T>( a : T, b : T ) : Int {
 	public static function compare<T>( a : T, b : T ) : Int {
-		return ( a == b ) ? 0 : (((cast a) > (cast b)) ? 1 : -1);
+		if (a == b) return 0
+		else if (a == null) return -1
+		else if (b == null) return 1
+		else return (cast a) > (cast b) ? 1 : -1;
 	}
 	}
 
 
 	public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool {
 	public static function compareMethods( f1 : Dynamic, f2 : Dynamic ) : Bool {
@@ -113,7 +116,7 @@ import lua.Boot;
 	}
 	}
 
 
 	public static function isEnumValue( v : Dynamic ) : Bool {
 	public static function isEnumValue( v : Dynamic ) : Bool {
-		return v != null && v.__enum__ != null;
+		return v != null && Std.is(v,lua.Table) && v.__enum__ != null;
 	}
 	}
 
 
 	public static function deleteField( o : Dynamic, field : String ) : Bool untyped {
 	public static function deleteField( o : Dynamic, field : String ) : Bool untyped {