Prechádzať zdrojové kódy

fix UInt.toString() for null in non-static targets
fixes #8716

Aleksandr Kuzmenko 6 rokov pred
rodič
commit
98249d0ab9
2 zmenil súbory, kde vykonal 18 pridanie a 0 odobranie
  1. 4 0
      std/UInt.hx
  2. 14 0
      tests/unit/src/unit/issues/Issue8716.hx

+ 4 - 0
std/UInt.hx

@@ -299,7 +299,11 @@ abstract UInt(Int) from Int to Int {
 
 	// TODO: radix is just defined to deal with doc_gen issues
 	private inline function toString(?radix:Int):String {
+		#if static
 		return Std.string(toFloat());
+		#else
+		return Std.string(this == null ? null : toFloat());
+		#end
 	}
 
 	private inline function toInt():Int {

+ 14 - 0
tests/unit/src/unit/issues/Issue8716.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+private enum abstract JsonTypeKind<T>(String) {
+	var TMono;
+}
+
+class Issue8716 extends unit.Test {
+#if !static
+	function test() {
+		var u:UInt = null;
+		eq('null', '$u');
+	}
+#end
+}