Skip to content

Stdlib: mb_strlen() — enum case operand TypeError (#5873) - #7593

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-5873-mb-strlen-enum-typeerror
Jun 8, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-5873-mb-strlen-enum-typeerror

Conversation

@PurHur

@PurHur PurHur commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • mb_strlen() VM path now uses VmString::coerceStringBuiltinArg() (php-src Z_PARAM_STR / ext/mbstring/mbstring.c) instead of throwing LogicException on enum case operands.
  • JIT/AOT lowering uses JitStringBuiltinArg::lower() via refactored JitMbStrlen::utf8LengthFromPtr().
  • Adds VM/JIT compliance PHPTs, AOT fixture, and wires MbStrlenVMTest / MbStrlenJITTest (existing mb_strlen*.phpt were previously unwired).

Closes #5873

php-src reference

  • ext/mbstring/mbstring.cPHP_FUNCTION(mb_strlen) / Z_PARAM_STR
  • PHP implementation: ext/mbstring/mb_strlen.php, ext/mbstring/JitMbStrlen.php

Verification

docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_mb_strlen_enum.php
php bin/vm.php test/repro/maintainer_mb_strlen_enum.php'
# Zend: TypeError: mb_strlen(): Argument #1 ($string) must be of type string, Es given
# VM:   TypeError: mb_strlen(): Argument #1 ($string) must be of type string, Es given

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit test/compliance/MbStrlenVMTest.php
vendor/bin/phpunit test/compliance/MbStrlenJITTest.php'
# OK (2 tests each)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/compile.php -l test/repro/maintainer_mb_strlen_enum.php'
# exit 0 (AOT lint)

Note: full AOT link (compile.php -o) currently fails on master in this harness with pre-existing StringSerializeDoubleJit LLVM builder error; same failure affects other AOT fixtures (e.g. levenshtein).

Test plan

  • VM repro matches Zend TypeError message
  • JIT enum TypeError compliance green
  • Normal string operands unchanged (mb_strlen.phpt, mb_strlen_jit.phpt)
  • AOT lint (compile.php -l) green

Made with Cursor

Use VmString::coerceStringBuiltinArg and JitStringBuiltinArg for php-src
Z_PARAM_STR parity on mb_strlen string/encoding operands; add VM/JIT/AOT
compliance coverage and wire MbStrlen* test classes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 7a4911b into master Jun 8, 2026
@PurHur
PurHur deleted the agent/issue-5873-mb-strlen-enum-typeerror branch June 8, 2026 00: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: mb_strlen() — enum case operand must TypeError (ext/mbstring/mbstring.c)

1 participant