From 73fc18099ec7386aba16b636046b3608db0dfd8d Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 15 Feb 2022 00:39:10 +0100 Subject: [PATCH] properly report duplicate label names --- .../astprocessing/AstIdentifiersChecker.kt | 2 +- examples/test.p8 | 28 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt index d3f7963b0..6c76064cb 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstIdentifiersChecker.kt @@ -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 diff --git a/examples/test.p8 b/examples/test.p8 index 9bb9c6235..8a56c9931 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -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: }