parse_error: a construct is written in a shape the grammar does not accept
The parser recognised a specific mistake: one of the grammar’s error
productions fired and chose both the position and the message. The caret
is on the token the message is about; the note under it usually shows the
correct shape. (Contrast syntax_error, where the parser could not say what
went wrong.)
A program that triggers it
mod Main
needs IO.Console
fn main(_console : Cap(IO.Console)) do
println("hello")
end
end
The fix
Rewrite the construct in the shape the note shows. Here: a module header
is mod Name do, and the do was missing.
mod Main do
needs IO.Console
fn main(_console : Cap(IO.Console)) do
println("hello")
end
end
Why the rule exists
March borrows ML and Elixir syntax, so a few constructs from those
languages are common slips. The grammar has explicit productions for the
known ones so the message names the fix instead of reporting a generic
parse failure, and the most common slips have a code of their own with a
mechanical fix: then_keyword (then for do), module_keyword
(module for mod), elif_keyword (elif for else if … end end) and
semicolon_separator (; between expressions).
See also: the language reference.