Browse Source

[error] fail early when encountering unknown identifier errors while checking overloads (closes #6765)

Dan Korostelev 7 years ago
parent
commit
a438571ccf

+ 11 - 1
src/typing/typer.ml

@@ -549,6 +549,15 @@ let unify_field_call ctx fa el args ret p inline =
 		| _ ->
 		| _ ->
 			assert false
 			assert false
 	in
 	in
+	let maybe_raise_unknown_ident cerr p =
+		let rec loop err =
+			match err with
+			| Unknown_ident _ -> error (error_msg err) p
+			| Stack (e1,e2) -> (loop e1; loop e2)
+			| _ -> ()
+		in
+		match cerr with Could_not_unify err -> loop err | _ -> ()
+	in
 	let rec loop candidates = match candidates with
 	let rec loop candidates = match candidates with
 		| [] -> [],[]
 		| [] -> [],[]
 		| (t,cf) :: candidates ->
 		| (t,cf) :: candidates ->
@@ -559,7 +568,8 @@ let unify_field_call ctx fa el args ret p inline =
 					candidate :: candidates,failures
 					candidate :: candidates,failures
 				end else
 				end else
 					[candidate],[]
 					[candidate],[]
-			with Error ((Call_error _ as err),p) ->
+			with Error ((Call_error cerr as err),p) ->
+				maybe_raise_unknown_ident cerr p;
 				let candidates,failures = loop candidates in
 				let candidates,failures = loop candidates in
 				candidates,(cf,err,p) :: failures
 				candidates,(cf,err,p) :: failures
 			end
 			end

+ 10 - 0
tests/misc/projects/Issue6765/Main.hx

@@ -0,0 +1,10 @@
+extern class J {
+	@:overload(function(s:String):Void {})
+	public function new():Void;
+}
+
+class Main {
+	static function main() {
+		new J(my_typo);
+	}
+}

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

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

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

@@ -0,0 +1 @@
+Main.hx:8: characters 9-16 : Unknown identifier : my_typo