Sisu
E0085

Constant of a type that cannot be folded

Error

Built from the repository at commit a8614dc.

A constant is an i64, a u8, an f64, a bool, a char or a string.

Why

The compiler computes a constant's value and puts it in place of each use. That works for a value that fits in a literal. An array, an optional or an object is made at run time, and a copy at each use would be a new one. Use a let in the function that needs the value, or a function that returns it.

Broken

const PRIMES: [i64] = [2, 3, 5]

fn main() {
    print(PRIMES[0])
}

What sisu says

error[E0085]: a constant is `i64`, `u8`, `f64`, `bool`, `char` or `string`
 --> E0085.sisu:1:15
  |
1 | const PRIMES: [i64] = [2, 3, 5]
  |               ^^^^^

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0085

Fixed

fn main() {
    let primes = [2, 3, 5]
    print(primes[0])
}

Related

  • E0086: constant value not known at compile time.