Skip to content

JIT: Fix JIT ASSIGN_DIM undefined OP_DATA and dim reporting on non-array containers - #24665

Open
jorgsowa wants to merge 1 commit into
php:PHP-8.4from
jorgsowa:fix-jit-assign-dim-undef-op-data
Open

jorgsowa wants to merge 1 commit into
php:PHP-8.4from
jorgsowa:fix-jit-assign-dim-undef-op-data

Conversation

@jorgsowa

Copy link
Copy Markdown
Contributor

In function JIT, zend_jit_assign_dim_helper() read an undefined OP_DATA before checking the container type. The VM reads it only when it actually assigns, so the JIT reported warnings in a different order, or where the VM reports none:

Code VM Function JIT
$x = 1.5; $x[0] = $undef; Error: Cannot use a scalar value as an array extra Undefined variable warning before the Error
$x = 'ab'; $x[] = $undef; Error: [] operator not supported for strings extra Undefined variable warning before the Error
$x = false; $x[0] = $undef; Deprecated (false to array), then Undefined variable Undefined variable, then Deprecated
$x = 1.5; $x[$undef] = 1; Error: Cannot use a scalar value as an array extra Undefined variable warning before the Error

The helper now checks for an undefined value only on the false path, after the deprecation, and no longer reports an undefined key on the scalar path. The generated JIT code is unchanged, and the helper is slightly smaller at -O2 (183 instructions instead of 207 on arm64).

…ontainers

Report an undefined OP_DATA only when the value is assigned, after the
false to array deprecation, and never report an undefined dim before
"Cannot use a scalar value as an array", matching the VM.
@jorgsowa jorgsowa self-assigned this Oct 24, 2026
@jorgsowa
jorgsowa requested a review from dstogov as a code owner October 24, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant