HaxeFoundation / HaxeFoundation/haxe
Ambiguous overload, candidates follow overload function
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
function main() {
f(10, 10);
f("hi", "there");
}
overload extern inline function f(args:haxe.Rest) {}
overload extern inline function f(args:haxe.Rest) {}
typedef GoInt = GoInt32;
abstract GoInt32(Int) from Int to Int {
@:from
static function fromString(x:String):GoInt32
return Std.parseInt(x);
}
```
```sh
3 | f("hi", "there");
| ^^^^^^^^^^^^^^^^
| Ambiguous overload, candidates follow
6 | overload extern inline function f(args:haxe.Rest) {}
| ^
| (args : haxe.Rest) -> Void
7 | overload extern inline function f(args:haxe.Rest) {}
| ^
| (args : haxe.Rest) -> 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:
```haxe
var x = ["hi", "there"];
$type(x); // Array
```
Contributor guide
Research direction
Reproduce the overload-resolution example at the linked try.haxe.org URL, starting with the calls using haxe.Rest and haxe.Rest. Investigate how the compiler handles the String-to-GoInt conversion when selecting overloads. Done means the string call selects the String overload without ambiguity while the numeric call remains valid.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100