Repository navigation
Description
What
PR #1207 (merged 2026-08-10) fixed a regression in function parameter-counting (function_data.args) for Python by adding a capture group to its args regex in gitgalaxy/standards/language_standards.py. That fix applied only to Python (python/embedded_python); the underlying bug mechanism affects a further set of languages with the same structural precondition: a zero-capture-group args regex pattern that also genuinely represents a comma/space-separated parameter list.
EDIT (post-filing correction): the original version of this issue listed 34 languages, based purely on args_pattern.groups == 0. Re-reading each of those 34 regexes individually found that 9 are false positives — their args rule doesn't represent a function parameter list at all, so this bug doesn't apply to them (see "Not affected" below). The real, corrected scope is 25 languages, split into two tiers by how directly Python's fix pattern transfers.
Root cause
Each language's args regex is consumed by gitgalaxy/core/detector.py's _calculate_block_metrics function:
arg_match = args_pattern.search(block)
args_str = arg_match.group(arg_match.lastindex) if arg_match.lastindex else arg_match.group(0)When args_pattern.groups == 0 (no capture group defined), arg_match.lastindex is None, so the code falls back to the WHOLE match text — e.g., "func main()" including the keyword and function name, not just the parameter list "()". This whole-text capture then gets split on whitespace and counted as tokens, hitting a zero/one-arg signature with no comma against a fallback meant for space-separated languages (Lisp/Scheme), and miscounting "func main()".split() as ["func", "main()"] → 2 args for a function that actually takes 0.
Verified as real in Go, Rust, Java (confirmed via actual detector pipeline against zero-arg and multi-arg samples). Inferred for the remaining languages in Tier 1 based on the same structural precondition and regex shape, not yet independently verified in each language.
Tier 1 — mechanical fix (20 languages)
Same keyword name(...) shape as Python/Go/Rust/Java (a single parenthesized, comma-separated parameter list). Python's exact fix pattern should transfer directly:
c, cpp, csharp, java, javascript, typescript, kotlin, swift, dart, scala, groovy, go, rust, php, ruby, perl, lua, solidity, apex, powershell
Tier 2 — needs individual judgment (5 languages)
Real bug (the same whole-match fallback mechanism applies), but the signature shape doesn't match Python's single-paren-comma-list model, so the fix needs per-language thought rather than a blind port:
objective-c— colon-selector method syntax (doThing:(int)x withOther:(int)y); parameters aren't inside one comma-separated(...)block.scheme— genuinely space-separated inside(define (name a b) ...), not comma-separated; the existing whitespace-split fallback is closer to correct in intent but still picks up the(define/name tokens as spurious args.matlab—function [outputs] = name(inputs); there's an output list before the=in addition to the real input-parameter parens, needs care to only count the input side.haskell— matches type signatures (::) and lambdas; idiomatic Haskell functions are often curried with no parens at all (add x y = x + y), so "args count" doesn't map onto this regex the same way.fortran— parens are optional in the pattern ((?:\s*\([^)]*\))?) and the alternation also matches unrelatedINTENT/VALUE/OPTIONALkeyword usage, not just declarations.
Not affected — false positives, removed from scope (9 languages)
These were in the original 34-language list purely because groups == 0, but their args rule measures something other than a function's parameter list, so this bug doesn't apply:
| Language | What args actually matches |
Why it's a different thing |
|---|---|---|
dockerfile |
ARG instruction lines |
Dockerfiles have no functions |
makefile |
$(1), $(call ...) |
Make variable references, not a param list |
yacc |
$1, $<type>1 |
Bison semantic-value references |
m4 |
$1, $@ |
Macro-argument references |
shell |
$1, $@ usage inside a function body |
Same shape as makefile/yacc — not a signature |
agc_assembly |
Opcode/operand mnemonics | Not a signature at all |
sqlite |
?1, :name, VALUES(...), WITH...AS |
SQL placeholders/CTEs, not function params |
css |
calc(...), var(...), etc. |
Built-in value-function call sites, not user function declarations |
yaml |
GitHub Actions with: block |
Workflow step inputs, unrelated concept |
If these are worth revisiting at all, it would be as a separate, differently-scoped issue about whether args is even the right rule name/purpose for them — not this bug.
The fix pattern (Tier 1)
For each Tier 1 language, add a capture group around just the parameter-list span in that language's args regex, positioned so re.Match.lastindex resolves to it (i.e., make it the LAST/highest-numbered participating capture group in whichever alternation branch matches).
Reference: Python's fixed args rule (search language_standards.py for the python language block) — it wraps the parameter list in (\(...\)) so args_str becomes exactly "(...)" with no keyword prefix. The existing _calculate_block_metrics and _count_top_level_args logic already correctly handles this clean capture for Python; no changes to detector.py are needed for Tier 1.
What does NOT need fixing
- The other two bugs function_data.args count is wrong for ~68% of correctly-found functions -- overcounts simple signatures, zeroes out multi-line ones #1199 fixed (trailing-comma multi-line overcount, Python's bare
*//keyword-only marker overcount) live entirely in the shared_count_top_level_argsfunction indetector.py, so they're already fixed repo-wide. Go/Rust/Java now correctly report args for multi-line trailing-comma signatures. No further work needed on these. - 11 languages already believed unaffected (have existing capture groups in their
argsrule):abap,ada,assembly,cobol,html,jcl,livecode,tcl,zig, pluspython/embedded_python(already fixed by function_data.args count is wrong for ~68% of correctly-found functions -- overcounts simple signatures, zeroes out multi-line ones #1199). - 14 languages with no
argsrule at all:batch,blp,csv,glsl,hlo,json,markdown,mlir,nix,pbtxt,plaintext,proto,td,xml. - The 9 false positives above — not this bug, not tracked here.
References
- Original issue: function_data.args count is wrong for ~68% of correctly-found functions -- overcounts simple signatures, zeroes out multi-line ones #1199 — "function_data.args count is wrong for ~68% of correctly-found functions"
- Implementing PR: fix(core): correct function_data.args counting for Python (#1199) #1207 — "fix(core): correct function_data.args counting for Python (function_data.args count is wrong for ~68% of correctly-found functions -- overcounts simple signatures, zeroes out multi-line ones #1199)"
Completion checklist
Tier 1 (mechanical)
- c
- cpp
- csharp
- java
- javascript
- typescript
- kotlin
- swift
- dart
- scala
- groovy
- go
- rust
- php
- ruby
- perl
- lua
- solidity
- apex
- powershell
Tier 1 is now fully complete (PR #1212: c/cpp/go/kotlin/swift/php/perl/lua/apex/rust/solidity/scala/dart. PR #1216: csharp/java/javascript/typescript/groovy/ruby/powershell).
Tier 2 is now also fully complete (PR #1218: objective-c/scheme/matlab/haskell/fortran — each needed a bespoke counting strategy, not a mechanical port; see the PR for the per-language design). All 25 languages in scope are fixed. Closing.
Tier 2 (needs individual judgment — separate follow-up pass)
- objective-c
- scheme
- matlab
- haskell
- fortran
Activity
[-]fix(core): add args regex capture group for 34 languages (regression from #1199 Python fix)[/-][+]fix(core): args regex capture group missing in 25 languages (regression from #1199 Python fix)[/+]squid-protocol commentedon Aug 10, 2026
Re-triaged the original 34-language list before starting implementation: 9 of them (
dockerfile,makefile,yacc,m4,shell,agc_assembly,sqlite,css,yaml) turned out to be false positives — theirargsrule matches something other than a function parameter list entirely (Dockerfile ARG lines, Make/Bison/m4 variable references, SQL placeholders, CSS built-in value functions, GitHub Actions workflow inputs), so this bug doesn't apply to them. Corrected scope is 25 languages, split into a 20-language mechanical tier and a 5-language tier needing individual judgment (objective-c, scheme, matlab, haskell, fortran — real bug, but the signature shape doesn't match Python's single-paren-comma-list model). Issue body and checklist updated accordingly. Starting on the Tier 1 mechanical batch now.squid-protocol commentedon Aug 10, 2026
PR #1212 fixes the first 13 of Tier 1's 20 languages:
c, cpp, go, kotlin, swift, php, perl, lua, apex, rust, solidity, scala, dart. Checklist updated. Also added persisted regression coverage that neither this issue nor #1199 had before (a shared-helper unit test plus a per-language real-pipeline parametrized test intests/core_engine/test_detector.py) -- extending that same fixture dict is the expected pattern for the remaining languages.Remaining in Tier 1:
csharp, java, javascript, typescript, groovy, ruby, powershell-- these have multi-branchargsregexes (separate alternatives for functions/arrow-functions/methods/getters-setters/decorators) needing the same per-branch capture-group treatment cpp/kotlin/swift/rust/scala did here, so they're a distinct, more expensive follow-up pass rather than a continuation of this same PR.fix(core): add args regex capture group for 13 languages (#1209) (#1212)
squid-protocol commentedon Aug 10, 2026
PR #1216 fixes the remaining 7 Tier 1 languages:
csharp, java, javascript, typescript, groovy, ruby, powershell. Tier 1 (20/20) is now complete.Notable findings from this batch:
groovy's closure branch has entirely optional params, requiring an empty-string alternative inside the group (same fix shape as perl's bareshiftin PR fix(core): add args regex capture group for 13 languages (#1209) #1212) so a zero-param closure still has something to capture.ruby's existingtest_ruby_argstest used a different, older convention (expected = the whole matched payload, not a name) that needed updating -- documented in the PR, no coverage lost.The
ARGS_COUNT_FIXTURESregression suite (added in PR #1212) now covers 20/20 Tier 1 languages, 21 parametrized cases total.Remaining: the 5-language Tier 2 (
objective-c, scheme, matlab, haskell, fortran) -- structurally unlike Python's model, each needs individual design thought rather than the mechanical capture-group port used here.fix(core): add args regex capture group for 7 more languages (#1209) (#…
squid-protocol commentedon Aug 10, 2026
PR #1218 fixes the remaining 5 Tier 2 languages:
objective-c, scheme, matlab, haskell, fortran. All 25 languages are now fixed — closing this issue.Each Tier 2 language needed a genuinely bespoke counting strategy rather than the mechanical capture-group port used for Tier 1:
_count_colon_selector_segmentscounts repeatedlabel:(Type)namesegments instead.function [out1, out2] = name(in1, in2)-- the fix specifically targets only the trailing INPUT parens, never miscounting the output-variable list as if it were part of the signature.name :: Int -> Int -> Inthas no parens/commas at all -- new_count_haskell_type_arrowscounts curried arity from top-level arrow count, gated on a new per-group opt-in flag (_args_arrow_count_groups) since a real signature can have zero arrows and still need a correct zero count.SUBROUTINE Foo(no parens) is valid zero-arg syntax -- the args group now has an empty-string alternative so it still participates and correctly counts zero.Two additional, unplanned findings surfaced while verifying these against ReDoS scaling sweeps (now part of standard practice for any args-regex edit per this repo's own protocol):
Also documented (not fixed, out of scope): scheme/matlab and some haskell/fortran signature shapes aren't actually extracted by the real detector pipeline at all -- a separate, pre-existing recall gap (paren-/keyword-delimited languages don't fit the generic Mode B brace-slicer). New regression tests for these call
_calculate_block_metricsdirectly to isolate and pin the counting fix independent of that gap.Full summary across all four PRs: #1207 (Python, originating fix) → #1212 (13 languages) → #1216 (7 languages) → #1218 (5 languages) = 25 languages total, all verified individually against real signatures, existing extraction test suites, and (for the languages that reach it) the real pipeline.
fix(core): args counting for Tier 2 languages -- closes #1209 (Tier 1…
docs: add JavaScript language-status doc, first tree-sitter-based §9 …
fix(testing): haskell ground truth now recognizes point-free functions (
docs(language-status): add apex.md (#1966)
fix: rename calls_out_ignore to _calls_out_ignore per helper-key conv…