Lyricdev
GitHub

LYR-SEM0068

an attribute repeated on one declaration

error ยท spec 11-metaprogramming

The same attribute type sits on one declaration twice, under any spelling.

Explanation

A declaration carries at most one value of each attribute; a second one would leave open which of the two a reader takes.

Keep one, and put everything it should say into its fields.

Wrong

import std.core { OnFunction };

struct Label :: [OnFunction] {
    text: string,
}

@Label { text = "a" }
@Label { text = "b" }
fn f(): void {
}

fn main(): void {
    f();
}
import std.core { OnFunction };

struct Label :: [OnFunction] {
    text: string,
}

@Label { text = "a" }
fn f(): void {
}

fn main(): void {
    f();
}