aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-08-29 16:13:39 -0400
committerGitHub <noreply@github.com>2023-08-29 16:13:39 -0400
commit49075d20557994da4eb341e7431de38a6df2088b (patch)
tree6c56a36b2d6e96612dd8beff36f5852816c6782f /src/Module.zig
parent4635179857999a64ce8350c9b3cbe90cede9ea8c (diff)
parent7a251c4cb8082d080e23fb86fe20be6bf4c745a4 (diff)
downloadzig-49075d20557994da4eb341e7431de38a6df2088b.tar.gz
zig-49075d20557994da4eb341e7431de38a6df2088b.zip
Merge pull request #16969 from jacobly0/no-clear-ref-trace
Sema: refactor to use fewer catch expressions
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Module.zig b/src/Module.zig
index c13be489bb..ba76c16faf 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -1519,11 +1519,11 @@ pub const ErrorMsg = struct {
msg: []const u8,
notes: []ErrorMsg = &.{},
reference_trace: []Trace = &.{},
+ hidden_references: u32 = 0,
pub const Trace = struct {
- decl: InternPool.OptionalNullTerminatedString,
+ decl: InternPool.NullTerminatedString,
src_loc: SrcLoc,
- hidden: u32 = 0,
};
pub fn create(
@@ -4147,7 +4147,9 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
const address_space_src: LazySrcLoc = .{ .node_offset_var_decl_addrspace = 0 };
const ty_src: LazySrcLoc = .{ .node_offset_var_decl_ty = 0 };
const init_src: LazySrcLoc = .{ .node_offset_var_decl_init = 0 };
- const decl_tv = try sema.resolveInstValue(&block_scope, init_src, result_ref, "global variable initializer must be comptime-known");
+ const decl_tv = try sema.resolveInstValue(&block_scope, init_src, result_ref, .{
+ .needed_comptime_reason = "global variable initializer must be comptime-known",
+ });
// Note this resolves the type of the Decl, not the value; if this Decl
// is a struct, for example, this resolves `type` (which needs no resolution),
@@ -4257,7 +4259,9 @@ fn semaDecl(mod: *Module, decl_index: Decl.Index) !bool {
decl.@"linksection" = blk: {
const linksection_ref = decl.zirLinksectionRef(mod);
if (linksection_ref == .none) break :blk .none;
- const bytes = try sema.resolveConstString(&block_scope, section_src, linksection_ref, "linksection must be comptime-known");
+ const bytes = try sema.resolveConstString(&block_scope, section_src, linksection_ref, .{
+ .needed_comptime_reason = "linksection must be comptime-known",
+ });
if (mem.indexOfScalar(u8, bytes, 0) != null) {
return sema.fail(&block_scope, section_src, "linksection cannot contain null bytes", .{});
} else if (bytes.len == 0) {