diff --git a/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt b/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt index ef77e5171..39018b79a 100644 --- a/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt +++ b/compiler/src/prog8/optimizer/ConstantFoldingOptimizer.kt @@ -102,7 +102,7 @@ internal class ConstantFoldingOptimizer(private val program: Program, private va else -> {} } // create the array itself, filled with the fillvalue. - val array = Array(size) {fillvalue}.map { NumericLiteralValue.optimalInteger(it, numericLv.position) as Expression}.toTypedArray() + val array = Array(size) {fillvalue}.map { NumericLiteralValue(ArrayElementTypes.getValue(decl.datatype), it, numericLv.position) as Expression}.toTypedArray() val refValue = ArrayLiteralValue(InferredTypes.InferredType.known(decl.datatype), array, position = numericLv.position) decl.value = refValue refValue.parent=decl diff --git a/examples/test.p8 b/examples/test.p8 index 7410d34a5..bce031b8f 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,7 +4,7 @@ main { - uword[2] array1 = 1 ; TODO fix compiler crash about init value type + uword[2] array1 = 1 sub start() {