HaxeFoundation / HaxeFoundation/haxe
function binding and native optional arguments
Open
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
class Main {
public static function main() {
var foo: (?a: Int, ?b: Int) -> Void = null;
foo(null, null); // throws on static targets
var bar = foo.bind(_, 0); // (?a: Null) -> Void
bar(null); // passes
}
}
```
I think in this case `bar` type should become `(a: Int) -> Void` instead as a default value for the native optional argument is lost.
To compensate stricter rules, maybe some construction can be used to specify default values in a binding:
```haxe
var bar = foo.bind(_ = 0, 0); // (?a: Null) -> Void
```
This might be handy not only to this specific issue, but in general too.
Contributor guide
Assessment
This issue has not been assessed yet.