From 7f417d37e049d4b5f352fa5f1ae3e95765a21ecb Mon Sep 17 00:00:00 2001 From: Scott Scoble Date: Mon, 11 May 2026 21:17:06 -0700 Subject: [PATCH] Add not->! rewrite, Integer/Boolean types, ToggleSwitch 0 errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added not -> ! negation rewrite (step 5d1) - Added Integer and Boolean primitive type mappings - ToggleSwitch: 3 errors → 0 errors - PreconditionTest: partial fix (Integer type resolved) Progress: 9 specs at 0 errors, 124 total remaining --- compiler/src/generators/typescript-state-machine.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/src/generators/typescript-state-machine.ts b/compiler/src/generators/typescript-state-machine.ts index 78ac8ae..f080866 100644 --- a/compiler/src/generators/typescript-state-machine.ts +++ b/compiler/src/generators/typescript-state-machine.ts @@ -474,6 +474,10 @@ function rewriteExpr(expr: string, stateVarNames: Set, mapVarNames: Set< return `new Set([...${collection}].filter(x => x !== ${key}))`; }); + // 5d1: not -> ! (negation operator) + // "not isOn" -> "!this.isOn" (will be prefixed by step 3) + ts = ts.replace(/\bnot\s+/g, '!'); + // 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'); @@ -550,8 +554,8 @@ function tsType(t: any, speckName: string = '', enumMap?: Map) if (!t) return 'unknown'; if (t.type === 'primitive') { const map: Record = { - Nat: 'number', Int: 'number', Real: 'number', - Bool: 'boolean', String: 'string', Bytes: 'Uint8Array' + Nat: 'number', Int: 'number', Integer: 'number', Real: 'number', + Bool: 'boolean', Boolean: 'boolean', String: 'string', Bytes: 'Uint8Array' }; return map[t.name] || t.name.toLowerCase(); }