Skip to content

Language: (int)/(float) cast on backed enum regression vs closed #5714 (zend_operators.c) #5791

Description

@PurHur

Category

language

Problem

Zend emits E_WARNING and yields 1 (legacy object-to-int) when casting a backed enum case with (int) / (float)not the backing value. #5714 was closed, but VM still prints 42 for (int) E::A with case A = 42.

php-src reference

Repro

test/repro/parity_enum_int_cast.php:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php8.2 test/repro/parity_enum_int_cast.php 2>&1 | tail -2
php bin/vm.php test/repro/parity_enum_int_cast.php 2>&1 | tail -2'
Runtime stdout (after warning)
Zend 1
VM 42

Scope

Done when

  • VM: warning + 1 for (int) E::A (not backing 42)
  • (float) same legacy 1.0 behavior
  • ./script/ci-fast.sh --filter int_cast_backed_enum 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