1
1
mirror of https://github.com/Burn-E99/TheArtificer.git synced 2026-06-04 09:03:50 -04:00

add additional paren balance check

This commit is contained in:
Ean Milligan
2025-04-29 02:41:31 -04:00
parent ba51bd471c
commit 15ecb45e65

View File

@@ -68,6 +68,11 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
} else if (e === ')') { } else if (e === ')') {
parenCnt--; parenCnt--;
} }
// If parenCnt ever goes below 0, that means too many closing paren appeared before opening parens
if (parenCnt < 0) {
throw new Error('UnbalancedParens');
}
}); });
// If the parenCnt is not 0, then we do not have balanced parens and need to error out now // If the parenCnt is not 0, then we do not have balanced parens and need to error out now