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:
Int32,String,Byte,Char,Float,Bool, etc.These are not valid constant types:
Array[Int32],(Int32) -> Int32,Ref[Int32], etc.
Erroneous example#
pub const A : Array[Int32] = [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[Int32] = [1, 2, 3]