Skip to content

Language: Range value object missing — Range::from() foreach fails on 8.4 profile (ext/standard/range.c) #17427

Closed

Description

@PurHur

Category

language · php-src-strict · PHP 8.4 forward profile

Problem

PHP 8.4 adds the Range value object for inclusive foreach iteration over integer and string intervals. On PHP_COMPILER_PROFILE=8.4, this compiler has no Range class — class_exists('Range') is false and Range::from() fatals.

Repro Zend 8.4+ VM (2026-07-08, profile 8.4)
foreach (Range::from(1, 3) as $i) yields 1,2,3 Class "Range" not found
foreach (Range::from('a', 'c') as $c) yields a,b,c same fatal

php-src reference

PHP implementation target

  • ext/standard/Range.php (or dedicated module unit) — VM iteration over int/string inclusive bounds
  • Register on forward profile only (CompilerVersion gate matching other PHP 8.4 builtins)
  • Optional JIT later; VM parity first

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export PHP_COMPILER_PROFILE=8.4
php bin/vm.php test/repro/maintainer_gap_range_from_84.php'
# fail: class_exists(Range) false

Done when

  • Range::from(1, 3) and Range::from('a', 'c') iterate with Zend-matching values on VM under PHP_COMPILER_PROFILE=8.4
  • class_exists('Range') false on 8.2 reference profile (no phantom)
  • Compliance .phpt guard under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 8, 2026
  2. PurHur commented on Jul 8, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-a — starting this run

  3. PurHur commented on Jul 8, 2026

    @PurHur
    OwnerAuthor

    Merged #17433

    Verification (PHP_COMPILER_PROFILE=8.4):

    • php bin/vm.php test/repro/maintainer_gap_range_from_84.php → ok
    • vendor/bin/phpunit --filter RangeBuiltinTest → OK
    • vendor/bin/phpunit --filter range_from_84 test/compliance/VMTest.php → OK
    • Reference profile: class_exists('Range', false) → false (phantom gate)

    Implementation: ext/standard/RangeBuiltin.php — Range::from() + IteratorAggregate::getIterator() via VmRange + ArrayIteratorBuiltin; gated by CompilerVersion::supportsRange().

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-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions