Credence.Syntax.FixMalformedSpec (credence v0.5.0)

Copy Markdown

Fixes @spec declarations where the :: return type separator is misplaced inside the argument parentheses.

LLMs translating from Python sometimes put the entire spec — parameter types AND return type — inside one pair of parentheses, placing :: in the wrong position.

Bad (won't parse)

@spec max_product(list(integer()) :: integer())

Good

@spec max_product(list(integer())) :: integer()

Detection

Finds @spec lines where the matching ) for the opening ( is the LAST ) on the line and the :: separator sits inside those parens rather than outside. Valid specs with named parameters (name :: type) are not flagged because they always have a :: outside the argument parens as well.