HaxeFoundation / HaxeFoundation/haxe
Expected type is not propagated through branching
Open
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Could the following code be made working? It would be nice :)
```haxe
function get() {
return new Map();
}
function getE() {
return E.A;
}
enum E { A; B; }
enum E2 { A; B; }
function main() {
// doesn't compile
trace(try get() catch (e) []); // haxe.ds.Map should be Array>
trace(if (Math.random() > 0.5) get() else []); // Array> should be haxe.ds.Map
trace(if (Math.random() > 0.5) getE() else A); // E2 should be E
}
```
Also, in the `try` example it complains about `get()` rather than `[]`, which is confusing because it doesn't follow syntatical order.
Contributor guide
Assessment
This issue has not been assessed yet.