diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-05-12 22:50:47 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-05-12 22:50:47 -0700 |
| commit | c102e1371088cf34aac28627a8523e66f0525098 (patch) | |
| tree | 786815a6ee8539a363a2c7f5268031d531f9f317 /src/Module.zig | |
| parent | a7aa3ca66c271bc6f2905e4c3f0dd78763584d5b (diff) | |
| download | zig-c102e1371088cf34aac28627a8523e66f0525098.tar.gz zig-c102e1371088cf34aac28627a8523e66f0525098.zip | |
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.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/Module.zig b/src/Module.zig index 39d226a2eb..1b80afd928 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2992,7 +2992,7 @@ fn semaDecl(mod: *Module, decl: *Decl) !bool { const body = zir.extra[extra.end..][0..extra.data.body_len]; const break_index = try sema.analyzeBody(&block_scope, body); const result_ref = zir_datas[break_index].@"break".operand; - const src = inst_data.src(); + const src: LazySrcLoc = .{ .node_offset = 0 }; const decl_tv = try sema.resolveInstConst(&block_scope, src, result_ref); const align_val = blk: { const align_ref = decl.zirAlignRef(); @@ -3729,7 +3729,7 @@ pub fn analyzeExport( if (mod.symbol_exports.get(symbol_name)) |other_export| { new_export.status = .failed_retryable; - try mod.failed_exports.ensureCapacity(mod.gpa, mod.failed_exports.items().len + 1); + try mod.failed_exports.ensureUnusedCapacity(mod.gpa, 1); const msg = try mod.errMsg( scope, src, |
