HaxeFoundation / HaxeFoundation/haxe

Dynamic is not bound for for loop variables

Open
#8,287 2 comments 0 reactions 2 assignees Claimed by @ncannasse View on GitHub
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

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.