Skip to content

bug(#631): match fails on empty substs#633

Merged
rultor merged 2 commits intoobjectionary:masterfrom
maxonfjvipon:bug/#631/match-fails-on-empty-substs
Mar 17, 2026
Merged

bug(#631): match fails on empty substs#633
rultor merged 2 commits intoobjectionary:masterfrom
maxonfjvipon:bug/#631/match-fails-on-empty-substs

Conversation

@maxonfjvipon
Copy link
Copy Markdown
Member

@maxonfjvipon maxonfjvipon commented Mar 17, 2026

Closes: #631

Summary by CodeRabbit

  • Bug Fixes

    • CLI now explicitly reports an error when a pattern produces no substitutions, replacing the previous silent/debug-only behavior with clearer feedback.
  • Tests

    • Added a test asserting that pattern-matching with no substitutions fails and emits an error, ensuring the new behavior is covered.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6bbd4d5a-22ae-4636-b330-ecdf733728e7

📥 Commits

Reviewing files that changed from the base of the PR and between 7389eb4 and 501c8da.

📒 Files selected for processing (1)
  • test/CLISpec.hs
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/CLISpec.hs

📝 Walkthrough

Walkthrough

runMatch now throws an EmptySubstsOnMatch CmdException when pattern matching produces no substitutions instead of only logging a debug message. A new exception constructor and Show message were added, and a test was added to assert the failing behavior.

Changes

Cohort / File(s) Summary
CLI Types
src/CLI/Types.hs
Added EmptySubstsOnMatch constructor to CmdException and updated its Show instance with message: "Provided pattern was not matched, no substitutions are built".
Match Runner
src/CLI/Runners.hs
Changed runMatch to throw EmptySubstsOnMatch when substs is empty instead of emitting a debug log.
Tests
test/CLISpec.hs
Added test "fails on empty substitutions" asserting the match command errors when no substitutions are produced.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through patterns, light and spry,
Found no carrots where they lie,
I thumped my foot, declared a fuss,
"EmptySubstsOnMatch" — hop, we must! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: fixing the match command to fail when empty substitutions are produced.
Linked Issues check ✅ Passed The changes implement the requirement from issue #631: the match command now fails (throws EmptySubstsOnMatch exception) when no substitutions are found instead of silently succeeding.
Out of Scope Changes check ✅ Passed All changes are directly scoped to addressing issue #631: adding the exception type, throwing it when substitutions are empty, and testing the behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/CLISpec.hs`:
- Around line 1030-1035: Remove the trailing whitespace at the end of the
withStdin argument in the test case labeled "fails on empty substitutions" so
the line containing withStdin "{Q.x.y}" has no extra spaces after the closing
brace; this fixes the fourmolu/formatter failure referenced in the test using
testCLIFailed and withStdin.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d9f48d94-89a7-47a4-a2fb-bd84d1429058

📥 Commits

Reviewing files that changed from the base of the PR and between 56c980a and 7389eb4.

📒 Files selected for processing (3)
  • src/CLI/Runners.hs
  • src/CLI/Types.hs
  • test/CLISpec.hs

@maxonfjvipon
Copy link
Copy Markdown
Member Author

@rultor merge

@rultor
Copy link
Copy Markdown
Contributor

rultor commented Mar 17, 2026

@rultor merge

@maxonfjvipon OK, I'll try to merge now. You can check the progress of the merge here.

@rultor rultor merged commit 501c8da into objectionary:master Mar 17, 2026
23 checks passed
@rultor
Copy link
Copy Markdown
Contributor

rultor commented Mar 17, 2026

@rultor merge

@maxonfjvipon Done! FYI, the full log is here (took me 19min).

@0crat
Copy link
Copy Markdown

0crat commented Mar 17, 2026

@maxonfjvipon Hey! Nice work on that contribution – you've bagged +12 points this time! 🎯 Here's the breakdown: +16 base points, but -4 for keeping it lean with just 10 hits-of-code (our policy encourages at least 40 for the full bonus). Still, quality over quantity – keep them coming! Your running score sits pretty at +122, and don't forget to peek at your Zerocracy account for the latest updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

match command does not return exit code 1 on not found matches

3 participants