check for name conflict with existing block (/module)

This commit is contained in:
Irmen de Jong 2021-01-07 23:27:54 +01:00
parent 61784a03bb
commit 87cee7a0fd
2 changed files with 5 additions and 5 deletions

View File

@ -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}) {

View File

@ -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 () {