Description
When the result of yield from is assigned to a local variable and then used, elephc compiles the program but the generated binary produces no output.
In PHP, yield from evaluates to the delegated generator's return value. That return value should be assigned to the local and remain usable after the delegation completes.
Reproduction
<?php
function inner() {
yield 1;
return 42;
}
function outer() {
$ret = yield from inner();
yield $ret;
}
foreach (outer() as $v) {
echo $v;
echo "\n";
}
PHP output
elephc behavior
- The file compiles successfully.
- The generated binary runs but prints nothing.
Expected behavior
The generated binary should print:
matching PHP.
Actual behavior
The delegated generator appears to run incorrectly once its return value is captured via yield from, and the outer generator produces no visible output.
Environment
- elephc 0.21.14
- PHP 8.4.20
- macOS ARM64
Notes
This looks separate from type inference issues around yield / send(). The failure here is runtime behavior after successful compilation.
Likely areas:
- generator lowering / resume-state handling for
yield from
- propagation of the delegated generator's terminal return value into the outer generator frame
- codegen/runtime interaction for delegation completion
Description
When the result of
yield fromis assigned to a local variable and then used, elephc compiles the program but the generated binary produces no output.In PHP,
yield fromevaluates to the delegated generator's return value. That return value should be assigned to the local and remain usable after the delegation completes.Reproduction
PHP output
elephc behavior
Expected behavior
The generated binary should print:
matching PHP.
Actual behavior
The delegated generator appears to run incorrectly once its return value is captured via
yield from, and the outer generator produces no visible output.Environment
Notes
This looks separate from type inference issues around
yield/send(). The failure here is runtime behavior after successful compilation.Likely areas:
yield from