leo/docs/error-guides/parser/member_const_after_var.md
2022-02-28 09:42:37 -08:00

681 B

static const after normal variables

Example

This error occurs when static const circuit members occur after normal member variables.

Erroneous code example:

circuit Foo {
    bar: u8,

    static const baz: bool = true;
}

The compiler will reject this code with, for example...:

Error [EPAR0370020]: Member variables must come after member consts.
    --> test.leo:4:18
     |
   4 |     static const baz: bool = true;
     |                  ^^^^^^^^^^^^^^^^

Solution

The issue can be solved by moving all static const members before normal member variables...:

circuit Foo {
    static const baz: bool = true;

    bar: u8,
}