From 314e5ca9e28dd61879ed3b0077dcc2f65bcef14b Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 6 Oct 2018 23:07:57 +0200 Subject: [PATCH] correct type for word array initialization value --- compiler/src/prog8/optimizing/ConstantFolding.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/src/prog8/optimizing/ConstantFolding.kt b/compiler/src/prog8/optimizing/ConstantFolding.kt index 89f382e6d..9d92b328a 100644 --- a/compiler/src/prog8/optimizing/ConstantFolding.kt +++ b/compiler/src/prog8/optimizing/ConstantFolding.kt @@ -56,11 +56,17 @@ class ConstantFolding(private val namespace: INameScope, private val heap: HeapV val litval = decl.value as? LiteralValue val size = decl.arrayspec!!.size() if(litval!=null && litval.isArray) { - // array initializer value is an array already, keep as-is + // array initializer value is an array already, keep as-is (or convert to WORDs if needed) if(litval.heapId!=null) { if (decl.datatype == DataType.MATRIX && litval.type != DataType.MATRIX) { val array = heap.get(litval.heapId).copy(type = DataType.MATRIX) heap.update(litval.heapId, array) + } else if(decl.datatype==DataType.ARRAY_W && litval.type == DataType.ARRAY) { + val array = heap.get(litval.heapId) + if(array.array!=null) { + heap.update(litval.heapId, HeapValues.HeapValue(DataType.ARRAY_W, null, array.array, null)) + decl.value = LiteralValue(decl.datatype, heapId = litval.heapId, position = litval.position) + } } } } else if (size != null) {