fix compiler crashing with invalid array initializer built from single integer

This commit is contained in:
Irmen de Jong 2020-03-25 01:23:40 +01:00
parent 2f05ebb966
commit fab224f509
2 changed files with 2 additions and 2 deletions

View File

@ -102,7 +102,7 @@ internal class ConstantFoldingOptimizer(private val program: Program, private va
else -> {} else -> {}
} }
// create the array itself, filled with the fillvalue. // 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) val refValue = ArrayLiteralValue(InferredTypes.InferredType.known(decl.datatype), array, position = numericLv.position)
decl.value = refValue decl.value = refValue
refValue.parent=decl refValue.parent=decl

View File

@ -4,7 +4,7 @@
main { main {
uword[2] array1 = 1 ; TODO fix compiler crash about init value type uword[2] array1 = 1
sub start() { sub start() {