Docs menu

E003: The number of values you gave doesn't match the array's declared size

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

When you declare an array with a size, like int[3], and give it a list of starting values, the number of values in that list has to match the size exactly – not more, not fewer.

Example
immut primes: int[3] = [2, 3, 5];   // correct -- 3 values for size 3

If you give too many or too few:

Example
immut primes: int[3] = [2, 3, 5, 7];   // 4 values, but size is 3

Turf won’t quietly drop the extra value or leave a slot empty – it stops and tells you exactly how many values it expected versus how many you gave, so nothing about your array’s contents is left ambiguous.

To fix it, just make the two numbers agree. Either change the size to match your list:

Example
immut primes: int[4] = [2, 3, 5, 7];

…or trim the list to match the size:

Example
immut primes: int[3] = [2, 3, 5];

Either way works – pick whichever one actually reflects what you meant the array to hold. This is an easy one to fix once you spot the mismatch, and Turf tells you both numbers up front so you don’t have to go count them yourself.

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

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

Esc

Type to search.