From e974d4c4295c4fbdbc239caa2cf2d653f65662f1 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 6 Aug 2021 17:26:37 -0700 Subject: stage2: get rid of "unable to monomorphize function" error This commit solves the problem in a much simpler way: putting runtime-known values in place of non-comptime arguments when instantiating a generic function. --- src/Module.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 3652a27927..42b36b5a04 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1376,6 +1376,16 @@ pub const Scope = struct { }); } + pub fn addArg(block: *Block, ty: Type, name: u32) error{OutOfMemory}!Air.Inst.Ref { + return block.addInst(.{ + .tag = .arg, + .data = .{ .ty_str = .{ + .ty = try block.sema.addType(ty), + .str = name, + } }, + }); + } + pub fn addInst(block: *Block, inst: Air.Inst) error{OutOfMemory}!Air.Inst.Ref { return Air.indexToRef(try block.addInstAsIndex(inst)); } -- cgit v1.2.3