HaxeFoundation / HaxeFoundation/haxe

[java?] Int vs. Null<Int> overloads

Open
#9,237 3 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
feature-null-t feature-overload platform-jvm
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

This:

```haxe
class Main {
static function main() {
test(0);
}

@:overload
static function test(value:Int) {}

@:overload
static function test(value:Null) {}
}
```

currently fails with

```
source/Main.hx:7: characters 2-36 : Another overloaded field of same signature was already declared : test
source/Main.hx:10: characters 2-42 : The second field is declared here
```

I'm not sure but I think this might be a regression from when we changed `Null` to be an abstract. There's some code in `overloads.ml` which tries to dance around this situation and still checks for `TType`. The assumption was probably that the only `TType` that would still be there after a `follow_skip_null` would be the old Null-typedef.

@waneck Could you confirm that this kind of overloading was supposed to be allowed in your original implementation?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.