Skip to content

A generator finished by an uncaught exception is not marked finished #43

Closed

Description

@blacktrs

Summary

A generator finished by an uncaught exception is not marked finished.

Fix planned in the ownership redesign epic (PR #15, task 10: generator frames). Tracking only.

Repro

<?php
function g(): \Generator { yield 1; throw new Exception('x'); }
$g = g();
try { foreach ($g as $v) {} } catch (Exception $e) { echo "caught\n"; }
var_dump($g->valid());
$g->next();
echo "ok\n";

Expected (php 8.5)

caught
bool(false)
ok

Actual (manticore 10affa68, macOS arm64)

caught
bool(true)
[exit code 255]
PHP Fatal error:  Uncaught Exception: x

Tracking

Known-bug repro: tests/aot/repro/wrong/generator_finished_by_exception.php — bash tests/aot/xfail.sh -k generator_finished_by_exception reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions