Disallow minus sign before symbol name in bracketed macro arguments (#2015)

This was being silently allowed but without actually negating the symbol's value
This commit is contained in:
Rangi
2026-07-07 00:42:09 -04:00
committed by GitHub
parent dabd0a08d2
commit f82b0838a1
4 changed files with 21 additions and 6 deletions
+9 -6
View File
@@ -535,13 +535,16 @@ static uint32_t readBracketedMacroArgNum() {
int c = peek();
bool empty = false;
bool symbolError = false;
bool negative = c == '-';
if (negative) {
c = nextChar();
}
if (isDigit<10>(c)) {
if (c == '-' || isDigit<10>(c)) {
bool negative = c == '-';
if (negative) {
c = nextChar();
if (!isDigit<10>(c)) {
error("No digit after minus sign in bracketed macro argument");
return 0;
}
}
uint32_t n = readNumber<10>(bumpChar(), nullptr);
if (n > INT32_MAX) {
error("Number in bracketed macro argument is too large");