aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-07 22:25:50 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:42:30 -0700
commit8587e510e46f98e321fbad30bb235e5eed33f1ba (patch)
tree5eb31158113d74473f3f895ec76eaaab1cc59efd /src/type.zig
parent3116477dcc5e85d8fe7b2be2f332796e1425f956 (diff)
downloadzig-8587e510e46f98e321fbad30bb235e5eed33f1ba.tar.gz
zig-8587e510e46f98e321fbad30bb235e5eed33f1ba.zip
stage2: more InternPool related fixes
* make Sema.zirPtrType coerce the sentinel value against the element type * fix lazyAbiAlignment wrong result type * typeHasOnePossibleValue no longer tries to create interned enum tag value with integer zero, instead uses enum_field_index * Type.ptr avoids trying to store typed null values into the intern pool
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/type.zig b/src/type.zig
index d784a25eb3..b088f58f0a 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2090,10 +2090,11 @@ pub const Type = struct {
}
/// May capture a reference to `ty`.
+ /// Returned value has type `comptime_int`.
pub fn lazyAbiAlignment(ty: Type, mod: *Module, arena: Allocator) !Value {
switch (try ty.abiAlignmentAdvanced(mod, .{ .lazy = arena })) {
.val => |val| return val,
- .scalar => |x| return mod.intValue(ty, x),
+ .scalar => |x| return mod.intValue(Type.comptime_int, x),
}
}
@@ -5441,9 +5442,16 @@ pub const Type = struct {
}
}
- if (d.pointee_type.ip_index != .none and
- (d.sentinel == null or d.sentinel.?.ip_index != .none))
- {
+ ip: {
+ if (d.pointee_type.ip_index == .none) break :ip;
+
+ if (d.sentinel) |s| {
+ switch (s.ip_index) {
+ .none, .null_value => break :ip,
+ else => {},
+ }
+ }
+
return mod.ptrType(.{
.elem_type = d.pointee_type.ip_index,
.sentinel = if (d.sentinel) |s| s.ip_index else .none,