From bf0f36dc993278523e404c2489df9acc50c77c19 Mon Sep 17 00:00:00 2001 From: Christoph Brandau Date: Tue, 19 Aug 2025 13:13:17 +0200 Subject: [PATCH] feat: regsub variable declaration check --- server/src/tools/checks.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/tools/checks.py b/server/src/tools/checks.py index dfeaae6..f158718 100644 --- a/server/src/tools/checks.py +++ b/server/src/tools/checks.py @@ -120,6 +120,15 @@ class UndeclaredVariableCheck(Visitor): base = text.split("(", 1)[0] # Handle array syntax if not base.startswith("::"): locals_set.add(base) + elif name == "regsub" and node.args: + # regsub ?switches? exp string subSpec ?varName? + # If a varName is provided as the last arg, treat it as a local + last_arg = node.args[-1] + text = _word_text(last_arg) + if text: + base = text.split("(", 1)[0] + if base and not base.startswith("::"): + locals_set.add(base) elif name == "foreach" and len(node.args) >= 3: # foreach varlist1 list1 ?varlist2 list2 ...? body # Treat loop variables as locals within the proc