diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index 7c41512b3..5dfe2650a 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -456,7 +456,7 @@ internal class AstChecker(private val program: Program, val targetIdentifier = assignTarget.identifier if (targetIdentifier != null) { val targetName = targetIdentifier.nameInSource - when (val targetSymbol = program.namespace.lookup(targetName, assignment.definingScope)) { + when (val targetSymbol = assignment.definingScope.lookup(targetName, assignment.definingScope)) { null -> { errors.err("undefined symbol: ${targetIdentifier.nameInSource.joinToString(".")}", targetIdentifier.position) return @@ -1073,7 +1073,7 @@ internal class AstChecker(private val program: Program, override fun visit(postIncrDecr: PostIncrDecr) { if(postIncrDecr.target.identifier != null) { val targetName = postIncrDecr.target.identifier!!.nameInSource - val target = program.namespace.lookup(targetName, postIncrDecr.definingScope) + val target = postIncrDecr.definingScope.lookup(targetName, postIncrDecr.definingScope) if(target==null) { val symbol = postIncrDecr.target.identifier!! errors.err("undefined symbol: ${symbol.nameInSource.joinToString(".")}", symbol.position) diff --git a/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt index 3ae260908..6b2983923 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt @@ -42,7 +42,7 @@ internal class AstIdentifiersChecker(private val program: Program, private val e if(decl.name in compTarget.machine.opcodeNames) errors.err("can't use a cpu opcode name as a symbol: '${decl.name}'", decl.position) - val existing = program.namespace.lookup(listOf(decl.name), decl.definingScope) + val existing = decl.definingScope.lookup(listOf(decl.name), decl.definingScope) if (existing != null && existing !== decl) nameError(decl.name, decl.position, existing) @@ -65,7 +65,7 @@ internal class AstIdentifiersChecker(private val program: Program, private val e // if (subroutine.parameters.any { it.name in BuiltinFunctions }) // checkResult.add(NameError("builtin function name cannot be used as parameter", subroutine.position)) - val existing = program.namespace.lookup(listOf(subroutine.name), subroutine) + val existing = subroutine.lookup(listOf(subroutine.name), subroutine) if (existing != null && existing !== subroutine) nameError(subroutine.name, subroutine.position, existing) diff --git a/compiler/test/TestScoping.kt b/compiler/test/TestScoping.kt index ede65305d..b8cd40cf3 100644 --- a/compiler/test/TestScoping.kt +++ b/compiler/test/TestScoping.kt @@ -58,7 +58,7 @@ class TestScoping { addr = &labelinside addr = &labeloutside addr = &main.start.nested.nestedlabel - ; addr = &nested.nestedlabel ; TODO should also work!! + addr = &nested.nestedlabel goto labeloutside goto iflabel goto main.start.nested.nestedlabel @@ -72,11 +72,11 @@ class TestScoping { addr = &labelinside addr = &labeloutside addr = &main.start.nested.nestedlabel - ; addr = &nested.nestedlabel ; TODO should also work!! + addr = &nested.nestedlabel goto iflabel goto labelinside goto main.start.nested.nestedlabel - ; goto nested.nestedlabel ; TODO should also work!! + goto nested.nestedlabel labelinside: } @@ -92,9 +92,9 @@ class TestScoping { addr = &labelinside addr = &labeloutside addr = &main.start.nested.nestedlabel - ; addr = &nested.nestedlabel ; TODO should also work!! + addr = &nested.nestedlabel goto main.start.nested.nestedlabel - ; goto nested.nestedlabel ; TODO should also work!! + goto nested.nestedlabel } } """ @@ -105,8 +105,6 @@ class TestScoping { val start = mainBlock.statements.single() as Subroutine val labels = start.statements.filterIsInstance