fix(promql): set-op default matching is ignoring([]), not on([]) (#68) - #74
Merged
Conversation
…n([]) (#68) The parser attaches a default modifier to every `and`/`or`/`unless`, whose `matching` is `None`. `walk_binary` mapped that to `VectorMatch{On, []}` — byte-identical to an explicit `on()`. So `a and b` and `a and on() b` lowered to the same tree, and the default "match on all shared labels" was misrepresented as "match on the empty label set". The default is exactly `ignoring([])` (ignore no labels ⇒ match on all shared labels). Map the `None` arm to `Ignoring([])` instead: - `a and b` → Ignoring([]) - `a and on() b` → On([]) (now distinct) - `a and ignoring() b` → Ignoring([]) (now correctly equal to default) Added `set_op_default_match_is_ignoring_empty_not_on_empty` (distinct-vs-on, equal-to-ignoring). Full workspace suite green; clippy --all-targets clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #68 (MEDIUM, from the whole-repo review).
Bug
The parser attaches a default modifier to every
and/or/unless(itsmatchingisNone).walk_binarymapped that toVectorMatch{On, []}— byte-identical to an expliciton(). Soa and banda and on() blowered to the same L3 tree, and the default "match on all shared labels" was misrepresented as "match on the empty label set".Fix
The default is exactly
ignoring([])(ignore no labels ⇒ match on all shared labels). Map theNonearm toIgnoring([]):a and b(default)On([])Ignoring([])a and on() bOn([])On([])a and ignoring() bIgnoring([])Ignoring([])Now default is distinct from explicit
on()and correctly equal to explicitignoring().Verified
set_op_default_match_is_ignoring_empty_not_on_emptyasserts both (assert_distinct("a and b", "a and on() b")+assert_equiv(["a and b", "a and ignoring() b"])). Existing binary-op e2e tests (arithmetic/comparison/on(job)) unaffected. Full suite green (29 binaries), clippy clean.🤖 Generated with Claude Code