Skip to content

Language: @ inside closure skips error_get_last() — Zend records silenced Warning (zend_errors.c) #32041

Description

@PurHur

Category

Language · php-src-strict / @ silence + error_get_last

Problem

@$undef inside a compiled closure (or the same pattern in a user function) is silent on both Zend and VM (good), but Zend still records the warning in error_get_last() while VM/JIT leave error_get_last() null.

File-scope @$undef already updates error_get_last() (control). Builtin @preg_match('/(/', …) inside a closure already records the message (control; #13662). This is the language undefined-variable + ZEND_BEGIN_SILENCE path in a nested frame.

Probed 2026-08-18 @ 87cba84dc2 — Zend 8.2.32 vs php bin/vm.php / php bin/jit.php.

Repro Zend 8.2.32 VM/JIT
closure: error_clear_last(); @$undef; error_get_last() type=2 Undefined variable $undef type=none (null)
file-scope @$undef then error_get_last() type=2 same message type=2
closure: unsileced $undef then error_get_last() records; line = inner records; line = call site (see sibling nested-frame line issue)
closure: @preg_match('/(/','a') records preg Compilation failed records ✓

php-src reference

PHP implementation target

  • lib/VM.php — silenced undefined-variable in a callee frame must still snapshot into the error_get_last buffer (same as file-scope @)
  • lib/VM/ErrorReporter.php (or existing silence helpers) — @ suppresses display, not last-error storage
  • No new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_error_get_last_at_undef_closure.php'
./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_error_get_last_at_undef_closure.php'
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_error_get_last_at_undef_closure.php'  # Zend baseline
<?php
error_reporting(E_ALL);
error_clear_last();
$fn = function () {
    @ $undef;
    $e = error_get_last();
    echo 'type=', $e['type'] ?? 'none', "\n";
    echo 'msg=', $e['message'] ?? 'none', "\n";
};
$fn();

Done when

  • VM/JIT: @$undef inside a closure/function updates error_get_last() to E_WARNING Undefined variable $undef (Zend); no user-visible Warning
  • File-scope @$undef and @preg_match malformed inside a closure unchanged (already green)
  • Compliance .phpt under test/compliance/cases/language/
  • 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