Docs menu

E051: You tried to write your own default() method, but that name is reserved

What compiler error E051 means, and how to fix it.

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:

Example
fn Point.default(): void {    self.x = 0;    self.y = 0;}// ERROR: 'default' is reserved and can't be declared by hand

The 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:

Example
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:

Example
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.

Last updated: Oct 15, 2026Edit this page on GitHub

Esc

Type to search.