Skip to content

Stdlib: math builtins (abs/ceil/floor/round/sqrt) — enum case TypeError regression (#5613, php-src-strict) #8728

Description

@PurHur

Category

stdlib · php-src-strict · regression

Problem

Closed #5613 added TypeError for enum case operands to core math builtins. VM regressed: abs/ceil/floor/round/sqrt silently coerce backed enum cases to scalars instead of raising TypeError like Zend (Z_PARAM_NUMBER / Z_PARAM_DOUBLE in php-src).

Verified 2026-06-15 on master.

php-src reference

Repro

Existing maintainer script:

./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'
Engine Expected per function
Zend PHP 8.3+ TypeError: {fn}(): Argument #1 ($num) must be of type int|float, Ei given
This compiler VM (today) prints {fn} uncaught (coercion, no TypeError)

Minimal inline:

<?php
enum Ei: int { case N = 5; }
try { round(Ei::N); echo "uncaught\n"; } catch (TypeError $e) { echo $e->getMessage(), "\n"; }

Scope (this repo)

Layer Path
VM ext/standard/VmMath.php — reject enum cases before numeric coercion
JIT/AOT lib/JIT/Builtin/*Math* / JitStringBuiltinArg guards mirroring VM
Tests test/compliance/cases/stdlib/math_enum_type_error.phpt (restore from #5613)

Done when

  • Repro prints Zend-matching TypeError for all five functions on VM
  • JIT/AOT compliance for the same repro when issue requires MCJIT path
  • ./script/ci-fast.sh --filter math_enum_type_error green
  • No new C runtime logic — PHP guards only

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