fix: tighten stack-depth guard to !== 4 to catch overflow (#584)
Reviewer noted that `< 4` only catches underflow; programs leaving 5+ values on the DYADIC stack silently passed isValid(). Change the guard to `!== 4` so both under- and overflow are rejected, matching the documented 'exactly 4 outputs' contract. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
5dffed123d
commit
403a304c98
1 changed files with 1 additions and 1 deletions
|
|
@ -391,7 +391,7 @@ export function transpile(program: Node): TranspileResult {
|
|||
processItems(program.items, state);
|
||||
|
||||
// Pop 4 outputs: top → ci, then anchorShare, anchorWidth, discoveryDepth.
|
||||
if (state.dStack.length < 4) {
|
||||
if (state.dStack.length !== 4) {
|
||||
throw new Error(
|
||||
`Program must leave exactly 4 values on the DYADIC stack; found ${state.dStack.length}`,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue