From 9d4cfd9048d71d7519d759b9849914ce154d1877 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 27 Feb 2022 16:51:33 -0700 Subject: Sema: resolve necessary information ahead of time Do the fallible logic in Sema where we have access to error reporting mechanisms, rather than in Type/Value. We can't just do the best guess when resolving queries of "is this type comptime only?" or "what is the ABI alignment of this field?". The result needs to be accurate. So we need to keep the assertions that the data is available active, and instead compute the necessary information before such functions get called. Unfortunately we are stuck with two versions of such functions because the various backends need to be able to ask such queries of Types and Values while assuming the result has already been computed and validated by Sema. --- src/Module.zig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index 9bc61aa708..8fed3138e7 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -1125,6 +1125,8 @@ pub const Union = struct { abi_align: Value, /// Returns the field alignment, assuming the union is not packed. + /// Keep implementation in sync with `Sema.unionFieldAlignment`. + /// Prefer to call that function instead of this one during Sema. pub fn normalAlignment(field: Field, target: Target) u32 { if (field.abi_align.tag() == .abi_align_default) { return field.ty.abiAlignment(target); -- cgit v1.2.3