Fix get_debug_type() on enum cases passed directly to calls (#4260) - #8664
Merged
Merged
Conversation
php-cfg can fold enum case ClassConstFetch operands before DECLARE_CLASS_CONST runs, leaving later call args without runtime CLASS_CONST_FETCH. Emit runtime fetches for enum case members and wire call-arg prefetch by CFG ordinal so backed + unit enums in one script return enum class names on VM and JIT. Reference: php-src ext/standard/type.c (PHP_FUNCTION(get_debug_type)). Co-authored-by: Cursor <cursoragent@cursor.com>
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
ClassConstFetchoperands but later calls lack a preceding fetch in CFG order (backed + unit enums in one script).TYPE_CLASS_CONST_FETCHfor enum case members instead of compile-time fold, and prefetch enum case call args viacompileCallArgRuntimeEnumConstFetchOps+ call ordinal mapping.operandsReferToSameVariable()to match viaBlock::cfgVarRoot()for php-cfg temporaries.get_debug_type()implementation inext/standard/get_debug_type.phpalready handlesTYPE_ENUM_CASE; this is a compile-time dataflow fix.php-src reference:
ext/standard/type.c—PHP_FUNCTION(get_debug_type)Closes #4260
Test plan
AOT note:
bin/compile.phpstill segfaults onget_debug_type()with enum operands (pre-existing on master;get_class()enum AOT works). No new AOT fixture added — tracked separately from this compiler lowering fix.Made with Cursor