Skip to content

Stdlib: number_format() — enum case operand must TypeError not silent coerce (ext/standard/number_format.c, phase 2 of #4163) #5892

Description

@PurHur

Category

stdlib · php-src-strict

Problem

#4163 tracks number_format() rejecting array operands. Enum case operands are a separate gap: VM accepts backed enum cases (coercing or formatting via backing) while Zend throws TypeError because $num must be int|float, not an enum object.

php-src reference

PHP implementation target: ext/standard/number_format.php, ext/standard/JitNumberFormat.php — reject TYPE_ENUM_CASE before numeric coercion (same guard pattern as #5613 math batch).

Repro

test/repro-maintainer/parity_number_format_enum_operand.php:

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_number_format_enum_operand.php
php bin/vm.php test/repro-maintainer/parity_number_format_enum_operand.php'
Runtime Output
Zend PHP 8.2 TypeError: number_format(): Argument #1 ($num) must be of type float, E given
bin/vm.php number_format: NO_ERROR (silent wrong path)

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

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions