This commit is contained in:
Irmen de Jong 2024-10-13 21:33:13 +02:00
parent b6ffb81909
commit 5280e1b449
2 changed files with 11 additions and 5 deletions

View File

@ -1813,16 +1813,21 @@ internal class AstChecker(private val program: Program,
sourceValue: Expression) : Boolean { sourceValue: Expression) : Boolean {
val position = sourceValue.position val position = sourceValue.position
if(sourceValue is ArrayLiteral || targetDatatype in ArrayDatatypes) { if (targetDatatype in ArrayDatatypes) {
errors.err("cannot assign arrays directly. Maybe use sys.memcopy(src, tgt, sizeof(tgt)) instead.", target.position) 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 return false
} }
if(sourceValue is RangeExpression) { if(sourceValue is RangeExpression) {
errors.err("can't assign a range value to something else", position) errors.err("can't assign a range value to something else", position)
return false return false
} }
if(sourceDatatype==DataType.UNDEFINED) { if(sourceDatatype==DataType.UNDEFINED) {
errors.err("assignment right hand side doesn't result in a value", position) errors.err("assignment right hand side doesn't result in a value", position)
return false return false

View File

@ -14,7 +14,8 @@ main {
txt.spc() txt.spc()
} }
txt.nl() txt.nl()
sys.memcopy(words2, words1, sizeof(words1)) cx16.r0L = words2
sys.memsetw(words1, len(words1), 99)
for cx16.r0 in words1 { for cx16.r0 in words1 {
txt.print_uw(cx16.r0) txt.print_uw(cx16.r0)
txt.spc() txt.spc()