LYR-SEM0094
a parenthesized attribute value with no one field to fill
An attribute is written @Name(value), but its struct does not have exactly one field without a default, or the use also names fields.
Explanation
The parenthesized form fills the one field of the attribute that has no default. With none or several such fields it is unclear which one the value fills, and mixing it with named fields would say the same thing two ways.
Write the fields by name (@Pair { a = 1, b = 2 }), or give every field but one a default.
Wrong
import std.core { OnFunction };
struct Pair :: [OnFunction] {
a: int,
b: int,
}
@Pair(1)
fn f(): void {
}
fn main(): void {
f();
}
Right
import std.core { OnFunction };
struct Pair :: [OnFunction] {
a: int,
b: int = 0,
}
@Pair(1)
fn f(): void {
}
fn main(): void {
f();
}