--TEST-- Test interaction of Generator::getReturn() and finally --FILE-- getReturn()); function gen2() { try { return 42; } finally { throw new Exception("gen2() throw"); } yield; } $gen = gen2(); try { // This will throw an exception (from the finally) // during auto-priming, so fails var_dump($gen->getReturn()); } catch (Exception $e) { echo $e->getMessage(), "\n"; } try { // This fails, because the return value was discarded var_dump($gen->getReturn()); } catch (Exception $e) { echo $e->getMessage(), "\n"; } ?> --EXPECT-- int(42) gen2() throw Cannot get return value of a generator that hasn't returned