Skip to content

Regression: UnhandledMatchError message always NULL for variable subjects — Zend formats value (re-#23664, Zend/zend_exceptions.c) #24329

Description

@PurHur

Category

bug · php-src-strict · language match

Problem

#23664 / #23678 fixed UnhandledMatchError formatting, but variable subjects now always print NULL instead of the Zend form. Literal false still formats; a false in a variable does not.

Verified 2026-07-28 (host Zend 8.2.32 vs bin/vm.php):

Repro subject Zend 8.2 VM
match ($v) with $v = 3 Unhandled match case 3 Unhandled match case NULL
$v = 'secret-value' Unhandled match case '...' Unhandled match case NULL
$v = null Unhandled match case NULL Unhandled match case NULL (OK)
$v = true Unhandled match case true Unhandled match case NULL
$v = false Unhandled match case false Unhandled match case NULL
$v = [1] Unhandled match case of type array Unhandled match case NULL
literal match(false) Unhandled match case false Unhandled match case false (OK)

php-src reference

PHP implementation target

  • lib/VM/MatchUnhandledSupport.php + ext/standard/phpc_match_unhandled_*.php / match lowering in lib/Compiler.php — pass the live subject into the message helper (variable path currently loses the value); JIT/AOT agree when in scope; no new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_unhandled_match_message_null.php'
# compare: php test/repro/maintainer_gap_unhandled_match_message_null.php

Inline:

<?php
foreach (['int' => 3, 'str' => 'secret-value', 'null' => null, 'true' => true, 'false' => false, 'arr' => [1]] as $label => $v) {
    try { match ($v) { 0 => 0, 'nope' => 1 }; echo "$label:no\n"; }
    catch (UnhandledMatchError $e) { echo $label, ':', $e->getMessage(), "\n"; }
}

Done when

  • All six variable rows match Zend on VM (and JIT/AOT when match is lowered there)
  • Literal match(false) remains correct
  • Compliance .phpt guard under test/compliance/cases/
  • php-src-strict; no php-compiler-strict shortcut

Activity

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

    area:compilerCompiler / CFG / JITarea:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions