Просмотр исходного кода

[typer] remove check for extra fields on Const structures

closes #3192
closes #9597
Simon Krajewski 5 лет назад
Родитель
Сommit
889d7d17cc

+ 0 - 4
src/core/tUnification.ml

@@ -848,10 +848,6 @@ and unify_anons uctx a b a1 a2 =
 				| _ ->
 					error [has_no_field a n];
 		) a2.a_fields;
-		(match !(a1.a_status) with
-		| Const when not (PMap.is_empty a2.a_fields) ->
-			PMap.iter (fun n _ -> if not (PMap.mem n a2.a_fields) then error [has_extra_field a n]) a1.a_fields;
-		| _ -> ());
 		(match !(a2.a_status) with
 		| Statics c -> (match !(a1.a_status) with Statics c2 when c == c2 -> () | _ -> error [])
 		| EnumStatics e -> (match !(a1.a_status) with EnumStatics e2 when e == e2 -> () | _ -> error [])

+ 1 - 3
tests/misc/projects/Issue3192/compile1-fail.hxml.stderr

@@ -1,3 +1 @@
-Main1.hx:3: characters 19-33 : { b : Int, a : Int } has extra field b
-Main1.hx:3: characters 3-34 : { b : Int, a : Int } should be { a : Int }
-Main1.hx:3: characters 3-34 : { b : Int, a : Int } has extra field b
+Main1.hx:3: characters 19-33 : { b : Int, a : Int } has extra field b

+ 1 - 1
tests/unit/src/unit/issues/Issue3192.hx

@@ -8,7 +8,7 @@ class Issue3192 extends Test {
 		var y1:{} = x1;
 		var y2:{} = x2;
 		var y3:{} = x3;
-		// var z1:{x:Int} = x1;
+		var z1:{x:Int} = x1;
 		var z2:{x:Int} = x2;
 		var z3:{x:Int} = x3;
 		eq(1, x1.x);

+ 21 - 0
tests/unit/src/unit/issues/Issue9597.hx

@@ -0,0 +1,21 @@
+package unit.issues;
+import unit.Test;
+
+class Issue9597 extends Test {
+	function test() {
+		var data = [
+			{name: 'Page A', uv: 4000, pv: 2400, amt: 2400},
+			{name: 'Page B', uv: 3000, pv: 1398, amt: 2210},
+			{name: 'Page C', uv: -1000, pv: 9800, amt: 2290},
+			{name: 'Page D', uv: 500, pv: 3908, amt: 2000},
+			{name: 'Page E', uv: -2000, pv: 4800, amt: 2181},
+			{name: 'Page F', uv: -250, pv: 3800, amt: 2500},
+			{name: 'Page G', uv: 3490, pv: 4300, amt: 2100}
+		  ];
+
+		  foo(data);
+		  utest.Assert.pass();
+	}
+
+	static function foo<T:{uv:Int}>(data:Array<T>):Void {}
+}