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
Related
Category
stdlibProblem
Math builtins in
ext/standardcoerce enum case operands to backing scalars (or fail with non-Zend messages) instead of rejecting them withTypeErrorlike Zend (Z_PARAM_NUMBER/Z_PARAM_DOUBLE).Distinct from #5524 (string builtins) and #4163 (
number_format()only).php-src reference
ext/standard/math.c—ZEND_PARSE_PARAMETERStype checksZend/zend_enum.cRepro
test/repro-maintainer/parity_math_builtin_enum_type_error.php:absUnsupported type for abs(): 5(fatal)ceilok)floorroundsqrtScope (PHP-in-PHP)
ext/standard/abs.php,ceil.php,floor.php,round.php,sqrt.php, … — rejectVariable::TYPE_ENUM_CASEbefore numeric coercionlib/JIT/Builtin//ext/standard/Jit*.phptest/compliance/cases/stdlib/math_enum_case_type_error.phptDone when
TypeErrorwith Zend-aligned message./script/ci-fast.sh --filter math_enum_casegreenRelated
TypeErrornumber_format()enum operand