From 0f27ea68bdf48f90988cee54467f5429f8bac34a Mon Sep 17 00:00:00 2001 From: Amolith Date: Sun, 18 Jan 2026 12:10:24 -0700 Subject: [PATCH] fix(cmd): resolve type checker nil warnings Add ---@cast annotations in clone.lua and new.lua where the type checker couldn't infer that loop-bounded array access returns non-nil. Add early return after shell.die() in add.lua so type checker knows file handle is non-nil when close() is called. Assisted-by: Claude Opus 4.5 via Amp --- src/wt/cmd/add.lua | 1 + src/wt/cmd/clone.lua | 1 + src/wt/cmd/new.lua | 1 + 3 files changed, 3 insertions(+) diff --git a/src/wt/cmd/add.lua b/src/wt/cmd/add.lua index c1b3571aa5c520f8129690f70a55fef4fe1bb281..3097c369a0a212cceadeca70ca1c619c7c3a38c9 100644 --- a/src/wt/cmd/add.lua +++ b/src/wt/cmd/add.lua @@ -77,6 +77,7 @@ function M.cmd_add(args) .. existing_wt.path .. "\nhint: run `git worktree prune` to clean up stale entries" ) + return end wt_check:close() diff --git a/src/wt/cmd/clone.lua b/src/wt/cmd/clone.lua index de10ce1f71ee48e63e8daded3f208bc2797aeb93..86c972598871a5dbde586abdada31ed3ec03f708 100644 --- a/src/wt/cmd/clone.lua +++ b/src/wt/cmd/clone.lua @@ -26,6 +26,7 @@ function M.cmd_clone(args) local positional = {} while i <= #args do local a = args[i] + ---@cast a string if a == "--remote" then if not args[i + 1] then shell.die("--remote requires a name") diff --git a/src/wt/cmd/new.lua b/src/wt/cmd/new.lua index 57c3a8dd95878b603a2681fb739998e452cde95b..bd0e5156306d574529c4e1219ffe08783ea3ebed 100644 --- a/src/wt/cmd/new.lua +++ b/src/wt/cmd/new.lua @@ -25,6 +25,7 @@ function M.cmd_new(args) local positional = {} while i <= #args do local a = args[i] + ---@cast a string if a == "--remote" then if not args[i + 1] then shell.die("--remote requires a name")