Skip to content

Incorrect compile error for goto to label preceding try/finally block #22280

Closed

Description

@woodholly

Description

Affected: PHP 8.2
Not affected: PHP 8.4.21 (compiles and runs fine)

<?php
goto d;
try { } catch (\Throwable) { }
d: try { } finally { }

Resulted in this output:

PHP Fatal error:  jump out of a finally block is disallowed in /tmp/repro.php on line 2

But I expected this output instead:

PHP Version

php -v
PHP 8.2.31 (cli) (built: May  8 2026 07:20:38) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.31, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.31, Copyright (c), by Zend Technologies

Operating System

Debian 12

Activity

  1. LamentXU123 commented on Jun 11, 2026

    @LamentXU123
    Member

    Hi. PHP 8.2 is end-of-life now. If your bug doesn't affect PHP 8.4, 8.5 and 8.6 (master) we couldn't offer a fix on it

  2. self-assigned this
    on Jun 11, 2026
  3. woodholly commented on Jun 11, 2026

    @woodholly
    Author

    Good! But just wanted to document it and someone to verify it was actually fixed and not just randomly stopped reproducing.

  4. LamentXU123 commented on Jun 11, 2026

    @LamentXU123
    Member

    Hmm, Are you sure it doesn't afftect PHP 8.4.21? seems like it can be reproduced in 8.4: https://3v4l.org/4XSmh#v8.4.21

    Yeah this also affect master and 8.5. This is a valid bug.

  5. removed their assignment
    on Jun 11, 2026
  6. changed the title [-]False positive on goto+finally[/-] [+]Incorrect compile error for goto to label preceding try/finally block[/+] on Jun 11, 2026
  7. added 2 commits that reference this issue on Jun 14, 2026
    9e9b309
    2ec5f2d
  8. added a commit that references this issue on Jun 14, 2026
    10bdc08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions