Every struct in Turf automatically gets a default() constructor for free – one that zeroes out every field – and it’s generated by the compiler itself. Because of that, default isn’t a name you’re allowed to declare a method under yourself; it’s reserved specifically for the automatic one.
So writing something like this triggers the error:
fn Point.default(): void { self.x = 0; self.y = 0;}// ERROR: 'default' is reserved and can't be declared by handThe good news is you don’t need to write this at all – Point::default() already works with zero code, doing exactly what you were trying to write by hand:
mut p: Point = Point::default();If what you actually wanted was custom construction logic – something more specific than “zero everything out” – that’s exactly what .new is for instead. new is never reserved; you’re expected to write it yourself:
fn Point.new(x: int, y: int): void { self.x = x; self.y = y;}So the fix is either: delete your .default entirely and just use the automatic one, or rename it to .new (and give it parameters) if you needed real custom logic.
Run turf --explain E051 in a terminal to read this again.