From ca2b917686e227ccb8a27ff81f71c654099ff796 Mon Sep 17 00:00:00 2001 From: Evan Haas Date: Mon, 9 Oct 2023 16:35:05 -0700 Subject: [PATCH] Compilation: use an errdefer compile error for documentation instead of a comment --- src/Compilation.zig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index ce18eb3d..56a68920 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -1084,10 +1084,8 @@ pub fn addSourceFromOwnedBuffer(comp: *Compilation, buf: []u8, path: []const u8, const splice_locs = try splice_list.toOwnedSlice(); errdefer comp.gpa.free(splice_locs); - // Important: do not perform any possibly-failing operations in this function after this realloc. - // Otherwise errdefers in callers will possibly free the realloced slice using the original len - // instead of the new if (i != contents.len) contents = try comp.gpa.realloc(contents, i); + errdefer @compileError("errdefers in callers would possibly free the realloced slice using the original len"); var source = Source{ .id = source_id,