Skip to content

Stdlib: math builtins (ceil/round/floor/abs/…) must TypeError on enum case operands (ext/standard/math.c) #5613

Description

@PurHur

Category

stdlib

Problem

Math builtins in ext/standard coerce enum case operands to backing scalars (or fail with non-Zend messages) instead of rejecting them with TypeError like Zend (Z_PARAM_NUMBER / Z_PARAM_DOUBLE).

Distinct from #5524 (string builtins) and #4163 (number_format() only).

php-src reference

Repro

test/repro-maintainer/parity_math_builtin_enum_type_error.php:

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_math_builtin_enum_type_error.php
php bin/vm.php test/repro-maintainer/parity_math_builtin_enum_type_error.php'
Builtin Zend VM (today)
abs TypeError Unsupported type for abs(): 5 (fatal)
ceil TypeError succeeds (ok)
floor TypeError succeeds
round TypeError succeeds
sqrt TypeError succeeds

Scope (PHP-in-PHP)

Layer Files
VM ext/standard/abs.php, ceil.php, floor.php, round.php, sqrt.php, … — reject Variable::TYPE_ENUM_CASE before numeric coercion
JIT Matching lib/JIT/Builtin/ / ext/standard/Jit*.php
Tests test/compliance/cases/stdlib/math_enum_case_type_error.phpt

Done when

  • Each listed builtin throws catchable TypeError with Zend-aligned message
  • No backing-value coercion path for enum cases
  • ./script/ci-fast.sh --filter math_enum_case 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-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions