From e0562bbd51c8da906e62e34e335d2bacd48aba6e Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Tue, 14 Feb 2023 23:07:18 +0000 Subject: [PATCH] [typer] Type hook callee as Hook type --- compiler/forget/src/TypeInference/InferTypes.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/forget/src/TypeInference/InferTypes.ts b/compiler/forget/src/TypeInference/InferTypes.ts index a7c496d23e..3223630bf4 100644 --- a/compiler/forget/src/TypeInference/InferTypes.ts +++ b/compiler/forget/src/TypeInference/InferTypes.ts @@ -9,6 +9,7 @@ import { TypeVar, } from "../HIR/HIR"; import { eachInstructionOperand } from "../HIR/visitors"; +import { parseHookCall } from "../Inference/InferReferenceEffects"; function isPrimitiveBinaryOp(op: t.BinaryExpression["operator"]) { switch (op) { @@ -120,7 +121,14 @@ function* generateInstructionTypes( } case "CallExpression": { - yield equation(value.callee.identifier.type, { kind: "Function" }); + const hook = parseHookCall(value.callee); + let type: Type; + if (hook !== null) { + type = { kind: "Hook", name: hook.name }; + } else { + type = { kind: "Function" }; + } + yield equation(value.callee.identifier.type, type); break; }