Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(swift): a subscript read is not a call (#3618)
Swati Ahuja075b7508b12b
diff --git a/packages/core/src/repowise/core/ingestion/queries/swift.scm b/packages/core/src/repowise/core/ingestion/queries/swift.scmindex b86e1b240..e1794f989 100644--- a/packages/core/src/repowise/core/ingestion/queries/swift.scm+++ b/packages/core/src/repowise/core/ingestion/queries/swift.scm@@ -72,10 +72,12 @@; ---------------------------------------------------------------------------; Simple call: foo(args)+; The "(" child is load-bearing: a subscript read ``items[0]`` parses as a+; call_expression too, with "[" in its value_arguments, and is not a call.(call_expression(simple_identifier) @call.target(call_suffix- (value_arguments) @call.arguments+ (value_arguments "(") @call.arguments)) @call.site@@ -97,6 +99,6 @@))(call_suffix- (value_arguments) @call.arguments+ (value_arguments "(") @call.arguments)) @call.sitediff --git a/tests/unit/ingestion/parser/test_swift.py b/tests/unit/ingestion/parser/test_swift.pyindex cb7e30251..4a0c29e74 100644--- a/tests/unit/ingestion/parser/test_swift.py+++ b/tests/unit/ingestion/parser/test_swift.py@@ -75,3 +75,10 @@ class TestSwiftParser:fi = _make_file_info("swift_pkg/Calculator.swift", "swift")result = parser.parse_file(fi, SWIFT_SOURCE)assert result.parse_errors == []++ def test_subscript_read_is_not_a_call(self, parser: ASTParser) -> None:+ # `items[0]` parses as a call_expression whose arguments open with "[".+ src = b"func use() {\n let a = items[0]\n let b = self.rows[1]\n f(1)\n g.h(2)\n}\n"+ fi = _make_file_info("swift_pkg/Use.swift", "swift")+ result = parser.parse_file(fi, src)+ assert {c.target_name for c in result.calls} == {"f", "h"}