Skip to content

Fix get_debug_type() on enum cases passed directly to calls (#4260) - #8664

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-get-debug-type-enum-4260
Jun 15, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-get-debug-type-enum-4260

Conversation

@PurHur

@PurHur PurHur commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix compiler lowering when php-cfg folds enum case ClassConstFetch operands but later calls lack a preceding fetch in CFG order (backed + unit enums in one script).
  • Emit runtime TYPE_CLASS_CONST_FETCH for enum case members instead of compile-time fold, and prefetch enum case call args via compileCallArgRuntimeEnumConstFetchOps + call ordinal mapping.
  • Extend operandsReferToSameVariable() to match via Block::cfgVarRoot() for php-cfg temporaries.

get_debug_type() implementation in ext/standard/get_debug_type.php already handles TYPE_ENUM_CASE; this is a compile-time dataflow fix.

php-src reference: ext/standard/type.cPHP_FUNCTION(get_debug_type)

Closes #4260

Test plan

php bin/vm.php test/repro-maintainer/get_debug_type_enum.php
# Color
# Size

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php vendor/bin/phpunit test/unit/GetDebugTypeBuiltinTest.php
php vendor/bin/phpunit test/compliance/JITTest.php --filter get_debug_type_enum
php vendor/bin/phpunit test/compliance/VMTest.php --filter get_debug_type_enum
'
# OK (3 + 1 + 3 tests)

AOT note: bin/compile.php still segfaults on get_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

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>
@PurHur
PurHur merged commit d17b5ae into master Jun 15, 2026
@PurHur
PurHur deleted the agent/stdlib-get-debug-type-enum-4260 branch June 15, 2026 10:18
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.

Stdlib: get_debug_type() — enum cases must return enum class name (ext/standard/type.c parity)

1 participant