Conversation
Replaced manual `Value` matching boilerplate across `src/stdlib/pattern.rs` with newly unified `expect_pattern` and `expect_text` helpers, significantly reducing redundancy. Co-authored-by: logbie <1138960+logbie@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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
Refactors standard-library pattern functions to remove duplicated match boilerplate by centralizing Value variant extraction into reusable helpers.
Changes:
- Added a new
expect_patternextractor viagenerate_expect!insrc/stdlib/helpers.rs. - Updated pattern stdlib natives to use
expect_text/expect_patterninstead of hand-writtenmatchblocks, preserving source location where needed. - Updated a legacy unit test to assert the new (helper-generated) error message text.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/stdlib/pattern.rs |
Replaces manual Value extraction with expect_text / expect_pattern and maps errors to retain line/column in interpreter-called natives. |
src/stdlib/pattern_test.rs |
Updates assertion to match the new standardized “Expected text …” error message. |
src/stdlib/helpers.rs |
Adds expect_pattern using the existing generate_expect! macro to standardize Pattern extraction/errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// | ||
| /// # Errors | ||
| /// | ||
| /// Returns `RuntimeError` if the value is not a Pattern. |
There was a problem hiding this comment.
The # Errors section here is less specific than the other generate_expect! helpers in this file (e.g., expect_text, expect_list) which document that the error message includes both the expected type and the actual Value::type_name(). Consider aligning this doc comment with the established pattern so callers know what information will be included in the RuntimeError message.
| /// Returns `RuntimeError` if the value is not a Pattern. | |
| /// Returns `RuntimeError` if the value is not a Pattern. The error message includes | |
| /// both the expected type ("a Pattern") and the actual `Value::type_name()`. |
Automatically ran `cargo fmt` to resolve line length issues introduced in the previous commit. Co-authored-by: logbie <1138960+logbie@users.noreply.github.com>
Summary of Changes
matchblocks used to safely extractValue::TextandValue::Patternvariants within the standard library's pattern functions (pattern_matches_native,pattern_find_native,pattern_find_all_native,native_pattern_replace, andnative_pattern_split).expect_patternmacro function was created usinggenerate_expect!insrc/stdlib/helpers.rs. All previously redundant manualmatchblocks for patterns and text were replaced with robustexpect_patternandexpect_textcalls. In functions where detailedlineandcolumncontext is required for error reporting, the generic helper errors were explicitly mapped back to retain source locations. Finally, a legacy integration test strictly asserting exact string values for the legacy manual error message was updated.Verification Checklist
cargo fmtexecuted and passed.cargo clippyreturned no warnings or errors.cargo testsuites passed (100% success rate).PR created automatically by Jules for task 15559435467753125591 started by @logbie
Summary by CodeRabbit
New Features
Refactor
Tests