diff --git a/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt b/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt index 399a7a72d..2aba7c292 100644 --- a/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt @@ -119,9 +119,12 @@ internal class AstIdentifiersChecker(private val program: Program, private val e val labelOrVar = subroutine.getLabelOrVariable(name) if(labelOrVar!=null && labelOrVar.position != subroutine.position) nameError(name, labelOrVar.position, subroutine) - val sub = subroutine.statements.singleOrNull { it is Subroutine && it.name==name} + val sub = subroutine.statements.firstOrNull { it is Subroutine && it.name==name} if(sub!=null) - nameError(name, sub.position, subroutine) + nameError(name, subroutine.position, sub) + val block = program.allBlocks().firstOrNull { it.name==name } + if(block!=null) + nameError(name, subroutine.position, block) } if(subroutine.isAsmSubroutine && subroutine.statements.any{it !is InlineAssembly}) { diff --git a/examples/test.p8 b/examples/test.p8 index db789ad09..4d7e35c3c 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -6,10 +6,7 @@ main { - ; TODO: error when a parameter has the same name as an existing module/block/subroutine: sub print_right(ubyte width, uword string) { - sub start() { - test_stack.test() } sub start2 () {