diff --git a/src/compiler.ts b/src/compiler.ts index 4893254..47e09b4 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -1,6 +1,8 @@ import type { AST, Pattern, Definition } from './ast'; import { _rt, store } from './runtime-js'; +let matchCounter = 0; + export const definitions: Map = new Map(); export const dependencies: Map> = new Map(); export const dependents: Map> = new Map(); @@ -135,7 +137,7 @@ function sanitizeName(name: string): string { function compileMatch(ast: AST & { kind: 'match'}, useStore = true, bound = new Set()): string { const expr = compile(ast.expr, useStore, bound); - const tmpVar = `_m${Math.floor(Math.random() * 10000)}`; + const tmpVar = `_m${matchCounter++}`; let code = `((${tmpVar}) => { `;