aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-09-23 13:03:03 -0400
committerkcbanner <kcbanner@gmail.com>2023-09-23 13:05:04 -0400
commitf2a24b48e1221a8954ddf16e9070e1470ee13e8d (patch)
tree65443a1d67bb03be28927643462f92568fedbbc0 /src/InternPool.zig
parent2fddd767ba20374e7677003c101e60f470c3804c (diff)
downloadzig-f2a24b48e1221a8954ddf16e9070e1470ee13e8d.tar.gz
zig-f2a24b48e1221a8954ddf16e9070e1470ee13e8d.zip
sema: rework the comptime representation of comptime unions
When the tag is not known, it's set to `.none`. In this case, the value is either an array of bytes (for extern unions) or an integer (for packed unions).
Diffstat (limited to 'src/InternPool.zig')
-rw-r--r--src/InternPool.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig
index 79d4127787..7c8702a716 100644
--- a/src/InternPool.zig
+++ b/src/InternPool.zig
@@ -1105,7 +1105,10 @@ pub const Key = union(enum) {
pub const Union = extern struct {
/// This is the union type; not the field type.
ty: Index,
- /// Indicates the active field.
+ /// Indicates the active field. This could be `none`, which indicates the tag is not known. `none` is only a valid value for extern and packed unions.
+ /// In those cases, the type of `val` is:
+ /// extern: a u8 array of the same byte length as the union
+ /// packed: an unsigned integer with the same bit size as the union
tag: Index,
/// The value of the active field.
val: Index,
@@ -5130,7 +5133,6 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index {
.un => |un| {
assert(un.ty != .none);
- assert(un.tag != .none);
assert(un.val != .none);
ip.items.appendAssumeCapacity(.{
.tag = .union_value,