From e5e63cc5ac16cefc3c214207693869e6df88da00 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 11 Mar 2023 16:12:47 +0100 Subject: [PATCH] catch wrong repeat value --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 8284a8bc5..c56aa4b0e 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -447,6 +447,13 @@ internal class AstChecker(private val program: Program, val iterations = repeatLoop.iterations?.constValue(program) if(iterations != null && iterations.number.toInt() > 65535) errors.err("repeat cannot go over 65535 iterations", iterations.position) + + val ident = repeatLoop.iterations as? IdentifierReference + if(ident!=null) { + val targetVar = ident.targetVarDecl(program) + if(targetVar==null) + errors.err("invalid assignment value, maybe forgot '&' (address-of)", ident.position) + } super.visit(repeatLoop) }