Fix switch default clause not participating in fallthrough#47
Conversation
When a prior case matched and fell through, the default clause body was unconditionally skipped because the first-pass loop used Continue for every default clause regardless of match state. Now the default clause is only skipped when no match has been found yet; once Matched = True, it falls through like any other clause. Fixes #46 Co-authored-by: Johannes Stein <frostney@users.noreply.github.com>
|
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 (2)
📝 WalkthroughWalkthroughA bug fix enabling the default clause to participate in switch statement fallthrough after a matched case, paired with comprehensive test cases validating various fallthrough scenarios and the interaction between cases, defaults, and break statements. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
Benchmark Results254 benchmarks · 🔴 18 regressed · 236 unchanged · avg -2.3% arraybuffer.js — 14 unchanged · avg +0.7%
arrays.js — 19 unchanged · avg +0.3%
async-await.js — 6 unchanged · avg -0.4%
classes.js — 31 unchanged · avg -1.4%
closures.js — 11 unchanged · avg -2.4%
collections.js — 12 unchanged · avg -1.3%
destructuring.js — 22 unchanged · avg -1.9%
fibonacci.js — 8 unchanged · avg -0.8%
for-of.js — 7 unchanged · avg -1.8%
iterators.js — 🔴 4 regressed, 16 unchanged · avg -4.5%
json.js — 🔴 4 regressed, 16 unchanged · avg -4.8%
jsx.jsx — 🔴 1 regressed, 20 unchanged · avg -3.3%
numbers.js — 🔴 1 regressed, 10 unchanged · avg -5.0%
objects.js — 🔴 3 regressed, 4 unchanged · avg -5.9%
promises.js — 🔴 4 regressed, 8 unchanged · avg -6.1%
strings.js — 🔴 1 regressed, 10 unchanged · avg -3.5%
typed-arrays.js — 22 unchanged · avg +0.1%
Measured on ubuntu-latest x64. Changes within ±7% are considered insignificant. |
When a prior case matched and fell through, the default clause body was unconditionally skipped because the first-pass loop used Continue for every default clause regardless of match state. Now the default clause is only skipped when no match has been found yet; once Matched = True, it falls through like any other clause.
Fixes #46
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests