Skip to content

refactor(checker): decompose infer_call into ordered stage helpers - #162

Merged
sims1253 merged 1 commit into
mainfrom
cleanup/07-infer-call
Sep 2, 2026
Merged

refactor(checker): decompose infer_call into ordered stage helpers#162
sims1253 merged 1 commit into
mainfrom
cleanup/07-infer-call

Conversation

@sims1253

@sims1253 sims1253 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Cleanup sprint, PR 7 of 7 (stacked on #161). Closes #151. infer_call went from 1017 lines of ~49 sequential special cases to a 256-line readable stage sequence; every case is now a named helper in exact original order, with the load-bearing ordering constraints stated at each seam. Net +296 lines — this PR buys structure, not size (issue #151's acceptance is "no function over ~300 lines, behavior identical, ordering documented"; the growth is extracted signatures, Option-plumbing per early-return stage, and the original rationale comments preserved verbatim in their new homes).

Shape

The main body is now literally the stage sequence. Grouped extractions per the issue:

  • Syntax-shape rules (RY093/RY100/RY101) → recall.rs-style helpers; these emit-and-fall-through, as before.
  • NSE/quoting clusterinfer_nse_quoting_call; hasArg/on.exitinfer_deferred_call. The cluster is two functions because RY094 sits between on.exit and library in the original order — preserved, nothing moved.
  • Assertion clusterinfer_assert_scalar_call / infer_stub_assertion_call / apply_assertion_predicates.
  • Constructorsinfer_atomic_constructor_call (c/list/data.frame/t/as.data.frame, construct.rs) and infer_literal_length_call (vector/rep/seq) — two dispatchers, because the literal-length trio deliberately runs after the FnTable stage (a user-defined rep/seq wins); infer_structure_call relocated to construct.rs byte-identically.
  • The tail (S3/S4 dispatch, higher-order, FnTable, typeshed apply_sig) stays as the readable main path; argument inference got a CallResolution struct capturing exactly the snapshots base's locals held.

Verification

  • Full gate after every extraction group: cargo test --workspace + clippy -D warnings + fmt, plus md5 checks over all tracked snapshot files at each step — final state 972/972 tests (exact baseline parity), snapshots byte-identical.
  • Independent review token-diffed every base line into its new location: all stages present once, in order; both ordering subtleties above confirmed; all six emit-and-fall-through stages remain fall-through; no stage dropped; CallResolution has no stale-state reads (the one value base computed later — locally_shadows_stub — is still computed at exactly the original position, after argument inference mutates the scope).

Gates

43 suites green, clippy clean, fmt clean, snapshots byte-identical.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: a735b794-ad16-47c5-a535-1f54fe739d1b

📥 Commits

Reviewing files that changed from the base of the PR and between ffe03e4 and 9b00721.

📒 Files selected for processing (2)
  • crates/ry-checker/src/infer/call.rs
  • crates/ry-checker/src/infer/construct.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the complete diff (both files, single commit), with independent verification of the refactor's fidelity: a stage-by-stage order mapping of the new main body against the old line numbers, a whitespace-stripped multiset diff of base call.rs vs the new call.rs+construct.rs, and local gates (cargo test --workspace green, cargo clippy --workspace --all-targets -- -D warnings clean).

  • Stage-sequence decompositioninfer_call (1017 lines, ~49 sequential special cases) is now a 259-line readable stage sequence; every helper preserves the exact original order, and the load-bearing ordering constraints (foreach before quoting, namespace-assign before local-assign, schema before eager arg inference, assertion before dispatch tail, literal-length after FnTable) are stated at each seam. Meets issue #151's "no function over ~300 lines" acceptance.
  • CallResolution plumbingarg_types / resolved_sig / user_function / lexical_callable / locally_shadows_stub are captured once by infer_argument_types and threaded through the post-inference stages; the one timing trap (locally_shadows_stub must be computed after argument inference mutates the scope, at exactly the original position) is handled correctly by note_dynamic_loader_scope.
  • Extracted clusters — syntax-shape diagnostics (RY093/RY100/RY101/RY094) as emit-and-fall-through checkers; hasArg/on.exit into infer_deferred_call; the NSE/quoting cluster into infer_nse_quoting_call; the assertion cluster into infer_assert_scalar_call / infer_stub_assertion_call / apply_assertion_predicates; the lexical-callable resolution into infer_lexical_callable_call (the else-if chain → early-return restructure is equivalent because the Function-mode branch always returns).
  • Constructor dispatchers in construct.rsinfer_class_constructor_call (structure/factor/new), infer_atomic_constructor_call (c/list/data.frame/t/as.data.frame), infer_literal_length_call (vector/rep/seq/seq.int); infer_structure_call relocated byte-identically. The two two-function splits are both order-preserving, not behavior changes.
  • Verbatim-move evidence — the multiset diff shows all 246 removed base lines reappear as mechanical transforms only (Some(...) wrapping for Option<RType> returns, &String&str borrow adjustments, guard inversions to ?/early-return, resolution. prefixes, comment reflows); no behavioral line is unaccounted for. All six emit-and-fall-through stages remain fall-through, and local tests confirm snapshot parity.

Pullfrog  | View workflow run | Using openai-compatible/glm-5.3𝕏

@sims1253
sims1253 changed the base branch from cleanup/06-walkers to main September 2, 2026 10:12
@sims1253
sims1253 force-pushed the cleanup/07-infer-call branch from d8315b4 to 9b00721 Compare September 2, 2026 10:13
@sims1253
sims1253 merged commit 62b9290 into main Sep 2, 2026
15 of 16 checks passed
@sims1253
sims1253 deleted the cleanup/07-infer-call branch September 2, 2026 10:19
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.

Decompose infer_call

1 participant