Add support for yielding from a generator in PrintNode

This commit is contained in:
Fabien Potencier
2024-07-22 13:46:32 +02:00
parent 3c52cd9814
commit 27f6171f2f
6 changed files with 57 additions and 4 deletions
+2 -3
View File
@@ -31,10 +31,9 @@ class PrintNode extends Node implements NodeOutputInterface
public function compile(Compiler $compiler): void
{
$compiler->addDebugInfo($this);
$compiler
->write('yield ')
->addDebugInfo($this)
->write($this->getNode('expr')->isGenerator() ? 'yield from ' : 'yield ')
->subcompile($this->getNode('expr'))
->raw(";\n")
;