Skip to content

Language: encapsed Undefined variable Warning cites wrong line — Zend user site (Zend/zend_compile.c) #32034

Description

@PurHur

Category

Language · php-src-strict / encapsed-string diagnostics

Problem

Undefined-variable warnings raised while compiling encapsed string fetches (double-quoted, ${var}, heredoc) cite the opening statement line (often error_reporting(E_ALL) on line 2) instead of the expression site Zend reports.

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

Repro Zend 8.2.32 VM/JIT
echo "x=$missing\n" Warning on line 3 Warning on line 2
$s = "a$missing b" line 3 line 2
$s = "a{$missing} b" line 3 line 2
echo "${missing}\n" line 3 line 2
heredoc with $missing line 4 line 2
echo $missing (plain) line 3 line 3

Bare variable reads, assigns, and calls report the correct line; only encapsed fetch paths are off.

php-src reference

PHP implementation target

  • lib/Compiler.php — encapsed-string / rope lowering: propagate user start line for embedded variable fetches
  • lib/VM.php — if warnings are emitted from compile-time rope setup, move to runtime fetch with correct opline or fix line on the emitted warn opcode
  • No new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_undef_var_line.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_undef_var_encapsed_line.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_undef_var_heredoc_line.php'
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_undef_var_line.php'  # Zend baseline

Done when

  • VM/JIT: encapsed/heredoc $undefined warnings cite the same line as Zend for double-quoted, brace, ${}, and heredoc forms
  • Plain $undefined / undefined array-key echo 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