Repository navigation
Remove leftover code and split long compiler functions - #161
Merged
Merged
Conversation
Clean-code pass with no change to compiler behaviour, diagnostic text or generated output. Output for all 288 x_test projects was compared before and after: 249 LLVM files and every message are identical. Remove code that lost its last caller in earlier redesigns: - parser context stack and owner constants - AST-based place resolution (Resolve, LocalRoot and helpers) with the tests that only covered it, and the Binding wrapper it needed - typechecker copies of two flow diagnostics, Match.Arm - unused backend, IR, emitter and CLI helpers and struct fields - manifest.RemoveDependency (peeper remove does not use it) Simplify: - drop parameters and results no caller uses - merge CallableTypeFor with its private twin - share one quote scanner in the syntax highlighter, one string lexer handler, one temp-store helper in MIR lowering, one arm lookup on thir.Match, and one request helper in the LSP loop - replace deprecated zip and tar calls Split GenerateLLVMIR, checkForInStmt, workspace rebuild and the LSP Run loop into named steps by moving code unchanged. Keep printUnderlineIndent and the unused TOML helpers at maintainer request, with comments saying so. Move ServerState.recompile into a test file since only tests call it. Update architecture docs for removed names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
place, flow/ownership analysis, THIR, MIR lowering, LLVM backend, diagnostics, LSP, CLI,pkg/toml,pkg/manifest,pkg/distribution,pkg/registry.ParseIntegerBuiltinorCompilerOp, and the output-ordering issue described under Risks.Depends on #160; retarget to
mainafter that PR merges.Production ownership
(*thir.Match).Arm:analysis/ownership.go,analysis/flow_thir.go.(*lowerer).storeInTemp: 19 cases inmir/expr_lower.go.scanQuoted: three call sites indiagnostics/syntax_highlighter.go.stringHandler(prefixLen, kind): two lexer patterns.handleRequest: hover, definition, completion and rename in the LSP loop.GenerateLLVMIR,checkForInStmt,workspaceIndex.rebuildandRun: one caller each, the function they came from.analysis/flow_thir.goremains the only resolver; the old AST-based one inplaceis removed.peeper removekeeps its own logic incmd/cli/remove.go.callableType(merged intoCallableTypeFor),place.Binding, typechecker copies of two flow diagnostics,cstringHandler,bindModuleScopeType,bindModuleScopeTypeIfUnset, three copies of the quote scanner, four copies of the LSP request block, the parser context stack.Emitter.printUnderlineIndent,toml.Data.HasSection,toml.Data.EnsureSectionandtoml.ParseBytesalready had no caller; they are kept at maintainer request and now carry a comment saying so.Design and behavior
reportUnresolvedkeeps its nil-node and nil-bag guard.tar.TypeRegAwas dropped from onecase; the Go tar reader already maps it toTypeReg.Armsits onthir.Matchbecause its callers moved to THIR.Validation
cmd/clitests callGetCommand(nil)instead of the removedinstallAllDependencies;placetests use the new resolver signature;ServerState.recompilemoved tointernal/lsp/state_test.go.x_testfixtures.x_testprojects with-keep-genbefore and after. 249.llfiles (compared with line order ignored) and all stdout/stderr are identical. Ranpeeper removeon a scratch project.Diff sanity
pkg/distribution/pack.goalso turns twoif / else ifchains intoswitch. Same behavior.docs/architecture/cli-and-packages.md,frontend.mdandsemantics-bindings.md.Code-tour.mdsection 12 still shows the instruction switch insideGenerateLLVMIR; it now lives inemitBlock. The snippet is marked "simplified" and was left as is.Risks and follow-up
internal/semantics/place/origin_test.gowere deleted with the AST-based resolver they covered. Nothing in production called that resolver since 2026-09-21.analysis/effects.gokeeps its own arm loop: it visits every arm with a case, not only the first, which can matter for programs with duplicate arms.declarelines. Content is the same when line order is ignored.