php-src/Zend/tests/generators/yield_from_greedy_parse.phpt
Sara Golemon 0fb640c717 Fix bug where yield from is captured too greedily
In the following piece of code:

```php
function from1234($x) {
  return $x;
}
function foo($x) {
  yield from1234($x);
}
```

The statement inside foo is taken as `yield from` `1234($x)`
which is neither the intent, nor even legal syntax for an fcall.

Do a lookahead for breaking non-label characters after the
`yield from` and only accept it if they occur.
2017-03-23 13:31:06 -07:00

24 lines
268 B
PHP

--TEST--
yield from parses too greedily
--FILE--
<?php
function from1234($x) {
return $x;
}
function bar() {
yield 24;
}
function foo() {
yield from1234(42);
yield from(bar());
}
foreach (foo() as $value) {
var_dump($value);
}
--EXPECT--
int(42)
int(24)