File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Yield from non-iterable
3
+ --FILE--
4
+ <?php
5
+
6
+ function gen () {
7
+ yield from new stdClass ;
8
+ }
9
+
10
+ try {
11
+ gen ()->current ();
12
+ } catch (Error $ e ) {
13
+ echo $ e ->getMessage (), "\n" ;
14
+ }
15
+
16
+ ?>
17
+ --EXPECT--
18
+ Can use "yield from" only with arrays and Traversables
Original file line number Diff line number Diff line change @@ -8067,6 +8067,7 @@ ZEND_VM_C_LABEL(yield_from_try_again):
8067
8067
ZEND_VM_C_GOTO (yield_from_try_again );
8068
8068
} else {
8069
8069
zend_throw_error (NULL , "Can use \"yield from\" only with arrays and Traversables" );
8070
+ FREE_OP1 ();
8070
8071
UNDEF_RESULT ();
8071
8072
HANDLE_EXCEPTION ();
8072
8073
}
Original file line number Diff line number Diff line change @@ -4545,6 +4545,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CONST_HANDLER(
4545
4545
goto yield_from_try_again;
4546
4546
} else {
4547
4547
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
4548
+
4548
4549
UNDEF_RESULT();
4549
4550
HANDLE_EXCEPTION();
4550
4551
}
@@ -13707,6 +13708,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_TMPVAR_HANDLER
13707
13708
goto yield_from_try_again;
13708
13709
} else {
13709
13710
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
13711
+ zval_ptr_dtor_nogc(EX_VAR(opline->op1.var));
13710
13712
UNDEF_RESULT();
13711
13713
HANDLE_EXCEPTION();
13712
13714
}
@@ -37728,6 +37730,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_YIELD_FROM_SPEC_CV_HANDLER(ZEN
37728
37730
goto yield_from_try_again;
37729
37731
} else {
37730
37732
zend_throw_error(NULL, "Can use \"yield from\" only with arrays and Traversables");
37733
+
37731
37734
UNDEF_RESULT();
37732
37735
HANDLE_EXCEPTION();
37733
37736
}
You can’t perform that action at this time.
0 commit comments