Repository navigation
Language: typed class constants — array/string fold + type check (#3592) - #3600
Merged
Merged
Conversation
3 tasks
Materialize literal typed class constants at compile time (including array literals), validate declared types, and store values on VM defineClass. Adds php-cfg patch for declaredType on class const nodes and compliance tests for array dim-fetch and compile-time type mismatch. php-src: Zend/zend_compile.c (zend_compile_class_const), Zend/zend_constants.c, Zend/zend_type.c (zend_verify_const_type) Co-authored-by: Cursor <cursoragent@cursor.com>
PurHur
force-pushed
the
agent/issue-3592-typed-class-constants
branch
from
May 30, 2026 10:51
455f7c7 to
46480a5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
const array X = [1,2];,const string S = 'a';) now compile and run on the VM: literal arrays are folded at compile time, stored in the class constant table, and support dim-fetch (C::X[0]).TypeError(e.g.const string S = 1).declaredTypeon class const nodes; JIT lowering stores immutable array constants viaHashTableHelper::variableFromVmHashTable(LLVM class-const fetch remains fragile in harness — pre-existing JIT segfault on class const fetch).php-src reference
Zend/zend_compile.c—zend_compile_class_constZend/zend_constants.c— constant table + type infoZend/zend_type.c—zend_verify_const_typeTest plan
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "class C { public const array X = [1, 2]; } echo C::X[0];"'→1./vendor/bin/phpunit test/compliance/VMTest.php --filter typed_class_const./vendor/bin/phpunit test/compliance/JITTest.php --filter typed_class_const(segfault on class const fetch in current harness — same as existingclass_member_constJIT cases)Closes #3592
Made with Cursor