Skip to content

Stdlib: version_compare() invalid $operator throws ValueError (#4319) - #7840

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-4319-version-compare-valueerror
Jun 9, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-4319-version-compare-valueerror

Conversation

@PurHur

@PurHur PurHur commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • version_compare() with an unknown third $operator now throws ValueError (not LogicException / silent false), matching php-src ext/standard/versioning.c.
  • VM: VmInfo::evaluateVersionCompareOperator() + applyVersionCompareOperator() shared helper.
  • JIT/AOT: compile-time invalid operator lowers via TypeErrorRaise::emitValueError; dynamic operators validated in versionCompareWithOperator().
  • Fixes StringVersionCompareJit::emitCompareSpecialForms() branchIf typo (passed icmp value instead of else block) that blocked AOT LLVM lowering.

php-src reference

  • ext/standard/versioning.c — php_version_compare() operator validation (zend_argument_value_error)

Verification

# Issue repro — Zend vs VM/JIT
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/version_compare_invalid_operator.php
php bin/vm.php test/repro-maintainer/version_compare_invalid_operator.php
php bin/jit.php test/repro-maintainer/version_compare_invalid_operator.php
'
# All three print:
# version_compare(): Argument #3 ($operator) must be a valid comparison operator

# Compliance + JIT
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter version_compare_invalid_operator'
# VM + JIT: OK (2 tests). AOT fixture: LLVM compile+link reaches run; harness lacks libz (-lz) like other AOT cases.

# AOT lint (compile path)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/compile.php -l test/repro-maintainer/version_compare_invalid_operator.php'
# exit 0

Closes #4319

Made with Cursor

Match php-src ext/standard/versioning.c: reject unknown $operator with
ValueError on VM, JIT, and AOT compile paths. Add compliance/AOT PHPTs and
fix StringVersionCompareJit branchIf typo blocking AOT lowering.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 1f6e59b into master Jun 9, 2026
@PurHur
PurHur deleted the agent/issue-4319-version-compare-valueerror branch June 9, 2026 23:02
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.

Stdlib: version_compare() — invalid $operator must throw ValueError (ext/standard/versioning.c parity)

1 participant