Repository navigation
fix(haskell): let func_start/args match guard-only defining equations - #1683
Merged
Merged
Conversation
A local binding whose defining equation puts its guards (| cond = expr) on separate, more-indented lines -- with no '=' anywhere on the naming/pattern line itself -- was never matched. Distinct from #1615 (same-line where): here where/let is on its own line (or absent), but the name+pattern line has no '=' at all, e.g.: isAllowedPunct c | extensionEnabled Ext_gfm_auto_identifiers exts = c == '-' || ... | otherwise = c == '_' || c == '-' || c == '.' func_start's equation-anchored alternative required an '=' on the SAME line as the captured name. Captured the naming line's leading indent as a group and extended the trailing lookahead to also accept a line with no '=' immediately followed, on the next line, by a guard ('|') at the exact same indent (backreference-enforced, not a general indent stack) -- mirrors the existing same-line '=' case without introducing unbounded cross-line backtracking. Kept the sibling args rule's equivalent alternative in sync, following the #1564/#1615 precedent. found_functions 139 -> 144 (+5, isAllowedPunct and stripBeginSpace now found), extra_functions unchanged at 2, args_exact_match 129 -> 133. Fixes #1616 Co-Authored-By: Claude Sonnet 5 <[email protected]>
squid-protocol
enabled auto-merge (squash)
August 15, 2026 20:30
…d-only-equations # Conflicts: # gitgalaxy/standards/language_standards.py # tests/extraction/languages/test_haskell.py # tests/golden_master_audit.json # tests/golden_master_zero_dep_audit.json # tests/tree_sitter_accuracy_baseline_haskell.json
… slot The #1616 guard-only fix newly exposed a pre-existing limitation in the multi-clause dedup mechanism: a single (name, end) tracking slot broke as soon as a differently-named match started nested inside the tracked span -- e.g. a `let`-bound guard-only local (`adjustNum`) inside an outer multi-clause `go`'s own `do`-block, only visible after this issue's own fix made it match at all. The inner match correctly needs its own tracking slot (so its own siblings can dedup against it), but overwriting the single slot lost the outer group's tracking entirely -- a later `go` clause, still within the outer group's real span, then failed the name check and got recorded as a spurious second "go" (confirmed on language-crucible's pandoc/Shared.hs, extra_functions 2 -> 3). Replaced the single-slot tracker with a stack of (name, end) frames. Popping frames whose span has already closed (relative to the current match's start) before each check lets a later match "return" to whichever enclosing frame is still actually open, at any nesting depth, instead of only ever comparing against the single most-recently-seen group. found_functions 139 -> 144, extra_functions unchanged at 2 (the pre-existing 2, not the newly-introduced 3rd), args_exact_match 129 -> 133 -- the intended #1616 improvement, now without the collateral regression. Fixes #1616 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1616.
A local binding whose defining equation puts its guards (
| cond = expr)on separate, more-indented lines -- with no
=anywhere on the naming/pattern line itself -- was never matched. Distinct from #1615 (same-line
where, already fixed): herewhere/letis on its own line (or absent),but the name+pattern line has no
=at all:func_start's equation-anchored alternative required an=on the SAMEline as the captured name (
(?=[ \t]+[^\s=][^\n=]*(?<![!<>/])=(?![=>])),explicitly bounded to the current line), so a guard-only naming line was
invisible.
Fix
Captured the naming line's leading indent as a group and extended the
trailing lookahead to also accept a line with no
=, immediately followedon the NEXT line by a guard (
|) at the exact same indent (backreference-enforced against the captured indent group, not a general indent stack) --
mirrors the existing same-line
=case without introducing unboundedcross-line backtracking. Kept the sibling
argsrule's equivalentalternative in sync, following the #1564/#1615 precedent.
Verification
ReDoS: probed a 50k-char single line of
|characters (no=), 50k linesof invalid same/shallower-indent guards, and a stress case of 20,000 valid
guard-only functions via
finditerover a synthetic doc -- all sub-second,no catastrophic backtracking.
crucible_check.py --mode bothblessed via--update --yes(expectedcascading drift).
audit_check.py --ciclean.Type of change
language_standards.py)Differential Scan target
Haskell parser corpus (pandoc) -- the same files the issue's measurements came from.
Co-Authored-By: Claude Sonnet 5 [email protected]