diff --git a/compiler/src/prog8/compiler/target/c64/codegen2/AnonymousScopeVarsCleanup.kt b/compiler/src/prog8/compiler/target/c64/codegen2/AnonymousScopeVarsCleanup.kt index d373ebfe8..10e9521fc 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen2/AnonymousScopeVarsCleanup.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen2/AnonymousScopeVarsCleanup.kt @@ -57,8 +57,8 @@ class AnonymousScopeVarsCleanup(val program: Program): IAstModifyingVisitor { val scope = ident.definingScope() as? AnonymousScope ?: return ident val vardecl = ident.targetVarDecl(program.namespace) - return if(vardecl!=null) { - // prefix the variable name reference + return if(vardecl!=null && vardecl.definingScope() == ident.definingScope()) { + // prefix the variable name reference that is defined inside the anon scope ident.withPrefixedName(nameprefix(scope)) } else { ident diff --git a/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt b/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt index 9dac54120..f075f3ba0 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt @@ -840,7 +840,10 @@ internal class AsmGen2(val program: Program, } private fun translate(stmt: RepeatLoop) { - TODO("repeat $stmt") + // TODO("repeat $stmt") + out(";------ TODO REPEAT") + translate(stmt.body) + out(";------ TODO REPEAT END") } private fun translate(stmt: WhenStatement) { diff --git a/examples/test.p8 b/examples/test.p8 index dd9597793..7ab98ecff 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -10,9 +10,29 @@ main { sub start() { A=abc + ubyte zzz + + repeat { + uword wvar + Y=abc + Y=zzz + wvar=99 + } until 99 + + repeat { + uword wvar + Y=abc + Y=zzz + wvar=99 + } until 99 + + if A>0 { + uword wvar + Y=abc + Y=zzz + wvar=99 + } - if A>0 - Y=abc ; @todo gets prefixed with anon1_ but should not be because is found in other scope... } }