Expected a declaration
Fix unexpected tokens at Prismio top level and understand parser recovery.
Last verified
Meaning
The parser found a token that cannot begin a top-level import, binding, function, external function, struct, or enum declaration.
Top-level expressions and calls are not initialization scripts. Executable statements belong inside a function such as main.
Why it happens
Common causes are a stray literal/operator, unsupported semicolon, missing brace that ended a declaration early, proposed syntax for a Coming Soon feature, or a call placed directly in the file.
Invalid code
9
fn main() -> Int { return 0 }Correct code
let value = 9
fn main() -> Int { return value }Common fixes
Put executable expressions inside a function, complete the preceding declaration, or remove stray punctuation. The parser synchronizes at later declaration starters and may report more than one top-level error.
Fix the earliest structural error first. trait, impl, and throw are reserved tokens but do not begin supported 0.1 declarations/statements.