authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-20 17:08:01-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-20 17:08:01-07:00
logf54b2e2da6a9ef72a37fae064dc04d951c686298
treeb492067d1ad90ed5313d3d1916753099bb5cdc10
parent6a053ffcc85ce3f2b598be08e5d0587c930b4358

add missing mutability check in simplePtrType


1 files changed, 2 insertions(+), 2 deletions(-)

src-self-hosted/Module.zig+2-2
......@@ -2487,7 +2487,7 @@ pub fn analyzeDeclRef(self: *Module, scope: *Scope, src: usize, decl: *Decl) Inn
24872487fn analyzeVarRef(self: *Module, scope: *Scope, src: usize, tv: TypedValue) InnerError!*Inst {
24882488 const variable = tv.val.cast(Value.Payload.Variable).?.variable;
24892489
2490 const ty = try self.singlePtrType(scope, src, variable.is_mutable, tv.ty, .One);
2490 const ty = try self.simplePtrType(scope, src, tv.ty, variable.is_mutable, .One);
24912491 if (!variable.is_mutable and !variable.is_extern) {
24922492 const val_payload = try scope.arena().create(Value.Payload.RefVal);
24932493 val_payload.* = .{ .val = variable.init };
......@@ -3191,7 +3191,7 @@ pub fn floatSub(self: *Module, scope: *Scope, float_type: Type, src: usize, lhs:
31913191}
31923192
31933193pub fn simplePtrType(self: *Module, scope: *Scope, src: usize, elem_ty: Type, mutable: bool, size: std.builtin.TypeInfo.Pointer.Size) Allocator.Error!Type {
3194 if (size == .Slice and elem_ty.eql(Type.initTag(.u8))) {
3194 if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) {
31953195 return Type.initTag(.const_slice_u8);
31963196 }
31973197 // TODO stage1 type inference bug