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 // the builtin functions can't be redefined
errors.err("builtin function cannot be redefined", label.position) errors.err("builtin function cannot be redefined", label.position)
} else { } else {
val existing = label.definingSubroutine?.getAllLabels(label.name) ?: emptyList() val existing = (label.definingSubroutine ?: label.definingBlock).getAllLabels(label.name)
for(el in existing) { for(el in existing) {
if(el === label || el.name != label.name) if(el === label || el.name != label.name)
continue continue

View File

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