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

remove duplicate errors when overload resolution fails (closes #4803)

Simon Krajewski 9 жил өмнө
parent
commit
234f4b1f2e

+ 2 - 1
src/typing/typer.ml

@@ -817,8 +817,9 @@ let unify_field_call ctx fa el args ret p inline =
 		let candidates,failures = loop candidates in
 		let fail () =
 			let failures = List.map (fun (cf,err,p) -> cf,error_msg err,p) failures in
+			let failures = remove_duplicates (fun (_,msg1,_) (_,msg2,_) -> msg1 <> msg2) failures in
 			begin match failures with
-			| (_,msg,p) :: failures when List.for_all (fun (_,msg2,_) -> msg = msg2) failures ->
+			| [_,msg,p] ->
 				error msg p
 			| _ ->
 				display_error ctx "Could not find a suitable overload, reasons follow" p;

+ 9 - 0
tests/misc/projects/Issue4803/Main.hx

@@ -0,0 +1,9 @@
+class Main  {
+	static function main() {
+		var j = new js.jquery.JQuery();
+		j.click(function(e) {
+			var p = { y : 3 };
+			p = { x : 5 };
+		});
+	}
+}

+ 3 - 0
tests/misc/projects/Issue4803/compile-fail.hxml

@@ -0,0 +1,3 @@
+-main Main
+-js js.js
+--no-output

+ 7 - 0
tests/misc/projects/Issue4803/compile-fail.hxml.stderr

@@ -0,0 +1,7 @@
+Main.hx:4: lines 4-7 : Could not find a suitable overload, reasons follow
+Main.hx:4: lines 4-7 : Overload resolution failed for Void -> js.jquery.JQuery
+Main.hx:4: lines 4-7 : Too many arguments
+Main.hx:4: lines 4-7 : Overload resolution failed for handler : (js.jquery.Event -> Void) -> js.jquery.JQuery
+Main.hx:6: characters 7-16 : Object requires field y
+Main.hx:6: characters 7-16 : For function argument 'handler'
+Main.hx:4: lines 4-7 : End of overload failure reasons