Skip to content

Stdlib: locale_lookup() JIT path throws instead of matching php-src locale lookup (ext/intl/locale/locale_methods.c) #32118

Description

@PurHur

Category

bug · php-src-strict

Problem

locale_lookup() already has a PHP implementation in ext/intl/VmLocale.php, and the VM path returns the php-src result for ordinary lookup cases. The JIT entrypoint in ext/intl/locale_lookup.php still hard-fails with RuntimeException: locale_lookup() JIT lowering not implemented; use VM, so the same builtin diverges by backend instead of matching Zend/php-src.

Repro Zend / php-src expected JIT (2026-08-18)
locale_lookup([\"de-DE\",\"de\"], \"de-CH\", true, \"en\") \"de\" RuntimeException: locale_lookup() JIT lowering not implemented; use VM

VM/reference confirmation in this tree today:

  • ./script/docker-exec.sh -- bash -lc 'php test/repro/issue_25198_locale_lookup_named.php' prints lookup_pos=de and lookup_named=de
  • ./script/docker-exec.sh -- bash -lc 'php -r '\''require \"vendor/autoload.php\"; var_dump(PHPCompiler\\ext\\intl\\VmLocale::lookup([\"de-DE\",\"de\"], \"de-CH\", true, \"en\"));'\''' prints string(2) \"de\"

php-src reference

PHP implementation target

  • ext/intl/locale_lookup.php — replace the hardcoded JIT exception with lowering that forwards to the existing PHP/intl helper path
  • ext/intl/VmLocale.php — keep the lookup semantics SSOT; JIT should reuse this behavior rather than adding new C/runtime logic
  • lib/JIT/ helper if needed, but keep semantics in PHP-owned intl helpers

Repro

./script/docker-exec.sh -- bash -lc 'php test/repro/issue_25198_locale_lookup_named.php'
./script/docker-exec.sh -- bash -lc 'php -r '\''require "vendor/autoload.php"; $ctx=(new ReflectionClass("PHPCompiler\\JIT\\Context"))->newInstanceWithoutConstructor(); try { (new PHPCompiler\ext\intl\locale_lookup())->call($ctx); } catch (Throwable $e) { echo get_class($e),": ",$e->getMessage(),"\n"; }'\'''

Done when

  • locale_lookup() returns the same result on JIT as php-src/VM for the lookup repro above instead of throwing
  • Named/optional args from test/repro/issue_25198_locale_lookup_named.php behave identically on VM and JIT
  • Compliance .phpt guard under test/compliance/cases/intl/ covers the JIT result path, not only reflection metadata
  • php-src-strict; no php-compiler-strict shortcut

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 / JITbugSomething isn't workingimplementation-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