Fix ?? (nullish coalescing) earlyOut to not short-circuit on falsy values#345
Fix ?? (nullish coalescing) earlyOut to not short-circuit on falsy values#345brianmhunt merged 4 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 26 minutes and 34 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughModified the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Suggested reviewers
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 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 |
Regression test for the earlyOut fix. Uses a counter-backed rhs function so the test fails when earlyOut is `a => a` (rhs invoked on 0/''/false) and passes with `a => a !== null && a !== undefined`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Summary
The
??operator'searlyOutwasa => a, identical to||. This caused??to short-circuit on falsy values like0,'', andfalse, which is incorrect —??should only short-circuit when the value is notnulland notundefined.Detected in #297
Fix
Verification
All 404 parser tests pass. Full suite (5371 tests) passes.
Summary by CodeRabbit
nullandundefinedvalues separately from other falsy values.