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.
This commit is contained in:
Andrew Kelley
2021-08-06 17:26:37 -07:00
parent ede76f4fe3
commit e974d4c429
2 changed files with 43 additions and 22 deletions

View File

@@ -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));
}