facebook / facebook/hhvm

Iterator interface applied to generators has wrong type for current()

Open
#5,469 0 comments 0 reactions 0 assignees View on GitHub
hack
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

``` hack
function blarr(): Iterator {
yield break;
}

function main(): void {
$b = blarr();
$b->next();
$cur = $b->current();
// hh thinks $cur is int, but it's null
}
```

I'm not sure what the right solution is: making `Iterator::current()` return `?Tv` seems unfortunate when this isn't the case for most iterators.

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.