Skip to content

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

Closed

Description

@squid-protocol

Summary

A where-introduced local binding whose first clause is written entirely on one line — where name args = expr — is never matched by func_start. This is the exact same shape #1564 already fixed for let, just not yet extended to where.

Root Cause

func_start's equation-anchored alternative (gitgalaxy/standards/language_standards.py, haskell) is:

^[ \t]+(?:let[ \t]+)?(?!(?:case|class|data|default|deriving|do|else|foreign|if|import|in|infix|infixl|infixr|instance|let|mdo|module|newtype|of|then|type|where)\b)([a-z_][a-zA-Z0-9_']*)(?=[ \t]+[^\s=][^\n=]*(?<![!<>/])=(?![=>]))

The (?:let[ \t]+)? optional skip added by #1564 lets a same-line let name args = expr anchor past the let token. where gets no equivalent skip — when a line reads where name args = expr (the binding's first/only clause written on the same physical line as the where keyword itself, rather than where alone with the binding starting on the next line), the negative lookahead's keyword exclusion sees where immediately after ^[ \t]+ and rejects the whole line, with no way to retry past it the way let now can.

Verification

Tested the regex directly:

from gitgalaxy.standards.language_standards import LANGUAGE_DEFINITIONS
fs = LANGUAGE_DEFINITIONS['haskell']['rules']['func_start']
snippet = """
renderTags' :: [Tag T.Text] -> T.Text
renderTags' = renderTagsOptions
               renderOptions{ optMinimize = matchTags ["hr"] }
              where matchTags tags = flip elem tags . T.toLower
"""
list(fs.finditer(snippet))  # -> only matches renderTags', never matchTags

Confirmed real-world misses in the pinned language-crucible/data/haskell/pandoc corpus (found via the clause-collapsed recall check in #1614 — these are genuine misses, not clause-counting artifacts):

  • matchTags (Shared.hs:734) — where matchTags tags = flip elem tags . T.toLower
  • rejectBadYear (Shared.hs:283) — where rejectBadYear day = case toGregorian day of
  • go (Shared.hs:261, inside tabFilter) — where go s = (technically spans onto the next line for the body, but the where go s = opener is the same single-line-where shape; go's other 6 occurrences elsewhere in the same file, which use where go :: ... on its own line, are all found correctly)

Proposed Fix

Extend the existing (?:let[ \t]+)? optional skip to also accept where, e.g. (?:(?:let|where)[ \t]+)?, mirroring #1564's fix exactly.

Important: 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

Activity

  1. added
    bug
    testing
    core-engine
    threat: false-negative
    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-enginepriority: mediumtestingthreat: false-negative

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions