Browse Source

(Python) do not generate None initializations for omitted optional structure fields (closes #2928)

Simon Krajewski 11 years ago
parent
commit
c7a630d15c
2 changed files with 12 additions and 2 deletions
  1. 2 2
      genpy.ml
  2. 10 0
      tests/unit/issues/Issue2928.hx

+ 2 - 2
genpy.ml

@@ -1398,11 +1398,11 @@ module Generator = struct
 	(* Transformer interface *)
 
 	let transform_expr e =
-		let e = Codegen.UnificationCallback.run Transformer.check_unification e in
+		(* let e = Codegen.UnificationCallback.run Transformer.check_unification e in *)
 		Transformer.transform e
 
 	let transform_to_value e =
-		let e = Codegen.UnificationCallback.run Transformer.check_unification e in
+		(* let e = Codegen.UnificationCallback.run Transformer.check_unification e in *)
 		Transformer.transform_to_value e
 
 	(* Printer interface *)

+ 10 - 0
tests/unit/issues/Issue2928.hx

@@ -0,0 +1,10 @@
+package unit.issues;
+
+class Issue2928 extends Test {
+	function test() {
+		var r:{?a:Int} = {};
+		f(Reflect.hasField(r, "a"));
+		eq(null, r.a);
+		eq(0, Reflect.fields(r).length);
+	}
+}