diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-18 13:56:20 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-20 20:11:12 +0300 |
| commit | 3b60a6de2fd68d7d02de7a10b8b88c919aa088f0 (patch) | |
| tree | 4dd4233eaf364efec301663c3383501d0afaaf2a /src | |
| parent | c95a34b68f6075d7a9d305d17a6b03bc9fd1fff2 (diff) | |
| download | zig-3b60a6de2fd68d7d02de7a10b8b88c919aa088f0.tar.gz zig-3b60a6de2fd68d7d02de7a10b8b88c919aa088f0.zip | |
Sema: fix using runtime instructions inside typeof in comptime only blocks
Closes #13210
Follow up to 3ccd4907fbcd04ecddffb618a4b14581fd080279
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 8945bc6bed..76e7e779e7 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -6433,7 +6433,7 @@ fn analyzeInlineCallArg( .ty = param_ty, .val = arg_val, }; - } else if ((try sema.resolveMaybeUndefVal(arg_block, arg_src, casted_arg) == null) or + } else if (((try sema.resolveMaybeUndefVal(arg_block, arg_src, casted_arg)) == null) or try sema.typeRequiresComptime(param_ty) or zir_tags[inst] == .param_comptime) { try sema.inst_map.putNoClobber(sema.gpa, inst, casted_arg); @@ -14521,6 +14521,12 @@ fn zirClosureGet( return sema.failWithOwnedErrorMsg(msg); } + if (tv.val.tag() == .unreachable_value) { + assert(block.is_typeof); + // We need a dummy runtime instruction with the correct type. + return block.addTy(.alloc, tv.ty); + } + return sema.addConstant(tv.ty, tv.val); } |
