Skip to content

Stdlib: chr() on enum case — VM fatal TYPE_RESOURCE, must TypeError (ext/standard/string.c) #5673

Description

@PurHur

Summary

Passing a backed enum case to chr() must throw TypeError (Zend 8.2). VM currently hits Undefined constant PHPCompiler\VM\Variable::TYPE_RESOURCE in VmMath::vmTypeName() because TYPE_ENUM_CASE is not handled in parseChrCodepoint() / parseLongBuiltinArgCore().

Umbrella #5524 tracks string builtins generally; this is a hard VM fatal on a common path and should be fixed in VmMath + chr/ord callers.

php-src reference

  • ext/standard/string.cPHP_FUNCTION(chr)

PHP implementation

  • ext/standard/VmMath.phpvmTypeName() + early TYPE_ENUM_CASE → TypeError in parseChrCodepoint()
  • ext/standard/chr.php (VM + JIT via JitChr)

Repro

php test/repro-maintainer/parity_chr_enum_operand.php
php bin/vm.php test/repro-maintainer/parity_chr_enum_operand.php

Acceptance

  • VM emits Zend-parity TypeError: chr(): Argument #1 ($codepoint) must be of type int, E given (enum class name in message).
  • Compliance or unit test under test/compliance/cases/stdlib/.

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