Fix semver:eq#3 ignoring $coerce parameter#66
Open
joewiz wants to merge 2 commits intoeXist-db:masterfrom
Open
Fix semver:eq#3 ignoring $coerce parameter#66joewiz wants to merge 2 commits intoeXist-db:masterfrom
joewiz wants to merge 2 commits intoeXist-db:masterfrom
Conversation
semver:eq/3 was calling semver:compare/2 instead of semver:compare/3, causing the \$coerce argument to be silently ignored. Also make semver:eq/2 delegate to semver:eq/3 (with false()) for consistency with all other arity-2 comparison functions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Test that semver:eq/3 correctly uses $coerce when comparing non-SemVer strings, covering both the equal and not-equal cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Member
Author
|
For the record, here's the log of the session that produced this PR: https://gist.github.com/joewiz/0d90cae455ca015bac2a8d2a05eb202c |
line-o
reviewed
Feb 20, 2026
Member
line-o
left a comment
There was a problem hiding this comment.
Looking good.
Would it make sense to have the opposite test as well?
declare
%test:assertFalse
function stc:eq-non-semver-without-coerce-fails() {
semver:eq("1.0", "1.0.0", false())
};
Member
Author
|
@line-o Thanks! The attempt to parse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
semver:eq#3was callingsemver:compare#2instead ofsemver:compare#3, causing the$coerceargument to be silently ignored. Callingsemver:eq("1.0", "1.0.0", true())would throw an error instead of returningtrue().semver:eq#2is updated to delegate tosemver:eq($v1, $v2, false()), consistent with all other arity-2 comparison functions (lt,le,gt,ge,ne).compare.xqmcovering the equal and not-equal cases with coercible non-SemVer strings.Test plan
stc:eq-coerce-non-semver—semver:eq("1.0", "1.0.0", true())returnstrue()stc:eq-coerce-non-semver-not-equal—semver:eq("1.0", "2.0.0", true())returnsfalse()🤖 Generated with Claude Code