From 0d55075de44ed037799b088a8e1ecf0783491da6 Mon Sep 17 00:00:00 2001 From: Vexu <15308111+Vexu@users.noreply.github.com> Date: Tue, 26 Nov 2019 22:38:05 +0200 Subject: [PATCH] fix command functions not being async pointers --- src-self-hosted/main.zig | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src-self-hosted/main.zig b/src-self-hosted/main.zig index 81b3055a54..7906c9daa7 100644 --- a/src-self-hosted/main.zig +++ b/src-self-hosted/main.zig @@ -49,7 +49,7 @@ const usage = const Command = struct { name: []const u8, - exec: fn (*Allocator, []const []const u8) anyerror!void, + exec: async fn (*Allocator, []const []const u8) anyerror!void, }; pub fn main() !void { @@ -118,9 +118,12 @@ pub fn main() !void { }, }; - for (commands) |command| { + inline for (commands) |command| { if (mem.eql(u8, command.name, args[1])) { - return command.exec(allocator, args[2..]); + var frame = try allocator.create(@Frame(command.exec)); + defer allocator.destroy(frame); + frame.* = async command.exec(allocator, args[2..]); + return await frame; } } @@ -852,10 +855,12 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { .exec = cmdInternalBuildInfo, }}; - for (sub_commands) |sub_command| { + inline for (sub_commands) |sub_command| { if (mem.eql(u8, sub_command.name, args[0])) { - try sub_command.exec(allocator, args[1..]); - return; + var frame = try allocator.create(@Frame(sub_command.exec)); + defer allocator.destroy(frame); + frame.* = async sub_command.exec(allocator, args[1..]); + return await frame; } }