compiler refactor #515
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
rust
technical-debt
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
navicore/patch-seq!515
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "may-refactor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Session recap: all non-test HIGH items in crates/compiler are now audited.
This session covered 20 files:
Refactored (13): error_flag_lint/analyzer.rs, codegen_ops.rs, resolver.rs,
typechecker/control_flow.rs, stack_utils.rs, parser/type_parse.rs,
parser/statements.rs, unification.rs, typechecker/driver.rs, quotations.rs,
typechecker/words.rs, main/lint.rs, ffi/manifest.rs, call_graph.rs,
parser/token.rs, codegen_calls.rs, builtins/list.rs, codegen/types.rs,
virtual_stack.rs, builtins/map.rs — recurring wins were context-structs
(TarjanState), single-source-of-truth helpers (span_line, or_exit,
emit_specialized_call, flush_token, quot promoted to macros.rs), fixing
several misattributed/stale doc comments, and dispatch-table consolidation.
Reviewed clean, no changes (7): types.rs, codegen/state.rs,
builtins/text.rs, and the 6 runtime/*.rs declarative tables
(batch-cleared).
Everything verified green at each step (just lint clean, 388 compiler-lib /
1140 workspace tests passing). The checklist at
tmp/rust-audit-crates-compiler.md reflects all of it, including the
deferred cross-file notes (e.g. Pattern::variant_name(), Parser::expect(),
FlagStack::clear_flags(), the runtime DECLS/SYMBOLS unification).
Review — approve, no blockers
What I verified
just cigreen on branch HEAD: 547 integration tests pass (same asmain— no regression), all 9 CI checks ✓.crates/compiler/src/typechecker/combinators.rs— clean refactor. The 5 quotation-effect dispatch arms (Quotation/Closure/Varfallback / error) consolidated into oneextract_quotation_effecthelper. Critically, the issue #471polymorphic_popcalls are preserved at all 5 sites (dip, keep, bi, if-cond, if-combinator).crates/compiler/src/ast/program.rs— wholesale restructure (+448/−453, net −5). Verified the hoistedconst BUILTINS: &[&str]is bit-identical to the original embedded list: 273 unique literals on both sides, zero differences.Two NOTABLE items (neither a blocker, both deliberate)
builtins/macros.rsty!catch-all. Enumerated arms forT, U, V, …, Accreplaced with a single$v:ident => Type::Var(stringify!($v)). Current call sites unaffected; future typos likety!(Bol)now silently become a type variable instead of a macro error. Surface area is small (internal, only called insidebuiltin!), but the compile-time guard is gone — worth a deliberate yes.codegen/specialization/codegen_word.rsemit_branchconsolidation. Then/else duplication folded into one helper;else_branch.unwrap_or(&[])collapses the oldis_none() || is_empty()guard into a singleis_empty()check on the slice. Semantically equivalent on inspection.Deferred follow-ups noted in the PR description
Confirmed not addressed in this PR (and shouldn't be — out of scope):
Pattern::variant_name()Parser::expect()FlagStack::clear_flags()DECLS/SYMBOLSunificationThe
ArmInfostruct introduced incodegen/control_flow.rsis the natural home for a futurePattern::variant_name()extraction.Other notable wins worth calling out
TarjanStatecontext-struct incall_graph.rswith accurate.expect("Tarjan invariant: …")messages — better failure mode than the prior.unwrap()s.span_linehelper deduping 5 copies intypechecker/control_flow.rs.flush_tokeninparser/token.rs(3 sites folded).or_exitinmain/lint.rs(5 match-and-die blocks deduped).pop_actual_capture_typesextraction intypechecker/quotations.rswith the load-bearing "don't unify, use actual types" invariant preserved verbatim.Net diff: +1342 / −1599 — a refactor that removes code. Exactly the right shape.