diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 0d0dc945f..ee85d9cd6 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -1813,16 +1813,21 @@ internal class AstChecker(private val program: Program, sourceValue: Expression) : Boolean { val position = sourceValue.position - if(sourceValue is ArrayLiteral || targetDatatype in ArrayDatatypes) { - errors.err("cannot assign arrays directly. Maybe use sys.memcopy(src, tgt, sizeof(tgt)) instead.", target.position) + if (targetDatatype in ArrayDatatypes) { + if(sourceValue.inferType(program).isArray) + errors.err("cannot assign arrays directly. Maybe use sys.memcopy instead.", target.position) + else + errors.err("cannot assign value to array. Maybe use sys.memset/memsetw instead.", target.position) + return false + } + if (sourceValue is ArrayLiteral) { + errors.err("cannot assign array", target.position) return false } - if(sourceValue is RangeExpression) { errors.err("can't assign a range value to something else", position) return false } - if(sourceDatatype==DataType.UNDEFINED) { errors.err("assignment right hand side doesn't result in a value", position) return false diff --git a/examples/test.p8 b/examples/test.p8 index cf1349a12..423eb6014 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -14,7 +14,8 @@ main { txt.spc() } txt.nl() - sys.memcopy(words2, words1, sizeof(words1)) + cx16.r0L = words2 + sys.memsetw(words1, len(words1), 99) for cx16.r0 in words1 { txt.print_uw(cx16.r0) txt.spc()