Skip to content

Fortran: detector.py's start_line is wrong for some subroutines, ~370 lines off in module_initialize_real.F #1531

Closed

Description

@squid-protocol

What

Found while regenerating fortran's tree_sitter_accuracy_audit.py baseline after #1526's
per-occurrence line-based pairing (which requires function_data.start_line to be accurate to
correctly identify which occurrence of a repeated name a row corresponds to).

language-crucible/data/fortran/wrf/module_initialize_real.F has exactly one real definition of
wrf_message:

5580: subroutine wrf_message(level,message)
5581:    character(len=*), intent(in) :: message
5582:    integer, intent(in) :: level
5583:    print *,trim(message)
5584: end subroutine wrf_message

tree-sitter-fortran correctly resolves this at line 5580 with 2 real params. GitGalaxy's own
function_data row for wrf_message in this file reports start_line=5208 — not close to any
CALL wrf_message(...) site either (the nearest is a wrf_error_fatal call at line 5157, ~50
lines further off, and no wrf_message reference sits anywhere near 5208). Also measured
args=1 against the real 2. A second case in the same file, const_module_initialize, shows a
smaller but still real discrepancy (GitGalaxy start_line=4645 vs. the real SUBROUTINE const_module_initialize at line 4951, a ~306-line gap; args similarly wrong, 1 vs. the real 6).

Why this matters beyond just being "a line number"

This isn't just cosmetic: since args is also wrong in both cases, this reads like func_start's
window for these two subroutines is anchoring somewhere other than the real declaration -- the
same kind of "regex found the name but grabbed the wrong span" shape as some of the C-family
func_start/args bugs fixed under epic #813, not a mere line-count arithmetic slip. Given
WRF is heavily CPP-preprocessed and already flagged in tests/tools/tree_sitter_accuracy_audit.py
(NODE_MAPS["fortran"]'s own comment) as a corpus where tree-sitter-fortran itself falls back to
ERROR node recovery, it's plausible GitGalaxy's fortran-mode extraction has a related fragility
on this same preprocessor-heavy style, but that's a hypothesis, not confirmed -- needs real
detector.py fortran-path debugging to root-cause, not further guessing from the corpus alone.

Scope

Deliberately not chased further in #1526/#1527's PR -- that PR's scope is the audit tool's
occurrence-pairing methodology (which persists start_line and uses it, but doesn't generate it);
this is a detector.py fortran-extraction correctness question, a different kind of fix with its
own blast radius (would need the Differential Scan protocol per CLAUDE.md if it turns out to be
a real func_start bug, not just line-counting).

Activity

  1. added
    bug
    core-engine
    data-integrity
    on Aug 14, 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-enginedata-integritypriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions