diff --git a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts index bed0c5be76..e50486d2f4 100644 --- a/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts +++ b/compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts @@ -24,10 +24,12 @@ import { FunctionType, IdentifierId, PolyType, + ScopeId, Type, ValueKind, makeBlockId, makeIdentifierId, + makeScopeId, } from "./HIR"; import { BuiltInMixedReadonlyId, @@ -412,6 +414,7 @@ export class Environment { #shapes: ShapeRegistry; #nextIdentifer: number = 0; #nextBlock: number = 0; + #nextScope: number = 0; config: EnvironmentConfig; #contextIdentifiers: Set; @@ -460,6 +463,10 @@ export class Environment { return makeBlockId(this.#nextBlock++); } + get nextScopeId(): ScopeId { + return makeScopeId(this.#nextScope++); + } + isContextIdentifier(node: t.Identifier): boolean { return this.#contextIdentifiers.has(node); } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts index c03dd726ae..436d3b48bf 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/InferReactiveScopeVariables.ts @@ -12,7 +12,6 @@ import { IdentifierId, Instruction, makeInstructionId, - makeScopeId, Place, ReactiveScope, } from "../HIR/HIR"; @@ -102,7 +101,7 @@ export function inferReactiveScopeVariables(fn: HIRFunction): void { let scope = scopes.get(groupIdentifier); if (scope === undefined) { scope = { - id: makeScopeId(scopes.size), + id: fn.env.nextScopeId, range: identifier.mutableRange, dependencies: new Set(), declarations: new Map(),