Credence.Syntax.NoUnclosedFnDelimiter (credence v0.8.0)

Copy Markdown

Repairs an fn clause that is closed with ) instead of end.

LLMs repeatedly write fn args -> body) — letting the enclosing call's ) stand in for the fn's end:

list |> Enum.max_by(fn {_, second} -> second)

Elixir reports a MismatchedDelimiterError (fn opened, ) found where end was expected). It never parses, so this is a REPAIR: insert the missing end immediately before the offending ).

Detection is driven by the parser itself — Code.string_to_quoted/2 pinpoints the exact {line, column} of the mismatched ) and reports the opened/expected delimiters — so the rule fires only on a genuine fn … ) mismatch and never on a line that merely happens to contain fn, ->, and a trailing ).

Bad (won't parse — MismatchedDelimiterError)

list |> Enum.max_by(fn {_, second} -> second)

Good

list |> Enum.max_by(fn {_, second} -> second end)