Skip to content

Commit 2ffffc5

Browse files
committed
Yield without a value should throw notice when generator references function
1 parent 6364c22 commit 2ffffc5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Zend/zend_vm_def.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7620,7 +7620,7 @@ ZEND_VM_HOT_NOCONST_HANDLER(198, ZEND_JMP_NULL, CONST|TMP|VAR|CV, JMP_ADDR)
76207620
uint32_t short_circuiting_type = opline->extended_value & ZEND_SHORT_CIRCUITING_CHAIN_MASK;
76217621
if (EXPECTED(short_circuiting_type == ZEND_SHORT_CIRCUITING_CHAIN_EXPR)) {
76227622
ZVAL_NULL(result);
7623-
if (OP1_TYPE == IS_CV
7623+
if (OP1_TYPE == IS_CV
76247624
&& UNEXPECTED(Z_TYPE_P(val) == IS_UNDEF)
76257625
&& (opline->extended_value & ZEND_JMP_NULL_BP_VAR_IS) == 0
76267626
) {
@@ -8196,6 +8196,10 @@ ZEND_VM_HANDLER(160, ZEND_YIELD, CONST|TMP|VAR|CV|UNUSED, CONST|TMPVAR|CV|UNUSED
81968196
}
81978197
}
81988198
} else {
8199+
if (UNEXPECTED(EX(func)->op_array.fn_flags & ZEND_ACC_RETURN_REFERENCE)) {
8200+
zend_error(E_NOTICE, "Only variable references should be yielded by reference");
8201+
}
8202+
81998203
/* If no value was specified yield null */
82008204
ZVAL_NULL(&generator->value);
82018205
}

0 commit comments

Comments
 (0)