Docs menu

E064: You returned a value that doesn't match the function's declared return type

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

When you write fn square(n: int): int { ... }, that : int at the end is a promise – every return inside the function has to hand back a real int. Turf checks that promise at compile time.

This keeps the promise:

Example
fn square(n: int): int {    return n * n;}

This breaks it:

Example
fn square(n: int): int {    return "nine";}

Turf tells you both halves of the mismatch – what the function is declared to return, and what you actually tried to return – so you can see immediately which side needs to change.

There are two honest ways to fix this: change what you’re returning so it’s really the declared type (maybe you meant n or n * n, not a string), or change the function’s own : Type if the value you’re returning was correct all along and the declaration is what’s actually wrong. Either is a completely normal thing to need while you’re still shaping out a function – it just means the signature and the body haven’t quite agreed with each other yet.

A bare return; is the same mistake: in a function that promises an int, it hands back nothing. Write the value (return 0;), or declare the function as void if it really returns nothing.

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

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

Esc

Type to search.