Skip to content

Language: user methods must reject $this reassignment (zend_compile.c) #4865

Description

@PurHur

Category

language · compile-time

Problem

Assigning to $this inside a user method is a compile-time fatal in Zend (Cannot re-assign $this). This compiler accepts $this = new C(); and continues execution.

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_reassign_this.php; echo zend:$?
php bin/vm.php test/repro-maintainer/parity_reassign_this.php; echo vm:$?
'
Engine Output exit
Zend Fatal error: Cannot re-assign $this 255
VM prints reassigned 0

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

Scope (this repo)

Area Files
Compiler lib/Compiler.php / CFG builder — reject $this as assignment target in user functions
VM belt-and-suspenders runtime guard if compile path missed
Tests test/compliance/cases/language/reassign_this.phpt

Done when

  • Repro fails at compile time with Zend message (VM + JIT + AOT)
  • Legitimate $this reads/writes to properties still work
  • ./script/ci-fast.sh --filter reassign_this 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