commit b03d34429d059dc3f6056d7f780dc623c96523b4 (tree)
parent d15e8f8017758fb77dd6e839ef3f39b174522c5c
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sun, 16 Jul 2023 23:17:45 -0700
compiler: work around slightly different generics semantics
Both of these cases are interesting, were not covered by behavior tests,
and should be inspected carefully with regards to the language
specification.
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/Zir.zig b/src/Zir.zig
@@ -65,9 +65,13 @@ pub const ExtraIndex = enum(u32) {
_,
};
+fn ExtraData(comptime T: type) type {
+ return struct { data: T, end: usize };
+}
+
/// Returns the requested data, as well as the new index which is at the start of the
/// trailers for the object.
-pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, end: usize } {
+pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {
const fields = @typeInfo(T).Struct.fields;
var i: usize = index;
var result: T = undefined;
diff --git a/src/codegen/c.zig b/src/codegen/c.zig
@@ -1802,7 +1802,12 @@ pub const DeclGen = struct {
}
}
- fn writeCValueMember(dg: *DeclGen, writer: anytype, c_value: CValue, member: CValue) !void {
+ fn writeCValueMember(
+ dg: *DeclGen,
+ writer: anytype,
+ c_value: CValue,
+ member: CValue,
+ ) error{ OutOfMemory, AnalysisFail }!void {
try dg.writeCValue(writer, c_value);
try writer.writeByte('.');
try dg.writeCValue(writer, member);