E4143#
Not a valid constant type, only immutable primitive types are allowed.
In MoonBit, you can use const to declare a constant value. Only literal value
of immutable primitive types can be assigned to const.
These are valid constant types:
Int,String,Byte,Char,Float,Bool, etc.These are not valid constant types:
Array[Int],(Int) -> Int,Ref[Int], etc.
Erroneous example#
pub const A : Array[Int] = [1, 2, 3] // Error: Not a valid constant type, only immutable primitive types are allowed.
Suggestion#
You can bind the value to a variable using let instead.
pub let a : Array[Int] = [1, 2, 3]