From 52be7b1c6d4722a4e3655c6498a2d507a04b55cd Mon Sep 17 00:00:00 2001 From: Scott Scoble Date: Mon, 11 May 2026 21:27:36 -0700 Subject: [PATCH] Fix SQLitePager, improve and/or rewrite, add emptySet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - SQLitePager: 4 errors → 0 errors - Added emptySet → new Set() rewrite - Fix and/or regex to avoid matching method calls like .or() - Progress: 12 specs at 0 errors --- compiler/src/generators/typescript-state-machine.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/generators/typescript-state-machine.ts b/compiler/src/generators/typescript-state-machine.ts index 184c3f7..b4cfeaa 100644 --- a/compiler/src/generators/typescript-state-machine.ts +++ b/compiler/src/generators/typescript-state-machine.ts @@ -488,7 +488,8 @@ function rewriteExpr(expr: string, stateVarNames: Set, mapVarNames: Set< ts = ts.replace(/\bnot\s+/g, '!'); // 5d2: and -> &&, or -> || (logical operators) - ts = ts.replace(/\band\b/g, '&&').replace(/\bor\b/g, '||'); + // Avoid matching inside method calls like .or( or .and( + ts = ts.replace(/([^.]\s*)\band\b(?!\s*\()/g, '$1&&').replace(/([^.]\s*)\bor\b(?!\s*\()/g, '$1||'); // 5d3: Strip SpeckDL comments (// ...) before TS processing ts = ts.replace(/\/\/.*$/gm, ''); @@ -509,6 +510,9 @@ function rewriteExpr(expr: string, stateVarNames: Set, mapVarNames: Set< return `new Map([[${k}, ${v}]])`; }); + // 5d6: emptySet -> new Set() + ts = ts.replace(/\bemptySet\b/g, 'new Set()'); + // 5e: Clean up trailing empty comparisons (===) — expression has no RHS after old() removal // "accounts[t.from].debits_posted ===" -> "accounts[t.from].debits_posted === accounts[t.from].debits_posted" ts = ts.replace(/(\S+)\s*===\s*$/g, '$1 === $1');