Skip to content

haskell func_start: single-line let name args = expr local bindings are structurally invisible #1564

Closed

Description

@squid-protocol

Summary

Haskell's let name args = expr local bindings declared inline in do blocks are not captured by the current func_start regex, causing systematic under-detection of a common Haskell idiom.

Root Cause

The func_start regex in gitgalaxy/standards/language_standards.py for Haskell has a local-binding alternative (second |-separated branch) that matches indented name args = expr lines, but excludes lines via a negative lookahead for keywords including let: (?!(?:case|class|data|default|deriving|do|else|foreign|if|import|in|infix|infixl|infixr|instance|let|mdo|module|newtype|of|then|type|where)\b).

This lookahead is anchored right after the indentation, so it's meant to stop let itself from being mistaken for a function name — but it has the unintended side effect of blocking the entire line whenever it starts with let , meaning a real local binding declared inline as let name args = expr is never matched at all. The regex never retries past the let token to find the real name that follows.

Verification

Tested the regex directly in a REPL against this snippet, which returns zero matches:

convertWithOpts scriptingEngine opts = do
  let outputFile = fromMaybe "-" (optOutputFile opts)
  let defFlavor fmt = Format.FlavoredFormat fmt mempty
  let isWarning msg = messageVerbosity msg == WARNING

Confirmed real-world instances missed in the pinned language-crucible/data/haskell/pandoc corpus (all genuine let name args = expr one-liners):

  • defFlavor (App.hs:152)
  • makeSandboxed (App.hs:165)
  • isWarning (App.hs:114)
  • isPandocCiteproc (Filter.hs — pattern-matched two-clause form at similar shape)
  • filterWithPath (Filter.hs:52) — let filterWithPath constr = maybe missingPath (return . constr . T.unpack)

Scope Note

This is distinct from #1435 (typeclass method signature floor) and #1442 (typeclass instance methods / where-clause locals without ::). This issue is specifically the let-inside-do-block one-liner shape.

Important: Fixing this is a detector.py/language_standards.py regex change and needs the Differential Scan protocol (crucible_check.py) before merging per CLAUDE.md.

Related Work

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-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions