Repository navigation
Closed
Labels
bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginepriority: mediumtestingUnit, integration, and E2E pipeline verification
Description
Bug: Angle Brackets as Math Operators Corrupt Depth Parsing
Description
In gitgalaxy/core/detector.py, the _count_top_level_args method blindly treats angle brackets < and > as scope delimiters to support generics (e.g., List<String>). However, these characters double as math operators (less-than, greater-than, left-shift).
elif ch in "([{<":
depth += 1
elif ch in ")]}>":
if ch == ">" and i > 0 and body[i - 1] in "=-":
pass
elif depth > 0:
depth -= 1Impact
When < or > is used as a math or comparison operator inside a default argument value, it corrupts the depth counter for the remainder of the parameter block:
- Less-than operator (
a = x < y): The<increments the depth counter permanently since there is no matching>. This causes all subsequent top-level commas to be ignored as if they were inside a generic bracket, resulting in severe undercounting. - Greater-than operator (
a = (x > y, z)): The>prematurely decrements the depth counter. If it decrements the depth to 0, nested commas (like the one separatingx > yandz) are exposed and erroneously counted as top-level argument separators, resulting in overcounting.
Steps to Reproduce
- Test with:
def foo(a = (x < y), b = 2)-> Returns 1 argument (undercounted). - Test with:
def foo(a = (x > y, z), b = 2)-> Returns 3 arguments (overcounted).
Suggested Fix
Consider detecting whether < or > is part of a balanced generic block or surrounded by spaces/math structures to distinguish them from standard operators, or restrict their generic-bracket behavior solely to statically-typed languages.
Metadata
Metadata
Assignees
Labels
bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginepriority: mediumtestingUnit, integration, and E2E pipeline verification
Activity
Correct overclaim in c.md, cross-reference pre-existing args issues, …
Fix 4 C/C++ arg-count extraction bugs in detector.py (#1884)
squid-protocol commentedon Aug 28, 2026
Fixed in #1884 (merged). Angle-bracket depth tracking in
_count_top_level_argsis now gated to_ANGLE_BRACKET_GENERIC_LANGUAGES(cpp/rust/csharp/java/kotlin/scala/typescript/swift/go/dart), so</>used as comparison/shift operators in a default value no longer corrupt the depth counter. Verified:def foo(a = (x < y), b = 2)anddef foo(a = (x > y, z), b = 2)both return 2 now. Regression testtest_count_top_level_args_angle_brackets_as_math_operators_1853passes on current main.Note: the harder residual case —
</>ambiguity inside a generic-using language's own default-value expressions — remains, as #1884 called out; that needs a type-aware parser. Opening a narrow follow-up only if it shows up in real corpus data.