properly report duplicate label names

This commit is contained in:
Irmen de Jong 2022-02-15 00:39:10 +01:00
parent e34dac8dbb
commit 73fc18099e
2 changed files with 22 additions and 8 deletions

View File

@ -108,7 +108,7 @@ internal class AstIdentifiersChecker(private val errors: IErrorReporter,
// the builtin functions can't be redefined
errors.err("builtin function cannot be redefined", label.position)
} else {
val existing = label.definingSubroutine?.getAllLabels(label.name) ?: emptyList()
val existing = (label.definingSubroutine ?: label.definingBlock).getAllLabels(label.name)
for(el in existing) {
if(el === label || el.name != label.name)
continue

View File

@ -1,11 +1,25 @@
%zeropage basicsafe
%import textio
main {
sub start() {
ubyte @shared xx
str myBar = "main.bar"
if xx==1 or xx==2 or xx==3 {
xx++
foo_bar:
sub start() {
txt.print(myBar)
txt.print(&foo_bar)
return
quert:
quert:
quert:
quert:
}
sub start() {
}
}
foo_bar:
foo_bar:
foo_bar:
foo_bar:
}