aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2021-08-26 03:29:31 +0200
committerRobin Voetter <robin@voetter.nl>2021-09-20 02:29:03 +0200
commit0e6dc64a6fa173ae92197f692cf907fdc8bbf811 (patch)
treed976bc3a1d418e796b40d80a8eb11f8818f0d461 /src/Sema.zig
parentcd9f6001af407a6961281cbe9c658cfe94b81ecb (diff)
downloadzig-0e6dc64a6fa173ae92197f692cf907fdc8bbf811.tar.gz
zig-0e6dc64a6fa173ae92197f692cf907fdc8bbf811.zip
Address Spaces: Return proper address space for &x[y]
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 14f43ccf9e..a782cb2472 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -9035,10 +9035,13 @@ fn elemPtrArray(
) CompileError!Air.Inst.Ref {
const array_ptr_ty = sema.typeOf(array_ptr);
const pointee_type = array_ptr_ty.elemType().elemType();
- const result_ty = if (array_ptr_ty.ptrIsMutable())
- try Type.Tag.single_mut_pointer.create(sema.arena, pointee_type)
- else
- try Type.Tag.single_const_pointer.create(sema.arena, pointee_type);
+ const result_ty = try Module.simplePtrTypeWithAddressSpace(
+ sema.arena,
+ pointee_type,
+ array_ptr_ty.ptrIsMutable(),
+ .One,
+ array_ptr_ty.ptrAddressSpace(),
+ );
if (try sema.resolveDefinedValue(block, src, array_ptr)) |array_ptr_val| {
if (try sema.resolveDefinedValue(block, elem_index_src, elem_index)) |index_val| {