Browse Source

[typer] don't eagerly display in check_error

We might want to raise instead if we're in_call_args in order to support overload resolution.
closes #11274
Simon Krajewski 1 year ago
parent
commit
1e5b2a242a

+ 1 - 1
src/typing/operators.ml

@@ -13,7 +13,7 @@ let check_error ctx err = match err.err_message with
 	| Module_not_found ([],name) when Diagnostics.error_in_diagnostics_run ctx.com err.err_pos ->
 		DisplayToplevel.handle_unresolved_identifier ctx name err.err_pos true
 	| _ ->
-		Common.display_error_ext ctx.com err
+		raise_or_display_error ctx err
 
 module BinopResult = struct
 

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

@@ -1 +1,2 @@
-Main.hx:4: characters 13-17 : Cannot use null as ternary condition
+Main.hx:4: characters 13-17 : Cannot use null as ternary condition
+Main.hx:4: characters 13-17 : ... For function argument 'v'

+ 33 - 0
tests/unit/src/unit/issues/Issue11274.hx

@@ -0,0 +1,33 @@
+package unit.issues;
+
+using unit.issues.Issue11274.SpriteTools;
+
+private class Sprite {
+	public function new() {}
+}
+
+private class SpriteTools {
+	public static function setName(sprite:Sprite, name:String):Void {}
+}
+
+class Issue11274 extends unit.Test {
+	static var mark = false;
+
+	function test() {
+		sprite(foo -> {
+			foo.setName("foo");
+			add(foo); // err
+		});
+		t(mark);
+	}
+
+	extern inline overload static function sprite(callback:(sprite:Sprite) -> Void) {
+		callback(new Sprite());
+	}
+
+	extern inline overload static function sprite(name:String, callback:(sprite:Sprite) -> Void) {}
+
+	static function add(sprite:Sprite):Void {
+		mark = true;
+	}
+}