From 54818261e141365e69b97812ce45b73da7035ccf Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Sat, 20 Jun 2026 22:15:41 +0000 Subject: [PATCH] test: widen window-collision classifier to recognize long bare-identifier exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #2715/#2771 brick-guard (test_window_function_collision) capped the window.X=RHS capture at 32 chars and required a trailing terminator to classify a bare identifier, so a very long function name (e.g. _renderLiveAnchorActivitySceneSnapshotForStream, 47 chars) was misclassified as 'other' → false positive on the now-correct direct-assignment exports. Widen capture to 80 chars + recognize an identifier running to end-of-window. Still flags the real object/number/other bug shapes. --- tests/test_window_function_collision.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_window_function_collision.py b/tests/test_window_function_collision.py index 4c5dfaac..1cb5f8b3 100644 --- a/tests/test_window_function_collision.py +++ b/tests/test_window_function_collision.py @@ -40,7 +40,7 @@ TOP_LEVEL_FN_RE = re.compile(r"^function\s+([A-Za-z_\$][A-Za-z_\$0-9]*)\s*\(", r # to see `function(` (8 chars) even after some whitespace; we use 32 chars to # be safe against newlines and odd indenting. WINDOW_ASSIGN_RE = re.compile( - r"window\.([A-Za-z_\$][A-Za-z_\$0-9]*)\s*=\s*([^=].{0,32})", + r"window\.([A-Za-z_\$][A-Za-z_\$0-9]*)\s*=\s*([^=].{0,80})", re.DOTALL, ) @@ -74,6 +74,12 @@ def _classify_rhs(rhs: str) -> str: # Allow ||, &&, ? chains too (e.g. `window.X = window.X || false;`). if re.match(r"[A-Za-z_\$][A-Za-z_\$0-9]*[\s;,)|&?.]", rhs): return "identifier" + # Bare identifier that runs to the end of the (length-capped) capture window + # with no trailing terminator visible — e.g. a very long function name like + # `_renderLiveAnchorActivitySceneSnapshotForStream;` whose terminator falls + # outside the captured snippet. Still a benign function reference. + if re.fullmatch(r"[A-Za-z_\$][A-Za-z_\$0-9]*", rhs.rstrip()): + return "identifier" return "other"