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

654 B

Expected string "x" -- got "y"

Example

This error occurs when a specific "string" (in reality a token), was expected but a different one was expected instead.

Erroneous code example:

function main ()  {
    let x: [u8; (!)] = [0];
}

The compiler will reject this code with:

Error [EPAR0370009]: unexpected string: expected 'int', got '!'
    --> test.leo:2:18
     |
   2 |     let x: [u8; (!)] = [0];
     |                  ^

Solutions

The error message "unexpected string" depends on the context. In the example above, we need to replace ! with 1...:

function main ()  {
    let x: [u8; 1] = [0];
}