diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-09-23 16:55:46 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-09-24 14:43:03 +0300 |
| commit | 3525b8778edd235d8d0ad2b55eee83eacd33d5cf (patch) | |
| tree | 5c0ca92c05bae4d64f062a30ba98d335e578234d /src/Sema.zig | |
| parent | ede379848525dce72c6e903b1895ac3e4acaf3ef (diff) | |
| download | zig-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.zig | 17 |
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 |
