@samitouri / QOS-React-2 / commits / 7c73f51139

[hir] Define function name only if it exists

Sathya Gunasekaran committed Jan 19, 2023 at 18:39 UTC 7c73f5113923641bf5f6260f41ddb3186fa76f72
1 file changed +9 -7
compiler/forget/src/Inference/InferReferenceEffects.ts
+9 -7
@@ -76,19 +76,21 @@ export default function inferReferenceEffects(fn: HIRFunction) {
76 // Initial environment contains function params
77 // TODO: include module declarations here as well
78 const initialEnvironment = Environment.empty();
79 - const id: Place = {
80 - kind: "Identifier",
81 - identifier: fn.id as any,
82 - loc: fn.loc,
83 - effect: Effect.Freeze,
84 - };
79 const value: InstructionValue = {
80 kind: "Primitive",
81 loc: fn.loc,
82 value: undefined,
83 };
84 initialEnvironment.initialize(value, ValueKind.Frozen);
91 - initialEnvironment.define(id, value);
85 + if (fn.id !== null) {
86 + const id: Place = {
87 + kind: "Identifier",
88 + identifier: fn.id,
89 + loc: fn.loc,
90 + effect: Effect.Freeze,
91 + };
92 + initialEnvironment.define(id, value);
93 + }
94
95 for (const param of fn.params) {
96 const value: InstructionValue = {