diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-06-04 12:20:28 +0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-06 13:11:50 -0700 |
| commit | a040ccb42f1b34ba612c975b7030ccdcbb3f8086 (patch) | |
| tree | b25a7f6f1bdf32e234e928914f14bfd36c5de97b /src | |
| parent | 33826a6a2e035d2a2be65314ed80a6b7abaf7f12 (diff) | |
| download | zig-a040ccb42f1b34ba612c975b7030ccdcbb3f8086.tar.gz zig-a040ccb42f1b34ba612c975b7030ccdcbb3f8086.zip | |
Sema: fix coerce result ptr outside of functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 593b299833..5669b4811a 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -1875,7 +1875,7 @@ fn zirCoerceResultPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE const dummy_ptr = try trash_block.addTy(.alloc, sema.typeOf(ptr)); const dummy_operand = try trash_block.addBitCast(pointee_ty, .void_value); - try sema.storePtr(&trash_block, src, dummy_ptr, dummy_operand); + try sema.storePtr2(&trash_block, src, dummy_ptr, src, dummy_operand, src, .bitcast); { const air_tags = sema.air_instructions.items(.tag); @@ -20187,6 +20187,13 @@ fn storePtr2( // TODO handle if the element type requires comptime + if (air_tag == .bitcast) { + // `air_tag == .bitcast` is used as a special case for `zirCoerceResultPtr` + // to avoid calling `requireRuntimeBlock` for the dummy block. + _ = try block.addBinOp(.store, ptr, operand); + return; + } + try sema.requireRuntimeBlock(block, runtime_src); try sema.queueFullTypeResolution(elem_ty); _ = try block.addBinOp(air_tag, ptr, operand); |
