Docs menu

E062: You assigned null to a variable that isn't a pointer

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

null means “no value yet,” and in Turf that concept only applies to pointer types – variables declared with a * in their type, like int*. A plain int, double, bool, string, char, or ordinary struct always holds a real value; there’s no such thing as an “empty” one of those, so null doesn’t make sense for them.

This is fine, because ptr is a pointer type:

Example
mut ptr: int* = null;

This isn’t, because n is a plain int, not a pointer:

Example
mut n: int = null;

Turf tells you the variable’s actual declared type, so you can see right away why null doesn’t fit there.

If you really wanted a placeholder value you can check for later, you’ll need to declare the variable as a pointer type (int* instead of int). If you just wanted a normal starting value, skip the = null entirely – declaring a variable without an initializer already gives it a sensible default (zero for numbers, false for bools, and so on), which is almost always what you actually want here.

Run turf --explain E062 in a terminal to read this again.

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

Esc

Type to search.