fix(noUnreachable): handle dead implicit jumps in finally#9305
fix(noUnreachable): handle dead implicit jumps in finally#9305
Conversation
🦋 Changeset detectedLatest commit: 8c3ef40 The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughFixes the noUnreachable analysis so code in Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/correctness/noUnreachable/JsTryFinallyStatement.js (1)
62-93: Consider adding one nestedtry/finallyjump case.A nested cleanup-chain test would harden this against future regressions in terminator restoration.
Possible test extension
+function JsTryFinallyStatement8() { + while (true) { + try { + try { + break; + } finally { + console.log("inner finally reachable"); + } + } finally { + console.log("outer finally reachable"); + } + console.log("unreachable"); + } +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_js_analyze/tests/specs/correctness/noUnreachable/JsTryFinallyStatement.js` around lines 62 - 93, Add a nested try/finally test to ensure cleanup chain restoration: create a new test function (e.g., JsTryFinallyStatement8) that has an outer try { try { /*jump: break/continue/return*/ } finally { console.log("inner reachable"); } } finally { console.log("outer reachable"); } followed by an unreachable console.log to assert the jump does not skip either finally; use the same pattern as JsTryFinallyStatement5–7 but nest an inner try/finally that performs the jump so both inner and outer finally blocks are executed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@crates/biome_js_analyze/tests/specs/correctness/noUnreachable/JsTryFinallyStatement.js`:
- Around line 62-93: Add a nested try/finally test to ensure cleanup chain
restoration: create a new test function (e.g., JsTryFinallyStatement8) that has
an outer try { try { /*jump: break/continue/return*/ } finally {
console.log("inner reachable"); } } finally { console.log("outer reachable"); }
followed by an unreachable console.log to assert the jump does not skip either
finally; use the same pattern as JsTryFinallyStatement5–7 but nest an inner
try/finally that performs the jump so both inner and outer finally blocks are
executed.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_js_analyze/tests/specs/correctness/noUnreachable/JsTryFinallyStatement.js.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (3)
.changeset/fix-no-unreachable-try-finally.mdcrates/biome_js_analyze/src/lint/correctness/no_unreachable.rscrates/biome_js_analyze/tests/specs/correctness/noUnreachable/JsTryFinallyStatement.js
Merging this PR will not alter performance
Comparing Footnotes
|
dyc3
left a comment
There was a problem hiding this comment.
would you mind including which models were used for AI prs? its no big deal but I'm trying to gauge how different models perform for what tasks
|
I've used 4.5 sonnet until last week. I recently switched to 4.6 sonnet |
There was a problem hiding this comment.
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 `@crates/biome_js_analyze/src/lint/correctness/no_unreachable.rs`:
- Around line 637-643: When handling finally_fallthrough, prefer the actual
terminator produced by the finally block over the saved pre_finally_terminator
so we don't drop a newer cause; change the continuation_terminator selection
(currently let continuation_terminator =
path.pre_finally_terminator.unwrap_or(path.terminator)) to prefer
path.terminator when it represents a terminating outcome (e.g., return/throw)
and only fall back to path.pre_finally_terminator when path.terminator is
non-terminating/empty—i.e., choose the active finally terminator
(path.terminator) if it indicates termination, otherwise use
path.pre_finally_terminator.
Summary
Closes #4946
It took a while for the AI agent to get the fix right.
Test Plan
Added a test
Docs