Skip to content

AOT: asymmetric private(set) property reads garbage and write guard never fires (#3165 regression) #16354

Description

@PurHur

Summary

On current master (4c4c300), AOT binaries mis-compile classes using PHP 8.4 asymmetric property visibility. A public private(set) int property read returns garbage (uninitialized slot) and the set-visibility guard never raises, so program output diverges from VM/JIT. script/capability-syntax.php regeneration in the pinned container now honestly flips the row to AOT=no (synced in the capability doc-sync PR).

Repro

<?php
class C { public private(set) int $x = 1; public function bump(): void { $this->x++; } }
$c = new C(); $c->bump(); echo $c->x, "\n";
try { $c->x = 5; } catch (Error $e) { echo "caught: ", $e->getMessage(), "\n"; }
Driver Output rc
bin/vm.php 2 + caught: Cannot modify public private(set) property C::$x from global scope 0
./phpc build + run (AOT) 446409552 (garbage int, no caught line) 0

Environment: php-compiler:22.04-dev (PHP 8.2.31, LLVM 9), PHP_COMPILER_LLVM_PATH=/opt/llvm9.

php-src reference

Zend/zend_compile.c ZEND_ACC_*_SET + zend_object_handlers.c write guard — Zend raises Error: Cannot modify ... and the read path is unaffected.

Notes

Done when

  • AOT output matches VM for the repro (value 2, guard Error caught)
  • php script/capability-syntax.php --check green with the row back at AOT=yes
  • Compliance phpt covering private(set) read+guard under AOT

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITbugSomething isn't workingphase-3:aotPhase 3 – AOT deployment

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions