🧹 Refactor overly long function lower_stmts_with_env - #331
Conversation
🎯 **What:** Extracted branches of `match st` inside `lower_stmts_with_env` into separate helper functions (`lower_if_stmt`, `lower_loop_stmt`, `lower_match_stmt`, `lower_try_stmt`). 💡 **Why:** The `lower_stmts_with_env` function was very large (>250 lines), making it hard to read and maintain. By extracting the complex branch handling (like `If`, `Loop`, `Match`, and `Try` statements) into their own methods, we reduce the complexity of the main loop and improve overall readability of `in-cli/src/lower_core.rs`. ✅ **Verification:** Ran `cargo test` on all crates. Verified `lower_core` unit tests pass. Ran `cargo clippy`. Ran `IN_TEST_SKIP_SWIFT=1 ./install.sh && ~/.local/bin/in test` to run conformance tests (failed tests are pre-existing issues). ✨ **Result:** The `lower_stmts_with_env` function is now much shorter and easier to understand, delegating block statement compilation to dedicated, focused helper functions. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@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. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_3d0ea841-e64d-4091-8c94-9ab3fd24b31e) |
|
Tick the box to add this pull request to the merge queue (same as
|
🎯 What:
Extracted branches of
match stinsidelower_stmts_with_envinto separate helper functions (lower_if_stmt,lower_loop_stmt,lower_match_stmt,lower_try_stmt).💡 Why:
The
lower_stmts_with_envfunction was very large (>250 lines), making it hard to read and maintain. By extracting the complex branch handling (likeIf,Loop,Match, andTrystatements) into their own methods, we reduce the complexity of the main loop and improve overall readability ofin-cli/src/lower_core.rs.✅ Verification:
Ran
cargo teston all crates. Verifiedlower_coreunit tests pass. Rancargo clippy. RanIN_TEST_SKIP_SWIFT=1 ./install.sh && ~/.local/bin/in testto run conformance tests (failed tests are pre-existing issues).✨ Result:
The
lower_stmts_with_envfunction is now much shorter and easier to understand, delegating block statement compilation to dedicated, focused helper functions.PR created automatically by Jules for task 2741279766877485696 started by @undivisible
Note
Low Risk
Mechanical move-only refactor in the compiler lowering path; behavior should be unchanged if tests pass.
Overview
Refactors the Core IR → textual SIL lowering in
lower_core.rsby pullingIf,Loop,Match, andTryhandling out of the mainlower_stmts_with_envstatement loop into dedicated helpers:lower_if_stmt,lower_loop_stmt,lower_match_stmt, andlower_try_stmt.The main dispatcher now delegates to those functions with the same SSA, environment, and output-buffer parameters; the extracted code preserves the prior behavior (basic blocks, env cloning/scoping for branches, pattern bindings, and try/catch labels). No intended change to emitted SIL—this is a readability and maintainability split for an oversized function.
Reviewed by Cursor Bugbot for commit bc33279. Configure here.