Quellcode durchsuchen

[typer] remove special stack handling for TAnon vs. TAnon

closes #7227
Simon Krajewski vor 7 Jahren
Ursprung
Commit
ad401487aa

+ 1 - 4
src/core/type.ml

@@ -1857,10 +1857,7 @@ let rec type_eq param a b =
 					let f2 = PMap.find n a2.a_fields in
 					if f1.cf_kind <> f2.cf_kind && (param = EqStrict || param = EqCoreType || not (unify_kind f1.cf_kind f2.cf_kind)) then error [invalid_kind n f1.cf_kind f2.cf_kind];
 					let a = f1.cf_type and b = f2.cf_type in
-					rec_stack eq_stack (a,b)
-						(fun (a2,b2) -> fast_eq a a2 && fast_eq b b2)
-						(fun() -> type_eq param a b)
-						(fun l -> error (invalid_field n :: l))
+					(try type_eq param a b with Unify_error l -> error (invalid_field n :: l))
 				with
 					Not_found ->
 						if is_closed a2 then error [has_no_field b n];

+ 16 - 0
tests/misc/projects/Issue7227/Main.hx

@@ -0,0 +1,16 @@
+class Test {
+    static function main() {
+        var struct:Struct = {url: 'www.example.com', method: 'GET'};
+        var promise:Generic<Struct> = new Generic({url: struct, method: 'GET'});
+
+    }
+}
+
+class Generic<T> {
+  public function new(v:T) {}
+}
+
+typedef Struct = {
+    url:String,
+    method:String,
+}

+ 2 - 0
tests/misc/projects/Issue7227/compile-fail.hxml

@@ -0,0 +1,2 @@
+-main Main
+--interp

+ 6 - 0
tests/misc/projects/Issue7227/compile-fail.hxml.stderr

@@ -0,0 +1,6 @@
+Main.hx:4: characters 9-81 : Generic<{ url : Struct, method : String }> should be Generic<Struct>
+Main.hx:4: characters 9-81 : Type parameters are invariant
+Main.hx:4: characters 9-81 : { url : Struct, method : String } should be Struct
+Main.hx:4: characters 9-81 : { url : Struct, method : String } should be { url : String, method : String }
+Main.hx:4: characters 9-81 : Invalid type for field url :
+Main.hx:4: characters 9-81 : { url : String, method : String } should be String