2
0
Эх сурвалжийг харах

[typeload] enable count check for type parameters again (closes #3710)

Simon Krajewski 10 жил өмнө
parent
commit
4fecde64f6

+ 7 - 0
tests/misc/projects/Issue3710/Main1.hx

@@ -0,0 +1,7 @@
+class Main1 {
+	static function main() {
+		var a:A<String, Int>;
+	}
+}
+
+class A<Rest:String> {}

+ 7 - 0
tests/misc/projects/Issue3710/Main2.hx

@@ -0,0 +1,7 @@
+class Main2 {
+	static function main() {
+		var a:A<String>;
+	}
+}
+
+class A<K:String,V> {}

+ 1 - 0
tests/misc/projects/Issue3710/compile-1-fail.hxml

@@ -0,0 +1 @@
+--run Main1

+ 1 - 0
tests/misc/projects/Issue3710/compile-1-fail.hxml.stderr

@@ -0,0 +1 @@
+Main1.hx:3: characters 2-23 : Invalid number of type parameters for A

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

@@ -0,0 +1 @@
+--run Main2

+ 1 - 0
tests/misc/projects/Issue3710/compile-2-fail.hxml.stderr

@@ -0,0 +1 @@
+Main2.hx:3: characters 2-18 : Invalid number of type parameters for A

+ 3 - 2
typeload.ml

@@ -354,7 +354,8 @@ let rec load_instance ctx t p allow_no_params =
 			| _ -> false,false
 		in
 		let types , path , f = ctx.g.do_build_instance ctx mt p in
-		if allow_no_params && t.tparams = [] && not (match types with ["Rest",_] -> true | _ -> false) then begin
+		let is_rest = is_generic_build && (match types with ["Rest",_] -> true | _ -> false) in
+		if allow_no_params && t.tparams = [] && not is_rest then begin
 			let pl = ref [] in
 			pl := List.map (fun (name,t) ->
 				match follow t with
@@ -371,7 +372,7 @@ let rec load_instance ctx t p allow_no_params =
 			| [TPType t] -> TDynamic (load_complex_type ctx p t)
 			| _ -> error "Too many parameters for Dynamic" p
 		else begin
-			(* if List.length types <> List.length t.tparams then error ("Invalid number of type parameters for " ^ s_type_path path) p; *)
+			if not is_rest && List.length types <> List.length t.tparams then error ("Invalid number of type parameters for " ^ s_type_path path) p;
 			let tparams = List.map (fun t ->
 				match t with
 				| TPExpr e ->