Go

What is wrong with the following code?:

package main

func main() {
    var x = 2
    var y = 3
    const someConst = x + y
}

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

Constants in Go can only be declared using constant expressions. But x, y and their sum is variable.

const initializer x + y is not a constant