HaxeFoundation / HaxeFoundation/haxe
Dynamic is not bound for for loop variables
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
It seems that it's not a regression and it _might_ be intended, but it looks strange that the `Dynamic` type parameter of `Iterator` is not bound to the loop variable type when used in a `for` loop.
```haxe
abstract Vector(Array) {
public function new () {
this = [];
}
public function iterator():Iterator {
return this.iterator();
}
}
class Main {
static function main() {
var a = new Vector();
for (v in a) {
$type(v); // Unknown<0>
}
var a = new Array();
for (v in a) {
$type(v); // Dynamic (probably because array is iterated differently using length+arrayAccess)
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.