Skip to content

Fix BackedEnum from()/spaceship var_dump dead call-arg slot (#9575) - #9598

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-9575-backed-enum-from
Jun 18, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-9575-backed-enum-from

Conversation

@PurHur

@PurHur PurHur commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

Root cause: BackedEnum::from() / tryFrom() lookup was already correct on VM/JIT; the reported regression surfaced via enum_from_spaceship.phpt where php-cfg emits a dead arg temp for var_dump() and the compiler only rewired boolean producers (#9030), not int-producing spaceship ops nested with E::from().

php-src reference: Zend/zend_enum.c — zend_enum_from_case(); compile-time call-arg lowering mirrors zend_compile.c dead-temp behavior (#9030).

Test plan

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_enum_from_regression.php
php bin/vm.php test/repro/maintainer_enum_from_regression.php
php bin/jit.php test/repro/maintainer_enum_from_regression.php
vendor/bin/phpunit --filter enum_from
vendor/bin/phpunit test/unit/InlineCallArgProducerSlotTest.php --filter testVarDumpSpaceshipFromSendsSpaceshipResultSlot'

Verified output (2026-06-18)

# maintainer repro (VM)
enum(Color::Red)
enum(Color::Red)
enum(Count::One)
enum(Count::One)
from_invalid: "nope" is not a valid backing value for enum Color
NULL

# enum_from_spaceship.phpt (VM)
int(0)
int(0)
int(0)

# enum_from filter: 11/12 pass (VM + JIT spaceship green); pre-existing AOT try/catch ValueError gap on fixtures/aot/cases/enum_from.phpt unchanged

Closes #9575

Made with Cursor

Extend the #9030 inline producer wiring to TYPE_LONG so var_dump(E::A <=> E::from(1)) sends the spaceship int result instead of a stale enum-case temp, restoring enum_from compliance and maintainer repro parity.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Regression: BackedEnum::from()/tryFrom() always ValueError — valid backing scalars never match (re-#3114, Zend/zend_enum.c)

1 participant