Skip to content

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

@woodholly

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions