mirror of
https://github.com/php/php-src.git
synced 2026-04-26 17:38:14 +02:00
0fb640c717
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.
25 lines
268 B
PHP
25 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)
|