Reject root multi-metavariable patterns#2727
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesRoot multi meta variable validation in PatternBuilder
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds validation to reject patterns where a multi-capture meta variable ($$$...) is used as the entire pattern, returning a dedicated error and covering the behavior with tests.
Changes:
- Build patterns first, then reject
$$$...when it is the root node of the pattern. - Introduce a new
PatternError::RootMultiMetaVarerror variant with a specific message. - Add unit tests for rejecting root multi meta vars while keeping existing in-list behavior unchanged.
Comments suppressed due to low confidence (1)
crates/core/src/matcher/pattern.rs:1
- Adding a new variant to a public Rust enum is a SemVer-breaking change for downstream crates that perform exhaustive matching on
PatternError. IfPatternErroris part of the public API, consider marking it#[non_exhaustive](and updating internal matches accordingly), or otherwise ensure this lands with an appropriate breaking-release/version bump policy.
use crate::language::Language;
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2727 +/- ##
==========================================
+ Coverage 86.67% 86.68% +0.01%
==========================================
Files 120 120
Lines 20636 20654 +18
==========================================
+ Hits 17886 17904 +18
Misses 2750 2750 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Root
$$$METApatterns were still accepted at pattern creation time, even though they hit the same root-pattern problem discussed in #2697.This rejects both named and bare root multi-metavariable patterns up front. In-list
$$$behavior is unchanged.I checked the redesign with formatting, pattern tests, core/config tests, the full cargo test suite, clippy, and
git diff --check.Fixes #2697
Summary by CodeRabbit
Bug Fixes
Tests