Credence.Syntax.FixDoBlockFusion
(credence v0.8.0)
Copy Markdown
Fixes LLM confusions between the do ... end block form and the , do:
one-liner form of definitions.
Diffusion code models (Dream, DiffuCoder) emit these fusions constantly - they are the single most common reason a draft fails to parse.
Detected patterns
def f(x), do - comma followed by a block opener at end of line
def f(x), do expr - one-liner missing the colon (midline)
def f(x) do do - doubled block opener
def f(x) do: expr - block opener fused with one-liner syntax
def f(x), do: expr end - one-liner with a stray trailing `end`Bad
def push(stack, value), do
[value | stack]
end
def double(number) do: number * 2 endGood
def push(stack, value) do
[value | stack]
end
def double(number), do: number * 2