Skip to content

Language: numeric-string <=> via zendi_smart_strcmp (#22848)#22864

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-22848-numeric-spaceship
Jul 24, 2026
Merged

Language: numeric-string <=> via zendi_smart_strcmp (#22848)#22864
PurHur merged 1 commit into
masterfrom
agent/issue-22848-numeric-spaceship

Conversation

@PurHur

@PurHur PurHur commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • String↔string <=> (and ordered </> on the VM) used lexicographic strcmp; Zend uses zendi_smart_strcmp so both-is_numeric operands compare as numbers ("10"<=>"2" === 1).
  • Shared SSOT: CompareJitHelperScalars::stringSpaceship (NestedJIT / __value__spaceship); VM Variable::spaceshipOp / string relational; native JIT VmStringCompare::smartStrcmp.
  • php-src-strict; no new C runtime logic.

Closes #22848

php-src reference

  • Zend/zend_operators.czendi_smart_strcmp / is_numeric_string_ex

Test plan

  • Issue repro: php bin/vm.php test/repro/issue_22848_numeric_spaceship.php matches Zend
  • vendor/bin/phpunit --filter SpaceshipCompareJitHelperTest
  • Docker JIT/AOT with PHP_COMPILER_HELPER_RUNTIME_O=1 (lock contended — will paste)
  • Compliance spaceship_numeric_string.phpt

Verification (VM)

php bin/vm.php test/repro/issue_22848_numeric_spaceship.php
'10'<=>'2' => 1
'2'<=>'10' => -1
'1e1'<=>'10' => 0
'0'<=>'00' => 0
' 10'<=>'10' => 0
'10 '<=>'10' => 0
'a'<=>'b' => -1

Made with Cursor

String↔string spaceship and ordered compares used lexicographic strcmp;
match Zend when both operands are_numeric (php-src-strict).

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur

PurHur commented Jul 24, 2026

Copy link
Copy Markdown
Owner Author

Verification (this run)

Trust probe (before claim): inventory OK 6512/6512; north-star5-fast red on gen-0 fingerprint (#22642 / PR #22717 — not this lane).

VM (php bin/vm.php test/repro/issue_22848_numeric_spaceship.php) — matches Zend:

'10'<=>'2' => 1
'2'<=>'10' => -1
'1e1'<=>'10' => 0
'0'<=>'00' => 0

JIT (PHP_COMPILER_HELPER_RUNTIME_O=1 php bin/jit.php …) — same output as Zend/VM.

PHPUnit: SpaceshipCompareJitHelperTest + spaceship_numeric_string — OK (7 tests).

AOT: native literal path shares VmStringCompare::smartStrcmp / NestedJIT CompareJitHelperScalars::stringSpaceship; cold helper-runtime rebuild contended on host — not blocking (JIT exercised the same lowering).

@PurHur
PurHur merged commit 73b286b into master Jul 24, 2026
@PurHur
PurHur deleted the agent/issue-22848-numeric-spaceship branch July 24, 2026 11:53
PurHur added a commit that referenced this pull request Jul 24, 2026
…22866)

Post-#22847 merges (#22857/#22862/#22863/#22864/#22865) moved live
lowering_source_fingerprint to 9aee9361… while the committed stamp stayed
at 159f4081…, redding north-star5-verify-fast step 4f-m and
user_release_ready. Restamp only; honest verified-fresh remains on


#22642/#22717.

Co-authored-by: PurHur <PurHur@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

Language: numeric string spaceship <=> uses lexicographic order — Zend numeric (Zend/zend_operators.c)

1 participant