Skip to content

A private property redeclared in a subclass is a separate slot; the two classes share one slot instead. #576

Closed

Description

@blacktrs

Summary

A private property redeclared in a subclass is a separate slot; the two classes share one slot instead.

Repro

<?php
class P { private array $r = []; private string $name = 'parent';
  public function add($x): void { $this->r[] = $x; }
  public function p(): string { return count($this->r) . ':' . $this->name; }
  public function reset(): void { $this->r = []; } }
class C extends P { private array $r = []; private string $name = 'child';
  public function add($x): void { $this->r[] = 'c' . $x; parent::add($x); }
  public function c(): string { return count($this->r) . ':' . $this->name; }
  public function resetChild(): void { $this->r = []; } }
$c = new C; $c->add(1); $c->add(2);
echo $c->c(), ' ', $c->p(), "\n";
$c->resetChild(); echo $c->c(), ' ', $c->p(), "\n";
$c->add(3); $c->reset(); echo $c->c(), ' ', $c->p(), "\n";

Expected (php)

2:child 2:parent
0:child 2:parent
1:child 0:parent

Actual (manticore f35c19e3, Darwin arm64)

4:child 4:child
0:child 0:child
0:child 0:child

Tracking

Known-bug repro: tests/aot/repro/wrong/private_property_shadowing.php — bash tests/aot/xfail.sh -k private_property_shadowing reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. added
    bug
    wrong-answer
    on Nov 6, 2026
  2. added a commit that references this issue on Nov 8, 2026
    77a2c5f
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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions