Docs menu

E123: An array's size has to be a positive whole number

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

An array is declared with a fixed size written in square brackets, and that size is a count of slots, so it must be a whole number greater than zero:

Example
mut numbers: int[5];             // five slots

These are rejected:

Example
mut empty: int[0];               // an array with no slots can hold nothingmut negative: int[-3];           // you can't have -3 slotsmut half: int[2.5];              // slots come in whole numbers

The size can also come from a literal: mut nums: int[] = [1, 2, 3]; is exactly int[3]. An empty literal has no size to give, so it is the same mistake:

Example
mut a: int[] = [];               // 'a' has no size -- an array needs at least one element

Give it at least one element, or write the size yourself (mut a: int[5];).

If you don’t know how many items you will need in advance, an array is the wrong tool: List<T> (from import list;) grows as you add to it.

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

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

Esc

Type to search.