diff --git a/compiler/forget/src/HIR/BuildHIR.ts b/compiler/forget/src/HIR/BuildHIR.ts index 9f044c168b..9545271fce 100644 --- a/compiler/forget/src/HIR/BuildHIR.ts +++ b/compiler/forget/src/HIR/BuildHIR.ts @@ -55,9 +55,10 @@ export function lower( options: EnvironmentOptions | null, capturedRefs: t.Identifier[] = [], // the outermost function being compiled, in case lower() is called recursively (for lambdas) - parent: NodePath | null = null + parent: NodePath | null = null, + environment: Environment | null = null ): Result { - const env = new Environment(options); + const env = environment ?? new Environment(options); const builder = new HIRBuilder(env, parent ?? func, capturedRefs); const context: Place[] = []; @@ -1349,7 +1350,8 @@ function lowerExpression( expr, builder.environment.options, [...builder.context, ...captured.identifiers], - builder.parentFunction + builder.parentFunction, + builder.environment ); let loweredFunc: HIRFunction; if (lowering.isErr()) { diff --git a/compiler/forget/src/HIR/PrintHIR.ts b/compiler/forget/src/HIR/PrintHIR.ts index 798afc9163..d3146be577 100644 --- a/compiler/forget/src/HIR/PrintHIR.ts +++ b/compiler/forget/src/HIR/PrintHIR.ts @@ -333,13 +333,12 @@ export function printInstructionValue(instrValue: ReactiveValue): string { break; } case "FunctionExpression": { - // const fn = generate(instrValue.expr).code; const fn = printFunction(instrValue.loweredFunc) .split("\n") .map((line) => ` ${line}`) .join("\n"); const deps = instrValue.dependencies - .map((i) => printIdentifier(i.identifier)) + .map((dep) => printPlace(dep)) .join(","); value = `Function @deps[${deps}]:\n${fn}`; break; diff --git a/compiler/forget/src/__tests__/fixtures/hir/capturing-function-member-expr-call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/capturing-function-member-expr-call.expect.md index f7e4e27b00..10adb826ba 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/capturing-function-member-expr-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/capturing-function-member-expr-call.expect.md @@ -19,9 +19,9 @@ function component({ mutator }) { ## Code ```javascript -function component(t10) { +function component(t15) { const $ = React.unstable_useMemoCache(7); - const t0 = t10; + const t0 = t15; const mutator = t0.mutator; const c_0 = $[0] !== mutator; let poke;