aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-08-06 17:26:37 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-08-06 17:26:37 -0700
commite974d4c4295c4fbdbc239caa2cf2d653f65662f1 (patch)
treecd69c982cb6d80d6a1c2076c9552ed36b4e98816 /src/Module.zig
parentede76f4fe31e6fc935ae10f030eb2c97ed36aaaa (diff)
downloadzig-e974d4c4295c4fbdbc239caa2cf2d653f65662f1.tar.gz
zig-e974d4c4295c4fbdbc239caa2cf2d653f65662f1.zip
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.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig10
1 files changed, 10 insertions, 0 deletions
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));
}