Skip to content

Language: Spaceship operator (<=>) for sorting and comparisons (#208)#224

Merged
PurHur merged 2 commits into
masterfrom
issue-208-spaceship-operator
May 18, 2026
Merged

Language: Spaceship operator (<=>) for sorting and comparisons (#208)#224
PurHur merged 2 commits into
masterfrom
issue-208-spaceship-operator

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 18, 2026

Summary

  • Implements the PHP spaceship operator (<=>) with a new TYPE_SPACESHIP opcode in the compiler, VM (spaceshipOp with numeric and string semantics), and JIT (LLVM icmp/select for native long/double pairs).
  • Adds compliance PHPTs for VM and JIT (spaceship_operator*.phpt) and patches php-types so Expr_BinaryOp_Spaceship type-checks under PHP 8.2.
  • Fixes Compiler: Not-identical and not-equal operators (!=, !==) parity in JIT #211 compliance regressions: correct EXPECT values, bool callback param (avoids reserved Mixed on PHP 8.2), and cross-type loose == / != in Variable::equals().

Closes #208.

Test plan

  • ./script/docker-ci.sh — VM/compliance phase: 231 tests OK (6 skipped)
  • Manual: php bin/vm.php -r 'echo 1 <=> 2, 2 <=> 2, 3 <=> 2;'-101
  • JIT compliance for spaceship (requires LLVM 9 + php-llvm patches on host)

Made with Cursor

PurHur and others added 2 commits May 18, 2026 18:20
Add TYPE_SPACESHIP opcode end-to-end with LLVM icmp/select lowering for
native int/float pairs, VM spaceshipOp with string strcmp semantics, and
compliance PHPTs. Patch php-types TypeReconstructor for Expr_BinaryOp_Spaceship.

Also fix #211 compliance tests (correct EXPECT, bool param, loose equals).

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep master's looseEqual and not_equal PHPT style; retain spaceship JIT lowering.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit 276ce97 into master May 18, 2026
@PurHur PurHur deleted the issue-208-spaceship-operator branch May 18, 2026 18:21
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.

Compiler: Not-identical and not-equal operators (!=, !==) parity in JIT Language: Spaceship operator (<=>) for sorting and comparisons

1 participant