aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-08-28 15:15:46 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-08-28 16:04:38 -0700
commit4bb5d17edc85eac74626224810d6a44a3c73cca3 (patch)
tree1464b91474019c5c047ba66bae7197fa7e6d73bf /src/Module.zig
parent05cf44933d753f7a5a53ab289ea60fd43761de57 (diff)
downloadzig-4bb5d17edc85eac74626224810d6a44a3c73cca3.tar.gz
zig-4bb5d17edc85eac74626224810d6a44a3c73cca3.zip
AstGen: pre-scan all decls in a namespace
Also: * improve the "ambiguous reference" error by swapping the order of "declared here" and "also declared here" notes. * improve the "not accessible from inner function" error: - point out that it has to do with the thing being mutable - eliminate the incorrect association with it being a function - note where it crosses a namespace boundary * struct field types are evaluated in a context that has the struct namespace visible. Likewise with align expressions, linksection expressions, enum tag values, and union/enum tag argument expressions. Closes #9194 Closes #9622
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index 4ed39c9954..77f880b492 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -2648,7 +2648,10 @@ pub fn astGenFile(mod: *Module, file: *Scope.File) !void {
undefined;
defer if (data_has_safety_tag) gpa.free(safety_buffer);
const data_ptr = if (data_has_safety_tag)
- @ptrCast([*]const u8, safety_buffer.ptr)
+ if (file.zir.instructions.len == 0)
+ @as([*]const u8, undefined)
+ else
+ @ptrCast([*]const u8, safety_buffer.ptr)
else
@ptrCast([*]const u8, file.zir.instructions.items(.data).ptr);
if (data_has_safety_tag) {