HaxeFoundation / HaxeFoundation/haxe
Infer optional fields on open structures when accessed with null coalescing operator.
Open
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Example:
```haxe
import sys.net.*;
function connect(options) {
var ret = new Socket();
ret.connect(options.host ?? Host.localhost(), options.port);
return ret;
}
```
In this case I would like `options` to be inferred to `{ ?host:sys.net.Host, port:Int }`, unless there are reasons not to.
It's perhaps worth mentioning that there's a bit of a special case in combination with safe navigation:
```haxe
import sys.net.*;
function connect(?options) {
var ret = new Socket();
ret.connect(options?.host ?? Host.localhost(), options?.port ?? 3306);
return ret;
}
```
Contributor guide
Assessment
This issue has not been assessed yet.