[hir] Make return.value non nullable
Sathya Gunasekaran committed
Apr 17, 2023 at 21:11 UTC
7c5e5eb30c996a72d3fa45b4d2b8cd2c321c5e63
2 files changed
+24
-26
compiler/forget/src/HIR/HIR.ts
+1
-1
@@ -313,7 +313,7 @@ export type Case = { test: Place | null; block: BlockId };
313
export type ReturnTerminal = {
314
kind: "return";
315
loc: SourceLocation;
316
- value: Place | null;
316
+ value: Place;
317
id: InstructionId;
318
};
319
compiler/forget/src/Inference/InlineUseMemo.ts
+23
-25
@@ -332,33 +332,31 @@ function rewriteBlock(
332
if (terminal.kind !== "return") {
333
return;
334
}
335
- if (terminal.value !== null) {
336
- block.instructions.push({
337
- id: makeInstructionId(0),
338
- loc: terminal.loc,
339
- lvalue: {
340
- effect: Effect.Unknown,
341
- identifier: {
342
- id: env.nextIdentifierId,
343
- mutableRange: {
344
- start: makeInstructionId(0),
345
- end: makeInstructionId(0),
346
- },
347
- name: null,
348
- scope: null,
349
- type: makeType(),
335
+ block.instructions.push({
336
+ id: makeInstructionId(0),
337
+ loc: terminal.loc,
338
+ lvalue: {
339
+ effect: Effect.Unknown,
340
+ identifier: {
341
+ id: env.nextIdentifierId,
342
+ mutableRange: {
343
+ start: makeInstructionId(0),
344
+ end: makeInstructionId(0),
345
},
351
- kind: "Identifier",
352
- loc: terminal.loc,
353
- },
354
- value: {
355
- kind: "StoreLocal",
356
- lvalue: { kind: InstructionKind.Reassign, place: { ...returnValue } },
357
- value: terminal.value,
358
- loc: terminal.loc,
346
+ name: null,
347
+ scope: null,
348
+ type: makeType(),
349
},
360
- });
361
- }
350
+ kind: "Identifier",
351
+ loc: terminal.loc,
352
+ },
353
+ value: {
354
+ kind: "StoreLocal",
355
+ lvalue: { kind: InstructionKind.Reassign, place: { ...returnValue } },
356
+ value: terminal.value,
357
+ loc: terminal.loc,
358
+ },
359
+ });
360
block.terminal = {
361
kind: "goto",
362
block: returnTarget,