diff options
| author | Robin Voetter <robin@voetter.nl> | 2021-08-25 02:58:19 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-08-27 18:53:03 -0400 |
| commit | 3aa533519da073695a56a56159b7ea3c487fb1b2 (patch) | |
| tree | 254305dadbd443aca65aa4e38ce9e187cad2b2ed /src/Sema.zig | |
| parent | 3a3704be05adcf929353e836222399885d1d99fb (diff) | |
| download | zig-3aa533519da073695a56a56159b7ea3c487fb1b2.tar.gz zig-3aa533519da073695a56a56159b7ea3c487fb1b2.zip | |
Store to mutable pointer in analyzeRef
This function previously attempted to store a value to an immutable
pointer, after which storePtr would yield an error.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index a11bdec66d..90505c6806 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -8818,9 +8818,12 @@ fn analyzeRef( try sema.requireRuntimeBlock(block, src); const ptr_type = try Module.simplePtrType(sema.arena, operand_ty, false, .One); - const alloc = try block.addTy(.alloc, ptr_type); + const mut_ptr_type = try Module.simplePtrType(sema.arena, operand_ty, true, .One); + const alloc = try block.addTy(.alloc, mut_ptr_type); try sema.storePtr(block, src, alloc, operand); - return alloc; + + // TODO: Replace with sema.coerce when that supports adding pointer constness. + return sema.bitcast(block, ptr_type, alloc, src); } fn analyzeLoad( |
