Skip to content

C/C++ args regex under-counts real parameter lists (masked by a since-fixed ground-truth bug) #1282

Closed

Description

@squid-protocol

Summary

While fixing #1263 (C++ func_start accuracy) and its prerequisite #1265/PR
#1280 (tree-sitter accuracy audit measurement bugs), a third, unrelated
measurement bug surfaced and got fixed as part of PR #1280: the audit tool's
_get_param_count() had the same "C-family function_definition has no
top-level field" gap _get_node_name() did before #1265 — it silently
returned 0 for every C/C++ function's real parameter count regardless of
actual arity, because parameters live behind a nested function_declarator,
not directly on function_definition.

Fixing that (PR #1280's second commit) revealed that GitGalaxy's own C
args/args_exact_match measurement, which looked fine before (1491/1670 =
89% exact match in the committed baseline), was actually two independent
bugs silently cancelling out
: the old ground truth always read 0 params
(via the missing-field gap above), and it turns out GitGalaxy's own C args
regex/counting also frequently returns 0 for functions with real,
non-empty parameter lists — so the two wrong numbers agreed far more often
than either was actually correct. Measured correctly for the first time,
args_exact_match for C is 175/1670 (10%), not 89%.

Example

cpython/ceval.c::PyEval_GetFrameGlobals        real=1 got=0
cpython/ceval.c::PyEval_SetProfileAllThreads   real=2 got=0
cpython/ceval.c::_PyEval_ExceptionGroupMatch   real=5 got=0

Confirmed via tests/tools/tree_sitter_accuracy_audit.py --lang c (verbose
sample list) against the pinned language-crucible/data/c corpus.

Suspected root cause (not yet fully traced)

The cpp analog of this same class of bug (found and partially traced while
working on #1263, but not fixed there since it's the args rule, a
different extraction pillar than func_start): detector.py's
_calculate_block_metrics computes a function's own arg count by re-running
the language's separate args regex (rules["args"]) via .search(block)
against the whole function body, not just its own signature line — for a
genuinely 0-arg function like void inProcess_initialize() { ... }, if the
body itself contains an earlier call whose parenthesized argument happens to
look like a typed parameter list to the args regex's heuristic (e.g. a
single-uppercase-letter string-literal prefix like RegisterWindowMessage(L"...")
matching the regex's [A-Z]\w* "looks like a type name" branch), that
call's arg count gets attributed to the enclosing function instead of 0.
Worth verifying this same mechanism explains the bulk of the C corpus's gap
too before proposing a fix.

Action

  1. Confirm root cause against the C corpus specifically (may be the same
    .search(block)-scans-the-whole-body issue, or a distinct C-args-regex
    gap — the C and cpp args rules in language_standards.py are separate
    regexes).
  2. Follow the harden-language-extraction skill's methodology.
  3. Regenerate tests/tree_sitter_accuracy_baseline_c.json /
    tests/tree_sitter_accuracy_baseline_cpp.json and the golden-master
    fixtures (tests/tools/crucible_check.py --update) once fixed.

References

Activity

  1. added
    bug
    testing
    core-engine
    on Aug 11, 2026
  2. added this to the v2.4.8 milestone on Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginetesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions