Skip to content

fix(haskell): args regex misses signature-less equations and truncates qualified/dotted type signatures - #1513

Merged
squid-protocol merged 1 commit into
mainfrom
fix/haskell-1511-args-signature-truncation
Aug 13, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/haskell-1511-args-signature-truncation

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Found while verifying #1503-#1506's ground-truth args-counting fixes (PR #1507, merged): haskell's own args engine regex (not the accuracy-measurement tool) had two distinct real bugs.

  1. Signature-less equations measured 0. Typeclass instance methods and where/let-local helpers routinely have no restated :: signature (same shape haskell func_start: hardcoded '< 2 lines' floor in _slice_by_indentation drops every abstract typeclass method signature #1435/haskell func_start: typeclass instance methods and where-clause locals without an explicit '::' signature are structurally invisible #1442 taught func_start to recognize), e.g. isPandocCiteproc (JSONFilter f) = .... Added a new capture-group alternative for the equation's own LHS pattern list, anchored to the block's absolute start. Routed through a new _count_haskell_pattern_list in detector.py -- depth-and-string-aware, since a naive whitespace split would wrongly split a single parenthesized compound pattern like (MetaList xs) into two tokens. Explicitly excludes Haskell reserved keywords (let, where, data, ...) from being mistaken for a function name -- let x = 1 must never match.

  2. Qualified/dotted type names truncated the :: capture (bigger real-world impact). The signature capture's character classes never included . -- real-world Haskell overwhelmingly writes qualified type names with a dot (T.Text, IO.Newline). Confirmed: inquotes :: T.Text -> T.Text captured only T (one letter, zero arrows) from a real 1-arrow signature -- every arrow after the first dotted type silently vanished. Added . to both character classes.

args_exact_match: 31/81 (pre-#1503) → 43/81 (ground-truth fix alone) → 70/81 (86.4%) with both fixes here.

Remaining known gap (documented, not fixed)

Arrow-count vs. actual-binding-arity diverges for point-free/partially-applied equations, e.g. writerFn :: IO.Newline -> FilePath -> Text -> IO () has 3 arrows, but its equations (writerFn eol "-" = UTF8.putStrWith eol) only bind 2 patterns, since the body itself evaluates to a partially-applied function value. Tree-sitter's ground truth (equation pattern count) is arguably more semantically correct here; fixing GitGalaxy's side would need real type inference, not a regex change. Left as-is.

tcl has its own separate, unrelated args-overcounting bug (default-value braced parameters like proc foo {{db db}}) found during the same verification pass -- filed as #1512, not fixed here (out of scope for a haskell-only PR).

Verification

tests/extraction/languages/test_haskell.py, test_haskell_strict.py -- 170/170 passed
  (2 pre-existing negative-case tests updated: "foo x =" and "let x = 1" boundaries
  changed by design -- see inline comments explaining why)
  (new ReDoS regression pins added for the new alternative's token-repetition shape)
python -m pytest tests/ -- 6897 passed, 2 skipped, 11 xfailed, 3 xpassed (full suite, clean)
tree_sitter_accuracy_audit --lang haskell --regenerate  -- baseline blessed
tree_sitter_accuracy_audit --all --ci  -- 31 languages, no cross-language regressions
tests/tools/crucible_check.py --mode both  -- PASS/PASS (golden masters re-blessed;
  drift is real+expected: haskell's own Function Analysis numbers changed, plus the
  usual small global PageRank/spatial-coordinate ripple across the whole corpus)
tests/tools/audit_check.py --ci  -- ruff/mypy/dead-key/ast-accuracy all clean

Fixes #1511.

🤖 Generated with Claude Code

…s qualified/dotted type signatures

Two distinct bugs in the haskell "args" engine regex, found while
verifying #1503-#1506's ground-truth fixes:

1. Typeclass instance methods and where/let-local helpers routinely
   have no restated `::` signature (same shape #1435/#1442 taught
   func_start to recognize) -- args_count fell back to 0 regardless
   of true arity. Added a new capture-group alternative for the
   equation's own LHS pattern list (`name pat1 pat2 = ...`), routed
   through a new detector.py _count_haskell_pattern_list (depth-aware,
   so a parenthesized compound pattern like `(MetaList xs)` counts as
   one argument, not two via naive whitespace-split). Explicitly
   excludes Haskell reserved keywords so `let x = 1` is never mistaken
   for a function equation.

2. The `::` signature capture's character classes never included "."
   -- real-world qualified/imported type names (`T.Text`, `IO.Newline`)
   truncated the whole captured signature at the first dot, silently
   dropping every arrow after it (confirmed: `inquotes :: T.Text ->
   T.Text` captured only "T", zero arrows from a real 1-arrow
   signature). This affected the majority of real corpus mismatches.

args_exact_match: 31/81 -> 43/81 (ground-truth fix alone, #1507) ->
70/81 (86.4%) with both fixes here.

Remaining known gap (documented, not fixed): arrow-count vs.
actual-binding-arity diverges for point-free/partially-applied
equations (e.g. `writerFn`'s signature has 3 arrows but its equations
only bind 2 patterns, since the body itself returns a function value)
-- not fixable without real type inference. tcl's own separate
default-value-parameter overcount bug filed as #1512, not fixed here.

Fixes #1511.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squid-protocol
squid-protocol merged commit 0ffa90a into main Aug 13, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the fix/haskell-1511-args-signature-truncation branch August 13, 2026 23:57
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

haskell args regex: signature-less equations measure 0, and qualified/dotted types truncate the :: signature capture

1 participant