LYR-SEM0065
an attribute that cannot stand here
An @Name names something that is not a struct, names a generic struct, or names a struct whose markers do not admit the declaration it sits on.
Explanation
An attribute is a non-generic struct that declares a marker of std.core saying where it may stand: OnFunction, OnField, OnType, or a wider one such as OnDecl or OnAny. The marker keeps metadata from landing on declarations nobody reads it from.
Declare the struct with the marker for this site, or move the attribute to a declaration its marker admits.
Wrong
import std.core { OnField };
struct Width :: [OnField] {
value: int,
}
@Width { value = 3 }
fn f(): void {
}
fn main(): void {
f();
}
Right
import std.core { OnFunction };
struct Width :: [OnFunction] {
value: int,
}
@Width { value = 3 }
fn f(): void {
}
fn main(): void {
f();
}