Skip to content

Language: backed enum case === / == with backing scalar must be false (zend_operators.c) #5798

Description

@PurHur

Category

language

Problem

Identity and equality between a enum case object and its backing scalar must be false in PHP 8.1+:

  • E::A === 1false
  • E::A == 1false

This compiler returns true for both (backing coercion in compare).

php-src reference

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_enum_strict_identity.php
php bin/vm.php test/repro-maintainer/parity_enum_strict_identity.php'
Engine === ==
Zend false false
VM true true

Scope

  • lib/VM/Variable.php (or compare helpers) — do not equate TYPE_ENUM_CASE to backing int
  • JIT/AOT compare lowering (phase 2)

Done when

  • VM returns false for === and == in repro
  • PHPT test/compliance/cases/language/enum_compare_backing_scalar.phpt green

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

    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