Sema: detect unneeded source locations earlier

This avoids a lot of work that just needs deferred cleanup anyway.
Crucially, also avoids use of undefined in `failWithNeededComptime`.
This commit is contained in:
Jacob Young
2023-11-10 22:23:56 -05:00
parent b5f89d681f
commit d93f1f3c72
2 changed files with 4 additions and 3 deletions

View File

@@ -1250,6 +1250,7 @@ pub const ErrorMsg = struct {
comptime format: []const u8,
args: anytype,
) !*ErrorMsg {
assert(src_loc.lazy != .unneeded);
const err_msg = try gpa.create(ErrorMsg);
errdefer gpa.destroy(err_msg);
err_msg.* = try ErrorMsg.init(gpa, src_loc, format, args);