diff --git a/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt b/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt index 390625afc..45922adaa 100644 --- a/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt +++ b/compiler/src/prog8/ast/processing/AstIdentifiersChecker.kt @@ -80,6 +80,11 @@ internal class AstIdentifiersChecker(private val program: Program, private val e if (existing != null && existing !== decl) nameError(decl.name, decl.position, existing) + if(decl.definingBlock().name==decl.name) + nameError(decl.name, decl.position, decl.definingBlock()) + if(decl.definingSubroutine()?.name==decl.name) + nameError(decl.name, decl.position, decl.definingSubroutine()!!) + super.visit(decl) } diff --git a/examples/test.p8 b/examples/test.p8 index 2b17d4649..00ec99059 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -6,40 +6,10 @@ main { sub start() { - ubyte[100] cargohold - - struct SaveData { - ubyte galaxy - ubyte planet - ubyte cargo0 - ubyte cargo1 - ubyte cargo2 - ubyte cargo3 - ubyte cargo4 - ubyte cargo5 - ubyte cargo6 - ubyte cargo7 - ubyte cargo8 - ubyte cargo9 - ubyte cargo10 - ubyte cargo11 - ubyte cargo12 - ubyte cargo13 - ubyte cargo14 - ubyte cargo15 - ubyte cargo16 - uword cash - ubyte max_cargo - ubyte fuel - } - SaveData savedata - - memcopy(&savedata.cargo0, cargohold, len(cargohold)) ; TODO fix compiler error about pointer - + dinges.travel_to(5) testX() } - asmsub testX() { %asm {{ stx _saveX @@ -55,3 +25,15 @@ _saveX .byte 0 }} } } + + +dinges { + + sub foo(ubyte x) { + } + + sub travel_to(ubyte d2) { + ubyte travel_to=d2 + foo(travel_to) + } + } diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 9f87849a1..460d16ba3 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -406,7 +406,7 @@ galaxy { } sub travel_to(ubyte galaxynum, ubyte system) { - init(galaxynum) ; TODO fix scoping error when using 'galaxy' as name + init(galaxynum) generate_next_planet() ; always at least planet 0 (separate to avoid repeat ubyte overflow) repeat system { generate_next_planet()