Skip to content

Commit

Permalink
fix: Added missing type check when return statement as no returned value
Browse files Browse the repository at this point in the history
  • Loading branch information
giann committed Sep 19, 2024
1 parent 2a17e7e commit 406bc03
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Codegen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3427,6 +3427,17 @@ fn generateReturn(self: *Self, node: Ast.Node.Index, breaks: ?*Breaks) Error!?*o

_ = try self.generateNode(value, breaks);
} else {
if (self.current.?.function.?.type_def.resolved_type.?.Function.return_type.def_type != .Void) {
self.reporter.reportTypeCheck(
.return_type,
self.ast.tokens.get(locations[self.current.?.function_node]),
self.current.?.function.?.type_def.resolved_type.?.Function.return_type,
self.ast.tokens.get(locations[node]),
self.gc.type_registry.void_type,
"Return value",
);
}

try self.emitOpCode(locations[node], .OP_VOID);
}

Expand Down

0 comments on commit 406bc03

Please sign in to comment.