Skip to content

Language: array offset on non-container types must emit E_WARNING (zend_execute.c) #4867

Description

@PurHur

Category

language · runtime

Problem

PHP 8+ warns when using [/] offset access on scalars that are not arrays/strings/ArrayAccess (Trying to access array offset on value of type bool). This compiler reads $x = true[0]; silently (no warning, $x null) and prints done.

Same class of bug as missing unary-+ warnings (#4723 / #4820) — invalid container access should warn under E_ALL, not fail silently.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_array_offset_bool.php; echo zend:$?
php bin/vm.php test/repro-maintainer/parity_array_offset_bool.php; echo vm:$?
'
Engine Output exit
Zend Warning: Trying to access array offset on value of type bool + done 0
VM done only 0

Repro script: test/repro-maintainer/parity_array_offset_bool.php

Scope (this repo)

Area Files
VM lib/VM.php — dim fetch on bool/int/float/null/resource
JIT/AOT mirror warning + null result after VM
Tests test/compliance/cases/language/array_offset_invalid_type.phpt (bool + int smoke)

Done when

  • Bool offset repro emits E_WARNING on VM under E_ALL
  • Result value remains null like Zend (no fatal)
  • ./script/ci-fast.sh --filter array_offset_invalid green

Links

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