LYR-SEM0008
this outside a method
The keyword this appears where there is no receiver: in a free function or in a module-level initializer.
Explanation
this is the receiver of a method; only the members of a struct, class, enum, interface or extend block have one. A free function takes what it works on as a parameter.
Move the function into the type, or pass the value as a parameter.
Wrong
fn main(): void {
let _ = this;
}
Right
struct Point {
x: int,
fn getX(): int { return this.x; }
}
fn main(): void {
let _ = Point { x = 1 }.getX();
}