Docs menu

E058: Your compare block isn't structured quite right

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

A compare block in Turf looks a bit like a switch statement: you give it a value, then list matches <value>: arms to handle each case, each one closed off with done. Turf found something wrong with the shape of this particular compare block – not with the values or types involved, just with how the arms themselves are written.

A correctly structured compare looks like this:

Example
compare x {    matches 1:        result = 1;    done    matches 3:        result = 3;    done    otherwise:        result = 0;    done}

This error usually comes from one of three mistakes. First, forgetting to close an arm with done before starting the next one:

Example
compare x {    matches 1:        result = 1;    matches 2:        result = 2;    done}

Here, the first matches 1: arm never got its own done before matches 2: started, so Turf can’t tell where one arm ends and the next begins.

Second and third: using more than one otherwise: arm, or putting otherwise: somewhere other than last. otherwise is your catch-all for “none of the above matched,” so it only makes sense as the final arm – Turf won’t let you have two of them, or one in the middle with more arms after it.

The fix is almost always to slow down and check that every matches arm has its own done, and that if you’re using otherwise at all, there’s exactly one, at the very end. Once the shape is right, the error goes away and the block behaves exactly as you’d expect.

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

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

Esc

Type to search.