From 393a3e5e5e272e29e7bfd57fa2e8f986d3d11101 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 7 Apr 2024 13:54:46 -0700 Subject: [PATCH] module: add check for missing injected arguments Signed-off-by: Stephen Gutekanst --- src/module/module.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/module/module.zig b/src/module/module.zig index a0551f6a..c40a1558 100644 --- a/src/module/module.zig +++ b/src/module/module.zig @@ -578,6 +578,12 @@ inline fn injectArgs( continue :outer; } } + if (@typeInfo(arg.type) == .Pointer and @hasDecl(std.meta.Child(arg.type), "IsInjectedArgument")) { + // Argument is declared as injectable, but we do not have a value to inject for it. + // This can be the case if e.g. a Mod() parameter is specified, but that module is + // not registered. + @compileError("mach: cannot inject argument of type: " ++ @typeName(arg.type) ++ " - is it registered in your program's top-level `pub const modules = .{};`?"); + } // First standard argument @field(args, arg.name) = std_args[std_args_index];