Commit 7217148edf

Veikka Tuominen <git@vexu.eu>
2022-03-27 20:05:42
Value: hash lazy_align
1 parent bda7993
Changed files (2)
src/value.zig
@@ -461,7 +461,7 @@ pub const Value = extern union {
             => unreachable,
 
             .ty, .lazy_align => {
-                const payload = self.castTag(.ty).?;
+                const payload = self.cast(Payload.Ty).?;
                 const new_payload = try arena.create(Payload.Ty);
                 new_payload.* = .{
                     .base = payload.base,
@@ -718,7 +718,7 @@ pub const Value = extern union {
             .lazy_align => {
                 try out_stream.writeAll("@alignOf(");
                 try val.castTag(.lazy_align).?.data.dump("", options, out_stream);
-                try out_stream.writeAll(")");
+                return try out_stream.writeAll(")");
             },
             .int_type => {
                 const int_type = val.castTag(.int_type).?.data;
@@ -2478,6 +2478,13 @@ pub const Value = extern union {
             .the_only_possible_value,
             => return hashInt(ptr_val, hasher, target),
 
+            .lazy_align => {
+                // Bit weird to have this here but this function is also called
+                // on integers.
+                const ty = ptr_val.castTag(.lazy_align).?.data;
+                ty.hashWithHasher(hasher, target);
+            },
+
             else => unreachable,
         }
     }
build.zig
@@ -613,7 +613,8 @@ fn addCxxKnownPath(
         ctx.cxx_compiler,
         b.fmt("-print-file-name={s}", .{objname}),
     });
-    const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?;
+    var tokenizer = mem.tokenize(u8, path_padded, "\r\n");
+    const path_unpadded = tokenizer.next().?;
     if (mem.eql(u8, path_unpadded, objname)) {
         if (errtxt) |msg| {
             std.debug.print("{s}", .{msg});