lang 2.1: Pack as a type-system value
Add a `pack` variant to IR `TypeInfo` — an ordered, interned sequence of
per-position element types (`PackInfo { elements: []const TypeId }`) — with
constructor (`packType`), structural equality + hashing, and a `pack(T0, …)`
printer. A pack is comptime-only: it lowers to flat positional args before
codegen and has no runtime layout, so `sizeOf` and `toLLVMType` bail loudly
rather than inventing a size. 5 unit tests (N=0/1/3, dedup, order/arity
distinctness, distinct-from-tuple, printer).
Also: give TypeTable an arena for the slices its constructors dupe (freed at
deinit), and add the missing `usize`/`isize` arms to `sizeOf` (a latent
non-exhaustive switch) so types.test.zig compiles and runs leak-free.
This commit is contained in:
@@ -4286,6 +4286,9 @@ pub const LLVMEmitter = struct {
|
||||
return self.cached_ptr;
|
||||
},
|
||||
.usize, .isize => if (self.target_config.isWasm32()) self.cached_i32 else self.cached_i64,
|
||||
// Comptime-only: a pack is expanded to flat positional args before
|
||||
// codegen, so it must never reach LLVM type emission.
|
||||
.pack => @panic("pack type has no LLVM representation (comptime-only)"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user