leo/docs/error-guides/parser/unable_to_parse_array_dimensions.md
2022-02-28 09:42:37 -08:00

623 B

Unable to parse array dimensions

Example

This error occurs when there is a syntax error in the array dimensions of an array initializer.

Erroneous code example:

function main() {
    let x = [1; +];
}

The compiler will reject this code with, for example...:

Error [EPAR0370018]: unable to parse array dimensions
    --> test.leo:2:13
     |
   2 |     let x = [1; +];
     |             ^

Solution

In the case above, the error occurs due to the +. The issue can be resolved by specifying the number of elements desired, e.g., 5...:

function main() {
    let x = [1; 5];
}