From 7c73f5113923641bf5f6260f41ddb3186fa76f72 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Thu, 19 Jan 2023 18:39:23 +0000 Subject: [PATCH] [hir] Define function name only if it exists --- .../src/Inference/InferReferenceEffects.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/compiler/forget/src/Inference/InferReferenceEffects.ts b/compiler/forget/src/Inference/InferReferenceEffects.ts index 2a17e0e93c..5539035862 100644 --- a/compiler/forget/src/Inference/InferReferenceEffects.ts +++ b/compiler/forget/src/Inference/InferReferenceEffects.ts @@ -76,19 +76,21 @@ export default function inferReferenceEffects(fn: HIRFunction) { // Initial environment contains function params // TODO: include module declarations here as well const initialEnvironment = Environment.empty(); - const id: Place = { - kind: "Identifier", - identifier: fn.id as any, - loc: fn.loc, - effect: Effect.Freeze, - }; const value: InstructionValue = { kind: "Primitive", loc: fn.loc, value: undefined, }; initialEnvironment.initialize(value, ValueKind.Frozen); - initialEnvironment.define(id, value); + if (fn.id !== null) { + const id: Place = { + kind: "Identifier", + identifier: fn.id, + loc: fn.loc, + effect: Effect.Freeze, + }; + initialEnvironment.define(id, value); + } for (const param of fn.params) { const value: InstructionValue = {