mirror of
https://github.com/php/php-src.git
synced 2025-08-20 01:14:28 +02:00

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.
24 lines
268 B
PHP
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)
|