Category
stdlib
Problem
Zend sprintf() / printf() support positional arguments in the format string (%2$s, %1$d, …) so callers can reorder values without changing argument order. This compiler rejects those specifiers at runtime:
LogicException: sprintf() unsupported conversion specifier %2 in this compiler build
(ext/standard/VmSprintf.php).
php-src reference
Repro (failure today)
<?php
echo sprintf('%2$s %1$s', 'world', 'hello'), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
/usr/bin/php repro.php # Zend: hello world
This compiler: fatal in VmSprintf::format().
Additional cases for done-when:
printf('%1$d-%2$d', 10, 20); // 10-20
sprintf('%2$.2f %1$s', 'pi', 3.14159); // 3.14 pi
Scope (this repo)
| Module |
Path |
| VM formatter |
ext/standard/VmSprintf.php — parse %n$ prefix, remap arg index |
| Builtin wrappers |
ext/standard/sprintf_.php, printf if registered |
| JIT/AOT |
ext/standard/JitSprintf.php — delegate or document VM-only v1 |
| Tests |
test/compliance/cases/stdlib/sprintf_positional.phpt |
| Matrix |
script/capability-matrix.php note on positional support |
Done when
Related
Category
stdlibProblem
Zend
sprintf()/printf()support positional arguments in the format string (%2$s,%1$d, …) so callers can reorder values without changing argument order. This compiler rejects those specifiers at runtime:(
ext/standard/VmSprintf.php).php-src reference
ext/standard/sprintf.c—php_sprintf()positional arg parsing (%n$forms)ext/standard/formatted_print.c— shared formatter helpersRepro (failure today)
This compiler: fatal in
VmSprintf::format().Additional cases for done-when:
Scope (this repo)
ext/standard/VmSprintf.php— parse%n$prefix, remap arg indexext/standard/sprintf_.php,printfif registeredext/standard/JitSprintf.php— delegate or document VM-only v1test/compliance/cases/stdlib/sprintf_positional.phptscript/capability-matrix.phpnote on positional supportDone when
hello worldon VM matching Zend%2$.2f) match Zend on compliance fixtures./script/ci-fast.sh --filter sprintf_positionalgreenRelated
sprintfwith positional forms in placesnumber_format)