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
Category
language| regression (re-#8949)Problem
Zend accepts enum case objects as
WeakMapkeys (enum cases are objects). This compiler VM throwsTypeError: WeakMap key must be an objectwhen 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
Zend/zend_weakrefs.c—zend_weakmap_offset_set, object key validation (IS_OBJECT, enum cases allowed)Zend/zend_enum.c— enum case object kindRepro
test/repro/maintainer_gap_weakmap_enum_key.php:set ok value=42/isset trueTypeError: WeakMap key must be an objecton line 7Scope
lib/VM.php— WeakMap offset set / isset / unset key validationlib/JIT/Builtin/Type/WeakMap_.php(if JIT path exists) — same php-src-strict rulesruntime/*.cweakref tablesDone when
php bin/vm.php(set/get/isset/unset with enum case keys)test/compliance/cases/language/weakmap_enum_case_key.phpt