mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Merge branch 'PHP-7.0'
This commit is contained in:
12
Zend/tests/generators/yield_from_by_reference.phpt
Normal file
12
Zend/tests/generators/yield_from_by_reference.phpt
Normal file
@@ -0,0 +1,12 @@
|
||||
--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
|
||||
@@ -6616,6 +6616,11 @@ void zend_compile_yield_from(znode *result, zend_ast *ast) /* {{{ */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user