Skip to content

Stdlib: pack()/unpack() enum operands — warn + backing scalar (#6213, #5713) - #7911

Merged
PurHur merged 1 commit into
masterfrom
agent/stdlib-pack-unpack-enum-6213
Jun 10, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/stdlib-pack-unpack-enum-6213

Conversation

@PurHur

@PurHur PurHur commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #6213
Related: #5713

php-src reference

  • ext/standard/pack.cphp_pack() argument coercion

PHP implementation

  • ext/standard/pack.php, ext/standard/PackEngine.php, ext/standard/VmPack.php
  • lib/VM/EnumCaseSupport.phppackCoerceToLong(), packCoerceToDouble(), packRejectStringOperand()

Verification

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/issue_6213_pack_unpack_enum.php
php bin/vm.php test/repro/issue_6213_pack_unpack_enum.php
vendor/bin/phpunit --filter "pack_backed_enum|pack_enum_string|unpack_enum"
php bin/compile.php -l test/repro/aot_pack_backed_enum.php
'

Output (2026-06-10):

PHP Warning:  Object of class E could not be converted to int
array(1) { [1]=> int(1) }
---VM---
PHP Warning:  Object of class E could not be converted to int
array(1) { [1]=> int(1) }
PHPUnit OK (6 tests)
bin/compile.php -l exit 0

Note: full AOT link for pack() remains blocked by pre-existing StringPackJit LLVM verify failures on master; -l lint passes for the enum repro.

Made with Cursor

Route pack() value operands through PackEngine Variable coercion instead of
VmJson::export so backed enum cases match Zend: E_WARNING plus backing int
round-trip, and string formats Error on enum objects.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit d9abb26 into master Jun 10, 2026
@PurHur
PurHur deleted the agent/stdlib-pack-unpack-enum-6213 branch June 10, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: unpack() — enum case operands must warn+pack backing int like Zend (ext/standard/pack.c, php-src-strict)

1 participant