Skip to content

Language: regression — backed enum === / == with backing scalar still true (#5798, PR #5802) #5832

Description

@PurHur

Category

language · php-src-strict · regression

Problem

#5798 was closed via PR #5802 (Variable::identicalTo / equals enum-vs-scalar guards), but the maintainer repro and compliance case enum_compare_backing_scalar.phpt still fail on VM (2026-06-04): E::A === 1, E::A == 1, and string-backed S::B === 'x' all return true.

Likely causes to investigate:

  1. E::A not materialized as TYPE_ENUM_CASE at runtime (php-cfg isEnumCase / script/apply-patches.sh — enum case parsed as plain const).
  2. Compare path bypasses Variable::identicalTo (constant-folded backing literal in compileClassConstFetch).

php-src reference

Repro

test/repro/maintainer_enum_compare_regression_5798.php (also test/compliance/cases/language/enum_compare_backing_scalar.phpt):

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_enum_compare_regression_5798.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_enum_compare_regression_5798.php'

Implementation (PHP-in-PHP)

  • Ensure enum case constants load as enum case objects (lib/Compiler.php compileTimeEnumCaseVar, lib/VM.php TYPE_DECLARE_CLASS_CONST, copyClassConstOrStaticPropertyByName).
  • Keep compare guards in lib/VM/Variable.php; add compliance green on VM before closing.
  • JIT/AOT: same semantics in lowered compares when required by compliance.

Verification

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_enum_compare_regression_5798.php'
./script/ci-local.sh --filter 'enum_compare_backing_scalar'

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

    area: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