aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-09-23 16:55:46 +0300
committerVeikka Tuominen <git@vexu.eu>2022-09-24 14:43:03 +0300
commit3525b8778edd235d8d0ad2b55eee83eacd33d5cf (patch)
tree5c0ca92c05bae4d64f062a30ba98d335e578234d /src/Sema.zig
parentede379848525dce72c6e903b1895ac3e4acaf3ef (diff)
downloadzig-3525b8778edd235d8d0ad2b55eee83eacd33d5cf.tar.gz
zig-3525b8778edd235d8d0ad2b55eee83eacd33d5cf.zip
Sema: properly handle generic struct as parameter type
Closes #12907
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 465a3ceb1b..342213dad1 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -8277,8 +8277,21 @@ fn zirParam(
else => |e| return e,
}
};
- const is_comptime = comptime_syntax or
- try sema.typeRequiresComptime(param_ty);
+ const is_comptime = sema.typeRequiresComptime(param_ty) catch |err| switch (err) {
+ error.GenericPoison => {
+ // The type is not available until the generic instantiation.
+ // We result the param instruction with a poison value and
+ // insert an anytype parameter.
+ try block.params.append(sema.gpa, .{
+ .ty = Type.initTag(.generic_poison),
+ .is_comptime = comptime_syntax,
+ .name = param_name,
+ });
+ try sema.inst_map.putNoClobber(sema.gpa, inst, .generic_poison);
+ return;
+ },
+ else => |e| return e,
+ } or comptime_syntax;
if (sema.inst_map.get(inst)) |arg| {
if (is_comptime) {
// We have a comptime value for this parameter so it should be elided from the