E0008: metadata not allowed on this declaration

View source

Every attribute has places where it is valid.

Every attribute has places where it is valid. repr, volatile and zero_on_drop belong on a struct, and repr also on an enum, as ADR-0097 and ADR-0102 describe. meta test and the other verb attributes belong on a verb. The parser reports this error when the declaration after the meta lines cannot take the attribute. The error points at the meta line of the attribute that the declaration cannot take.

Example

actus
meta repr(C)
verb main() {
}
actus
meta zero_on_drop
enum Mode {
    Idle,
    Busy,
}

verb main() {
}

Fix

Put the attribute on a declaration that accepts it, or remove it. A memory layout belongs to a type, not to a verb. zero_on_drop needs a repr(C) struct.

actus
meta repr(C)
struct Point {
    x: Int,
    y: Int,
}

verb main() {
}
actus
meta zero_on_drop
meta repr(C)
struct Key {
    byte: u8,
}

verb main() {
}

Run actus explain E0008 in your terminal to read this entry offline. Browse Lexer & parser or all error codes.