Skip to content

Language: static property union types (string|int) — VM parity (#8726) - #8740

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-8726-static-property-union-type
Jun 15, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-8726-static-property-union-type

Conversation

@PurHur

@PurHur PurHur commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • VM already parsed public static string|int $p but JIT boxed (TYPE_VALUE) static slots with scalar defaults were never initialized, and DNF metadata was not wired for static property declare/fetch/assign.
  • Register static property DNF arms on JIT declare (including trait merge), enforce DNF writes on static assign, and count static DNF properties for the MCJIT try epilogue (scriptHasDnfTypedProperties).
  • Add compliance PHPT + issue repro; gate MCJIT execute for scalar union static props in JITTest (segfault on declare/fetch — same class of issue as #4908).

php-src reference

  • Zend/zend_compile.c — static property type compilation (PHP 8.4)
  • PHP implementation: lib/Compiler.php (compileTypeConstrainedVariable, TYPE_DECLARE_STATIC_PROPERTY), lib/VM.php (unionTypeConstraints on assign), lib/JIT/Builtin/Type/Object_.php

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/static_property_union_type.php'
x
42
ok
TypeError: Cannot assign array to property C::$p of type string|int
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter static_property_union_type'
OK (1 test, 1 assertion)

Closes #8726

Made with Cursor

…it (#8726)

Wire union/DNF metadata for static typed properties on VM and JIT declare
paths, fix boxed scalar default init for TYPE_VALUE static slots, and add
compliance coverage. MCJIT execute for scalar union static props remains
gated in JITTest until MCJIT static fetch is stable.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 889cd9d into master Jun 15, 2026
@PurHur
PurHur deleted the agent/issue-8726-static-property-union-type branch June 15, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Language: static property union type hints (T1|T2) — PHP 8.4 parse + runtime (zend_compile.c)

1 participant