Code: Select all
BlockStart:
@LocalLabel:
.byte $47
BlockEnd:
lda @LocalLabel
However, I was writing the global labels from within macros, where I was doing other tasks, and mysteriously enough, the local label became visible outside of the block! After hours of debugging, I found the culprit, a symbol assignment using .set. Then I reproduced the issue in a more concise way:
Code: Select all
BlockStart:
SomeSymbol .set 4
@LocalLabel:
.byte $47
BlockEnd:
SomeSymbol .set 5
lda @LocalLabel
Sounds like a bug to me, because the "BlockEnd" label should be ending the scope where "@LocalLabel" is accessible, and you shouldn't be able to go back to that scope. What do you think? Is this a bug or a feature?
Another thing that's bothering me that also involves cheap local labels is that you can't "copy" a cheap local label before it's defined, like you can with other types of labels. For example, this works:
Code: Select all
.scope
GlobalCopy := LocalLabel
LocalLabel:
.byte $47
.endscope
lda GlobalCopy
Code: Select all
BlockStart:
GlobalCopy := @LocalLabel
@LocalLabel:
.byte $47
BlockEnd:
lda GlobalCopy
Code: Select all
BlockStart:
@LocalLabel:
.byte $47
GlobalCopy := @LocalLabel
BlockEnd:
lda GlobalCopy