Skip to content

Haskell: detector.py's start_line looks shifted by roughly one prior function when short definitions are stacked #1532

Closed

Description

@squid-protocol

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

  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