haxe icon indicating copy to clipboard operation
haxe copied to clipboard

Ambiguous overload, candidates follow overload function

Open PXshadow opened this issue 5 months ago • 0 comments

function main() {
	f(10, 10);
	f("hi", "there");
}

overload extern inline function f(args:haxe.Rest<GoInt>) {}
overload extern inline function f(args:haxe.Rest<String>) {}
typedef GoInt = GoInt32;

abstract GoInt32(Int) from Int to Int {
	@:from
	static function fromString(x:String):GoInt32
		return Std.parseInt(x);
}
 3 |  f("hi", "there");
   |  ^^^^^^^^^^^^^^^^
   | Ambiguous overload, candidates follow

    6 | overload extern inline function f(args:haxe.Rest<GoInt>) {}
      |                                 ^
      | (args : haxe.Rest<GoInt>) -> Void

    7 | overload extern inline function f(args:haxe.Rest<String>) {}
      |                                 ^
      | (args : haxe.Rest<String>) -> Void

https://try.haxe.org/#5a5bab3A

I would prefer if the compiler didn't think this case was ambiguous, in other scenarios with an array it would be obvious what type it should be, for example:

  var x = ["hi", "there"];
  $type(x); // Array<String>

PXshadow avatar Jun 12 '25 17:06 PXshadow