Arquivos
hhvm/hphp/test/vm/inline_closure_gen.php
T
Jordan Delong 363d1bb20f Code move src/ -> hphp/
This change is mostly for FB internal organizational reasons.
Building is not effected beyond the fact that the target now
lands in hphp/hhvm/hhvm rather than src/hhvm/hhvm.
2013-02-11 02:10:41 -08:00

32 linhas
418 B
PHP

<?php
function using($cgen) {
foreach ($cgen() as $x) {
yield $x;
}
}
function broke() {
foreach (using(function() { yield 1; yield 2; yield 3; }) as $x) {
var_dump($x);
}
}
broke();
class c {
function genclo() {
return function() use($this) {
yield $this;
};
}
}
function main() {
$c = new c;
$f = $c->genclo();
foreach ($f() as $v) {
var_dump($v);
}
}
main();