Do not allow defining labels outside sections (#2013)

Creating a `Symbol` with `type = SYM_LABEL` but `section = nullptr`
is inconsistent and dangerous. I was not able to cause any buggy
behavior so far, but it's safer and reasonable to not create such
a symbol in the first place.

The main consequence is that `DEF(LabelOutsideSection)` will now
evaluate as 0.
This commit is contained in:
Rangi
2026-07-06 16:18:42 -04:00
committed by GitHub
parent 46a6966b70
commit fe3b238dea
12 changed files with 24 additions and 19 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
error: Label `lab` created outside of a `SECTION`
error: Cannot define label `lab` outside of a `SECTION`
at use-label-outside-section.asm(1)
error: Expected constant expression: `lab` is not constant at assembly time
at use-label-outside-section.asm(2)
error: Expected constant expression: undefined symbol `lab`
at use-label-outside-section.asm(3)
Assembly aborted with 2 errors