mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-24 06:37:07 +00:00
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:
+2
-2
@@ -227,9 +227,9 @@ static int32_t tryConstMask(Expression const &lhs, Expression const &rhs) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
assume(sym.isNumeric());
|
||||
assume(sym.type == SYM_LABEL);
|
||||
// We can now safely use `expr.value()` and `sym.getSection()`
|
||||
|
||||
// We can now safely use `expr.value()`
|
||||
int32_t mask = expr.value();
|
||||
|
||||
// The mask must not cover any unknown bits
|
||||
|
||||
Reference in New Issue
Block a user