Skip to content

Language: typed static local variable — parse accepted on 8.2 profile (Zend/zend_compile.c) #16512

Description

@PurHur

Category

language · php-src-strict · profile gate

Problem

Typed static locals (static int $x = 0;) are a PHP 8.3+ feature. On the project's default 8.2 language profile, Zend rejects the syntax at parse time; this compiler accepts and executes the function body.

Repro Zend 8.2 VM (2026-07-05)
function f(){ static int $x=0; return ++$x; } f(); parse error 1

php-src reference

PHP implementation target

  • lib/Parser.php / compile path for static variables — reject typed static locals when PHP_COMPILER_LANGUAGE_PROFILE (or equivalent) is < 8.3
  • Future 8.3+ profile may enable; gate behind profile version, not unconditional acceptance

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php test/repro/maintainer_gap_typed_static_local_variable.php'
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_typed_static_local_variable.php'

Done when

  • 8.2 profile: parse/compile error matching Zend for typed static locals
  • 8.3+ profile (when enabled): typed static locals compile and run
  • Compliance .phpt guard 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 machineenhancementNew feature or requestimplementation-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