Skip to content

Fix keyed list destruct Undefined array key warning line (#31994) - #32024

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-31994-list-undef-key-line
Aug 18, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-31994-list-undef-key-line

Conversation

@PurHur

@PurHur PurHur commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Stamp TYPE_ARRAY_DIM_FETCH / TYPE_ARRAY_DIM_FETCH_WRITE opcodes with CFG sourceLocation via assignSourceMetadata() so Undefined array key warnings cite the list-destructure fetch site (Zend ZEND_FETCH_LIST_R opline), not a prior statement such as echo.
  • Root cause: without metadata, FatalSite::lineFromOpcodes() walked back to the preceding TYPE_ECHO for keyed destruct after an earlier echo; positional destruct accidentally worked because an intervening TYPE_ASSIGN on the same line was found first.
  • Add compliance .phpt + dedicated VM/JIT test classes (Language: keyed list destructure Undefined array key Warning cites previous line — Zend list site (zend_vm_def.h) #31994).

php-src reference

  • Zend/zend_vm_def.hZEND_FETCH_LIST_R
  • Zend/zend_execute.czend_undefined_index uses current opline

Verification

Issue repro (VM):

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_list_undef_key_line.php 2>&1'
PHP Warning:  Undefined array key 1 in .../maintainer_gap_list_undef_key_line.php on line 3
a=1
PHP Warning:  Undefined array key "x" in .../maintainer_gap_list_undef_key_line.php on line 5
c_done

Issue repro (JIT — falls back to VM interpreter when MCJIT verify fails on this script):

./script/docker-exec.sh -- bash -lc 'php bin/jit.php test/repro/maintainer_gap_list_undef_key_line.php 2>&1'

Same output (key "x" now line 5, was line 4).

Compliance:

./script/phpunit.sh test/compliance/ListDestructUndefKeyLine31994VMTest.php
./script/phpunit.sh test/compliance/ListDestructUndefKeyLine31994JITTest.php

Both OK (1/1).

Not covered

  • Full VMTest / JITTest suites
  • AOT path (list destruct dim fetch uses same compiler metadata; no separate AOT repro run)
  • Differential sweep (warning line only; no operand/lowering change)

Closes #31994

Made with Cursor

Stamp ArrayDimFetch opcodes with CFG source metadata so VM/JIT warnings cite the list destruct site instead of walking back to a prior ECHO opline.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 976b444 into master Aug 18, 2026
1 check failed
@PurHur
PurHur deleted the agent/issue-31994-list-undef-key-line branch August 18, 2026 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: keyed list destructure Undefined array key Warning cites previous line — Zend list site (zend_vm_def.h)

1 participant