docs

You are reading the docs for v0.1.0. Nabi 0.1.0 is no longer supported. Latest release: v0.1.3 →

#E0017: item in the wrong place

An item or statement appears where it is not allowed: a static in an impl, a static mut outside an extern block, a statement in a module body, or a macro import inside a function. Move it where the message says, usually to module level.

nabi
mod inner {
    println("hi");
}
error[E0017]: expected an item in `mod inner`: module bodies are definitions-only; statements belong in `main.nabi`
  --> main.nabi:2:5
   |
 2 |     println("hi");
   |     ^^^^^^^

Module bodies hold definitions; put the statement in a function:

nabi
mod inner {
    pub fn hi() { println("hi"); }
}
inner::hi();
hi

Related: E0018 return with a value in top-level statements, E0036 invalid program entry point

Found a mistake? Edit this page on GitHub. Last updated