authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-12 22:50:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-12 22:50:47-07:00
logc102e1371088cf34aac28627a8523e66f0525098
tree786815a6ee8539a363a2c7f5268031d531f9f317
parenta7aa3ca66c271bc6f2905e4c3f0dd78763584d5b

stage2: fix source location of Decl compile errors

In `Module.semaDecl`, the source location being used was double-relative to the `Decl`, causing a crash when trying to compute byte offset for the compile error. Change the source location to node_offset = 0 since the scope being used makes the source location relative to the Decl, which already has the source node index populated.

1 files changed, 2 insertions(+), 2 deletions(-)

src/Module.zig+2-2
......@@ -2992,7 +2992,7 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool {
29922992 const body = zir.extra[extra.end..][0..extra.data.body_len];
29932993 const break_index = try sema.analyzeBody(&block_scope, body);
29942994 const result_ref = zir_datas[break_index].@"break".operand;
2995 const src = inst_data.src();
2995 const src: LazySrcLoc = .{ .node_offset = 0 };
29962996 const decl_tv = try sema.resolveInstConst(&block_scope, src, result_ref);
29972997 const align_val = blk: {
29982998 const align_ref = decl.zirAlignRef();
......@@ -3729,7 +3729,7 @@ pub fn analyzeExport(
37293729
37303730 if (mod.symbol_exports.get(symbol_name)) |other_export| {
37313731 new_export.status = .failed_retryable;
3732 try mod.failed_exports.ensureCapacity(mod.gpa, mod.failed_exports.items().len + 1);
3732 try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1);
37333733 const msg = try mod.errMsg(
37343734 scope,
37353735 src,