diff --git a/compiler/forget/src/Diagnostic.ts b/compiler/forget/src/Diagnostic.ts index 8362e3c6f2..c60fd588b5 100644 --- a/compiler/forget/src/Diagnostic.ts +++ b/compiler/forget/src/Diagnostic.ts @@ -154,6 +154,7 @@ export type DiagnosticOpts = path: NodePath; context: { callee: NodePath | NodePath[]; + init: NodePath | NodePath[]; }; } | { code: "E0008"; path: NodePath; context: { input: NodePath } } @@ -224,7 +225,7 @@ function getDiagnosticMessage(opts: DiagnosticOpts): DiagnosticMessage { body: `\`${getSource( opts.context.callee )}\` does not have a return value.`, - suggestion: `Do \`${getSource(opts.path.get("init"))}\` instead.`, + suggestion: `Do \`${getSource(opts.context.init)}\` instead.`, }; case "E0008": return { diff --git a/compiler/forget/src/IR/Hook.ts b/compiler/forget/src/IR/Hook.ts index 9c040881dd..5623e6ef70 100644 --- a/compiler/forget/src/IR/Hook.ts +++ b/compiler/forget/src/IR/Hook.ts @@ -505,11 +505,12 @@ function matchHookCallRetVals( function matchVoid(_pattern: Void, lvals: NodePath) { if (lvals.isPatternLike()) { + let init = lvals.parentPath.get("init"); let callee = lvals.parentPath.get("init.callee"); context.createDiagnostic({ code: "E0007", path: lvals.parentPath, - context: { callee }, + context: { callee, init }, }); } }