Skip to content

Regression: enum relational operators — < and <=> order inverted vs Zend (re-#9016, zend_enum.c) #9288

Description

@PurHur

Category

language · php-src-strict · regression

Problem

Relational comparison between two cases of the same backed enum (<, <=>) must follow php-src declaration order. #9016 was closed 2026-06-16 but the repro still fails on VM (2026-06-17 audit): ordering is inverted for both int- and string-backed enums.

php-src reference

Repro

test/repro/issue_enum_relational_operators.php (in tree):

<?php
declare(strict_types=1);
enum E: int { case A = 1; case B = 2; }
enum S: string { case X = 'a'; case Y = 'b'; }
var_dump(E::A < E::B);
var_dump(E::A <=> E::B);
var_dump(S::X < S::Y);
var_dump(S::X <=> S::Y);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/issue_enum_relational_operators.php
php bin/vm.php test/repro/issue_enum_relational_operators.php
'
Expr Zend PHP 8.2 VM today
E::A < E::B bool(false) bool(true)
E::A <=> E::B int(1) int(-1)
S::X < S::Y bool(false) bool(true)
S::X <=> S::Y int(1) int(-1)

Scope (this repo)

Path Work
lib/VM/EnumCaseSupport.php compareSpaceship() / relational lowering must match Zend ordinal, not inverted backing compare
lib/VM/Variable.php enum case </> paths
lib/JIT/ JIT/AOT spaceship/relational ops must agree with VM
test/compliance/cases/language/enum_relational_operators.phpt guard repro

PHP-in-PHP — no new runtime/*.c logic.

Done when

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    IMPORTANTCritical patharea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions