Skip to content

tree_sitter_accuracy_audit: solidity's _get_param_count never finds parameters (function_definition has no 'parameters' field) #1503

Closed

Description

@squid-protocol

Summary

args_exact_match for solidity measures 22/95 (23.2%) in docs/self_scan/tree_sitter_accuracy_history.csv, the worst real (non-metric-mismatch) args score in the whole table. Every single mismatch sampled is real=0 got=N where N is GitGalaxy's (correct) actual parameter count -- i.e. the tool's tree-sitter ground truth is under-measuring, not GitGalaxy's regex over-measuring.

Root cause

tests/tools/tree_sitter_accuracy_audit.py::_get_param_count starts by looking for a parameters field:

params_node = node.child_by_field_name("parameters")

tree-sitter-solidity's function_definition/modifier_definition/constructor_definition nodes have no field of that name at all -- individual parameter nodes are bare, unwrapped children of the function node directly, with no wrapping list node and no field name. Confirmed via a live parse of:

function hasRole(bytes32 role, address account) public view returns (bool) {

Dumping hasRole's function_definition children shows parameter/,/parameter as direct children (no field), sitting alongside visibility/state_mutability/return_type_definition siblings. Since child_by_field_name("parameters") returns None, _get_param_count falls through every existing branch (C-style declarator unwrap, matlab's function_arguments scan, etc. -- none apply to solidity) and ultimately returns 0 for every solidity function/modifier/constructor regardless of real arity.

Note return_type_definition's own nested parameter node(s) (the return type list) must NOT be counted -- they're grandchildren, not direct children of the function node, so a direct-children scan naturally excludes them.

Reproduce: LANGUAGE_CRUCIBLE_PATH=/home/joe/nyx_projects/language-crucible python tests/tools/tree_sitter_accuracy_audit.py --lang solidity (no --ci) and read the "Sample args-count mismatches" section.

Suggested fix

Same shape as the existing matlab branch in _get_param_count (the function_arguments-with-no-field-name direct-child scan) and precedent set by issue #1339 (11-language node-type whitelist gaps in this same function): add a solidity-specific branch, gated on node.type in ("function_definition", "modifier_definition", "constructor_definition") and ts_lang == "solidity" context (or simply: when no parameters field is found AND no C-style declarator applies, fall back to scanning node.children directly for child.type == "parameter", mirroring the matlab function_arguments fallback already in the function). Verify against a constructor with zero params and a receive()/fallback() (no params, sometimes no explicit param list at all) to make sure the zero-arg case still returns 0 cleanly.

Out of scope

The "Sample extra" constructor/receive/fallback false-positive-extra findings shown in the same audit run (GitGalaxy reports these as functions with no tree-sitter counterpart) are a separate class_node_types/naming-convention concern, not part of this args-counting fix -- do not touch that in this PR.

This only affects tests/tools/tree_sitter_accuracy_audit.py's own measurement accuracy (epic #1227/#1261), not GitGalaxy's actual args structural signature or risk scoring in any way.

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    on Aug 13, 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-enginepriority: mediumtestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions