Skip to content

Regression: spaceship (<=>) on backed enum cases — VM still inverts Zend signs (re-#9796, Zend/zend_enum.c) #10203

Description

@PurHur

Category

language · php-src-strict

Problem

#9796 closed but VM still diverges from Zend on spaceship (<=>) for backed enum cases. Docker verification 2026-06-20:

Expression Zend PHP 8.2 php bin/vm.php
E::A <=> E::B (A=1, B=2) int(1) int(-1) ❌
E::A <=> 1 int(1) int(0) ❌
E::A <=> 'x' int(1) int(-1) ❌

Distinct from #9476 (LLVM migration): this is compare semantics in VM/JIT shared guards, not routing SpaceshipCompareJit to PHP.

php-src reference

Repro

test/repro/maintainer_spaceship_enum.php:

<?php
declare(strict_types=1);
enum E: int { case A = 1; case B = 2; }
var_dump(E::A <=> E::B);
var_dump(E::A <=> 1);
var_dump(E::A <=> 'x');
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_spaceship_enum.php
echo VM:
php bin/vm.php test/repro/maintainer_spaceship_enum.php
'

Scope

Area Files
VM lib/VM/CompareSupport.php or enum compare path
JIT shared compare guards — must agree with VM
Tests test/compliance/cases/language/enum_spaceship.phpt

Done when

  • All three var_dump lines match Zend output on VM
  • JIT agrees when in scope
  • ./script/ci-fast.sh --filter enum_spaceship green

Links

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 featuresstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions