mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +00:00
proper error if variable name is the same as its subroutine or block (that would create naming problems in the assembly code)
This commit is contained in:
parent
cd825e386d
commit
4d68b508a2
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user