Fix predicate numeric probe erroring on multi-item sequences#148
Open
boukeversteegh wants to merge 2 commits intoPaligo:mainfrom
Open
Fix predicate numeric probe erroring on multi-item sequences#148boukeversteegh wants to merge 2 commits intoPaligo:mainfrom
boukeversteegh wants to merge 2 commits intoPaligo:mainfrom
Conversation
e013f0c to
f218cd3
Compare
) `pop_is_numeric` used `atomized_option`, which raises XPTY0004 on any sequence of length > 1. That turned predicates like `a[b]` into errors whenever `<a>` had more than one `<b>` child, instead of falling through to EBV as the XPath spec requires. Return `false` for empty or multi-item atomized sequences so the EBV path handles them. Updates one snapshot (`(1,2,3)[(2,3)]` now fails with FORG0006 from EBV instead of XPTY0004) and adds a regression test for `//a[b]` against multi-child XML. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Four lints newly promoted in Rust 1.95.0 started failing CI: - `interpret.rs`: collapsible_match — merge nested `if` into a guarded match arm on `xot::Value::Text(text) if text.get().is_empty()`. - `library/map.rs` (x2): useless_conversion — drop `.into_iter()` on values already implementing `IntoIterator` inside `Vec::extend`. - `xslt-ast/whitespace.rs`: collapsible_match — same pattern, merge nested `if` into the outer `Value::Text(text)` arm's guard. Mechanical clippy autofix equivalents; no behavior change. Verified locally against rustc 1.95.0 with `cargo clippy --all-targets --all-features -- -D warnings` and `cargo test --workspace`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f218cd3 to
120fd8f
Compare
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.
Fixes #147.
Summary
pop_is_numericusedValue::atomized_option, which raisesXPTY0004on any sequence of length > 1. That turned predicates likea[b]into errors whenever an<a>had more than one<b>child, instead of falling through to the effective-boolean-value path the XPath spec requires.falsefor empty or multi-item atomized sequences so the EBV path handles them. Only a single atomized value can be a numeric predicate; anything else is not numeric by definition.Behavior change
a[b](and//lambda[body/block/expression_statement], etc.) now match correctly when the inner path can yield more than one node.(1, 2, 3)[(2, 3)]still errors, but now withFORG0006— the correct spec error for applying EBV to a heterogeneous non-node multi-item sequence. One snapshot updated to reflect this.Tests
test_node_predicate_with_multiple_childrencovering//a[b]against<root><a><b>…</b></a><a><b>…</b><b>…</b></a></root>.cargo test --workspace— all green.cargo clippy --all-targets --all-features -- -D warnings— clean on Rust 1.95.0.QT3 conformance gain
Re-running
xee-testrunner update vendor/xpath-tests/shrankvendor/xpath-tests/filtersby 5 tests underprod-Predicate, all the same bug class:Before the fix these threw
XPTY0004(wrong error). After the fix they throwFORG0006(EBV-on-heterogeneous-non-node-sequence), matching the spec. The filter update is included in this PR so conformance tracking stays tight.Bundled clippy cleanup (happy to split if preferred)
CI runs on the floating
stabletoolchain and Rust 1.95.0 promoted a few lints to errors. Fixed in a separate commit on this branch:interpret.rs:collapsible_match— merged nestedifinto a guarded match arm.library/map.rs(×2):useless_conversion— dropped.into_iter()insideVec::extend.xslt-ast/whitespace.rs:collapsible_match— same pattern.Purely mechanical; no behavior change. If you'd rather merge this as a standalone PR, say the word and I'll split the commit out.
🤖 Generated with Claude Code