The current yield from implementation doesn't support by-ref
yields. It's likely not worthwhile to actually implement this,
but we should at least keep the door open for the future by
issuing a compile error.
Refs bug #71252.
--- /dev/null
+--TEST--
+Yield from by reference is not supported
+--FILE--
+<?php
+
+function &gen() {
+ yield from [];
+}
+
+?>
+--EXPECTF--
+Fatal error: Cannot use "yield from" inside a by-reference generator in %s on line %d
zend_mark_function_as_generator();
+ if (CG(active_op_array)->fn_flags & ZEND_ACC_RETURN_REFERENCE) {
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Cannot use \"yield from\" inside a by-reference generator");
+ }
+
zend_compile_expr(&expr_node, expr_ast);
zend_emit_op_tmp(result, ZEND_YIELD_FROM, &expr_node, NULL);
}