Skip to content

🧹 Refactor overly long function lower_stmts_with_env - #331

Open
undivisible wants to merge 1 commit into
masterfrom
refactor-lower-stmts-with-env-2741279766877485696
Open

🧹 Refactor overly long function lower_stmts_with_env#331
undivisible wants to merge 1 commit into
masterfrom
refactor-lower-stmts-with-env-2741279766877485696

Conversation

@undivisible

@undivisible undivisible commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 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.


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.rs by pulling If, Loop, Match, and Try handling out of the main lower_stmts_with_env statement loop into dedicated helpers: lower_if_stmt, lower_loop_stmt, lower_match_stmt, and lower_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.

🎯 **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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@mergify

mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

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.

1 participant