Selaa lähdekoodia

treat abstracts over {} as special case for structure declarations (closes #3029)

Simon Krajewski 11 vuotta sitten
vanhempi
commit
d9ac9c2e14
2 muutettua tiedostoa jossa 12 lisäystä ja 1 poistoa
  1. 11 0
      tests/unit/issues/Issue3029.hx
  2. 1 1
      typer.ml

+ 11 - 0
tests/unit/issues/Issue3029.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+private abstract TemplateData({}) from {} to {} { }
+
+class Issue3029 extends Test {
+	function test() {
+        var t1:TemplateData = {};
+        var t2:TemplateData = { name: "jason" };
+		eq("jason", Reflect.field(t2,"name"));
+	}
+}

+ 1 - 1
typer.ml

@@ -2711,7 +2711,7 @@ and type_expr ctx (e,p) (with_type:with_type) =
 			| TAnon a when not (PMap.is_empty a.a_fields) -> Some a
 			| TAbstract (a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
 				begin match follow (Codegen.Abstract.get_underlying_type a tl) with
-					| TAnon a -> Some a
+					| TAnon a when not (PMap.is_empty a.a_fields) -> Some a
 					| _ -> None
 				end
 			| _ -> None)