Repository navigation
Description
Summary
During the tri-comparison-ledger-sweep (GitGalaxy vs. ctags vs. tree-sitter) investigating C++ parameter-counting accuracy, a systematic bias emerged in tree-sitter's parameter measurements: tree-sitter consistently undercounts by exactly 1 whenever a function parameter has a default value.
Verified pattern: Tree-sitter's parameter count is off-by-one lower in every sampled case where a function has a defaulted parameter:
| Function | Source | ctags | GitGalaxy | tree-sitter | Real param count |
|---|---|---|---|---|---|
save_scene_to_path |
godot/editor_node.h | 2 | 2 | 1 | 2 ✓ |
step |
godot/editor_node.h:1055 | 1 | 1 | 0 | 1 (default: int p_step = -1) ✓ |
get_index |
godot/node.h:590 | 1 | 1 | 0 | 1 (default: bool p_include_internal = true) ✓ |
atr_n |
godot/node.h | 4 | 4 | 3 | 4 (has defaulted param) ✓ |
atr |
godot/node.h | 2 | 2 | 1 | 2 (has defaulted param) ✓ |
ObjectSignalLock |
godot/object.cpp | 2 | 2 | 1 | 2 (has defaulted param) ✓ |
In every case, ctags and GitGalaxy agree on the correct count (verified by reading source), and tree-sitter is exactly 1 lower.
Corpus: language-crucible/data/cpp/ (6+ confirmed examples as of 2026-08-21).
Impact
- Parameter counting is a core verification signal in
tests/tools/tree_sitter_accuracy_audit.pyandtests/tools/tri_comparison_gatherer.py, used to generate the tri-comparison ledger. - This systematic undercount biases all cpp/function/args comparisons where defaults are present, making tree-sitter appear systematically worse than it actually is (a measurement artifact, not a real accuracy difference).
- Any follow-up work relying on tree-sitter's cpp parameter counts as ground truth will inherit this bias.
Suggested fix
The issue is in tests/tools/tree_sitter_accuracy_audit.py's _get_param_count() function, which handles per-language parameter enumeration. The cpp-specific logic enumerates parameter node types but appears to miss the node type wrapping a parameter with a default value.
- Locate the cpp-specific parameter-list walking logic in
_get_param_count(). - Parse a simple test case (
void f(int x = 0)) directly with tree-sitter-cpp to inspect the actual node type/shape for defaulted parameters (likely something likeoptional_parameter_declarationor similar in tree-sitter-cpp's grammar). - Update the cpp parameter-enumeration logic to include the missing node type.
- Verify the fix against the 6 known failing cases in the corpus.
- Check whether the same pattern affects other languages with default parameters (e.g., C, Java, Rust) — this issue was found investigating cpp but the root cause is likely language-agnostic.
Note: This is specifically a bug in the VERIFICATION TOOLING, not GitGalaxy production code — ctags and GitGalaxy both already count these correctly.
Cross-reference
- Found in the same tri-comparison sweep as cpp func_start misses constructors with long member-initializer-lists #2009, cpp func_start misses conversion operators with template/generic return types #2010, cpp class_start counts forward declarations as real class/struct definitions #2011, cpp args: Zero-undercount for operator() and method definitions, off-by-one overcount for constructors with initializer-lists #2012 (all cpp-related, filed 2026-08-21).
- Related: tree_sitter_accuracy_audit: _get_param_count node-type whitelist missing real per-language parameter node types (11 languages) #1339 (11-language args-identification ground-truth audit that found multiple
_get_param_countgaps across languages), Build generalized tests/tools/tree_sitter_accuracy_audit.py + per-language node-map registry #1228 (tree_sitter_accuracy_audit.py build/generalization).
Activity
Validate cpp tri-comparison ledger; fix ctags/tree-sitter comparison-…
fix(testing): include optional_parameter_declaration for cpp paramete…