Skip to content

Commit bcca3d2

Browse files
committed
Wait until loop boundary is substituted before unrolling it
1 parent b3f57d3 commit bcca3d2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/src/tbaf.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,18 @@ function unrollForLoop(forStatement: ForStatement, vars: varsContext) {
631631
return;
632632
}
633633

634+
// Ensure the loop boundary is numeric
635+
if (Node.isBinaryExpression(condition)) {
636+
const conditionValue = condition.getRight().getText();
637+
if (isNaN(Number(conditionValue))) {
638+
console.log(`Skipping loop with non-numeric boundary: ${conditionValue}`);
639+
return;
640+
}
641+
} else {
642+
console.log("Skipping loop with unsupported condition type.");
643+
return;
644+
}
645+
634646
// Get the incrementor (e.g., `i++`, `i += 2`)
635647
const incrementor = forStatement.getIncrementor();
636648
if (!incrementor) {

0 commit comments

Comments
 (0)