Repository navigation
Description
What
Found while regenerating haskell's tree_sitter_accuracy_audit.py baseline after #1526's
per-occurrence line-based pairing. Also relevant: haskell's real_functions ground truth jumped
94 -> 247 (2.6x, the largest jump of any language) once same-named occurrences stopped collapsing
onto one dict slot, because tree-sitter-haskell gives each pattern-matching equation of a function
its own function node (e.g. f 0 = ... / f n = ... are two separate nodes for one logical
function) -- expected and already covered by _get_param_count's existing haskell-specific
patterns field handling (see that function's own inline comment). That part isn't the concern
here.
The concern: multiple args-mismatch samples on this corpus show a suspiciously consistent
~10-13 line offset between the real (tree-sitter) line and GitGalaxy's own recorded start_line
for the SAME function name, not a random scatter. Concrete example --
language-crucible/data/pandoc/App.hs (well, data/haskell/pandoc/App.hs):
405: else readerOpts{ readerExtensions = pandocExtensions }
...
410: htmlFormat :: Text -> Bool
411: htmlFormat = (`elem` [...])
413: isTextFormat :: Text -> Bool
414: isTextFormat s = s `notElem` [...]
416: adjustMetadata :: (Meta -> Meta) -> Pandoc -> Pandoc
417: adjustMetadata f (Pandoc meta bs) = Pandoc (f meta) bs
420: writeFnBinary :: FilePath -> BL.ByteString -> IO ()
421: writeFnBinary "-" = BL.putStr
422: writeFnBinary f = BL.writeFile (UTF8.encodePath f)tree-sitter correctly resolves writeFnBinary's real definition at line 421/422. GitGalaxy's own
function_data.start_line for writeFnBinary in this file is 410 -- not writeFnBinary's own
line at all, but htmlFormat's type-signature line, ten lines earlier and three function
definitions back. Several other samples in the same file (getMetadataFromFiles, writerFn,
inlineListToIdentifier, tabFilter, splitTextByIndices, blocksToInlinesWithSep,
textToIdentifier, unEmoji, formatCode) show the same ~10-13-line, roughly-one-prior-function
shaped offset, not a one-off.
Hypothesis (unconfirmed)
Reads like GitGalaxy's haskell-mode function extraction is attributing a function's start_line
to the wrong definition when several short name :: Type / name args = body pairs are stacked
back-to-back with no blank-line separation issue -- possibly an off-by-one in how the extractor
walks from one haskell equation to the next in this mode. Not confirmed against detector.py
source directly; needs real debugging of the haskell extraction path, not further guessing from
corpus symptoms alone.
Scope
Deliberately not chased further in #1526/#1527's PR -- same reasoning as the sibling fortran issue
(#1531): that PR's scope is the audit tool's occurrence-pairing methodology, which surfaced this by
persisting/using start_line, not generating it. This is a detector.py haskell-extraction
correctness question with its own blast radius if it turns out to be a real bug (Differential Scan
protocol territory per CLAUDE.md, not just a test-tool fix).
Activity
fix(tests): pair same-named function occurrences by line instead of c…
fix(haskell): correct line-shift, let-binding blindness, and prime-na…