Skip to content

Stdlib: random_int() min:/max: named parameters rejected (ext/random/random.c) #10043

Description

@PurHur

Category

stdlib · php-src-strict

Problem

php-src names random_int() parameters min and max. Zend accepts:

random_int(min: 1, max: 3); // int in [1,3]

VM rejects with Unknown named parameter $min. Positional random_int(1, 3) works.

php-src reference

Repro (failure today)

<?php
echo random_int(min: 1, max: 3), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php repro.php
php bin/vm.php repro.php
# VM: Unknown named parameter $min
'
Call Zend PHP 8.2+ VM today
random_int(min: 1, max: 3) int in range fatal ❌
positional int in range int in range ✅

Scope (this repo)

Path Work
patches/php-types*.patch / builtin arginfo Export min/max for random_int
lib/Compiler.php, lib/VM/NamedArgs.php, lib/JIT/NamedArgs.php Named binding
ext/standard/random_int.php (or random module) handler after arg wiring
Tests test/compliance/cases/stdlib/random_int_named.phpt

PHP-in-PHP first — no new runtime/*.c.

Done when

  • Repro runs without fatal; result in [1,3] on VM
  • max < min still throws ValueError like Zend
  • ./script/docker-exec.sh -- vendor/bin/phpunit --filter random_int_named green

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:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions