Skip to content

Regression: WeakMap enum case object keys — TypeError not Zend object key (re-#8949, Zend/zend_weakrefs.c) #8993

Description

@PurHur

Category

language | regression (re-#8949)

Problem

Zend accepts enum case objects as WeakMap keys (enum cases are objects). This compiler VM throws TypeError: WeakMap key must be an object when the key is a backed enum case — treating the enum as non-object or failing before weakref attach.

Issue #8949 was closed; repro still fails on VM (verified 2026-06-16).

php-src reference

Repro

test/repro/maintainer_gap_weakmap_enum_key.php:

<?php
enum E: int { case A = 1; }

$map = new WeakMap();
$map[E::A] = 42;
echo 'set ok value=' . $map[E::A] . "\n";
echo isset($map[E::A]) ? "isset true\n" : "isset false\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_weakmap_enum_key.php
php bin/vm.php test/repro/maintainer_gap_weakmap_enum_key.php
'
Engine Result
Zend PHP 8.x set ok value=42 / isset true
VM (2026-06-16) TypeError: WeakMap key must be an object on line 7

Scope

  • lib/VM.php — WeakMap offset set / isset / unset key validation
  • lib/JIT/Builtin/Type/WeakMap_.php (if JIT path exists) — same php-src-strict rules
  • PHP-in-PHP: no new runtime/*.c weakref tables

Done when

  • Repro passes on php bin/vm.php (set/get/isset/unset with enum case keys)
  • Compliance PHPT: test/compliance/cases/language/weakmap_enum_case_key.phpt
  • JIT/AOT agree when both in scope (or matrix notes VM-only)

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: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