aboutsummaryrefslogtreecommitdiff
path: root/src/Sema.zig
diff options
context:
space:
mode:
authorjacob gw <jacoblevgw@gmail.com>2021-04-09 00:09:21 -0400
committerAndrew Kelley <andrew@ziglang.org>2021-04-09 10:05:15 -0700
commitafe5862111034ea4100b0eea5971e181d70ffc39 (patch)
tree454fcaa87f6f3c50ccac5c038dd5e6e6236fa54a /src/Sema.zig
parentc6791d87d4f49598aab54064df683fc86e97dbd9 (diff)
downloadzig-afe5862111034ea4100b0eea5971e181d70ffc39.tar.gz
zig-afe5862111034ea4100b0eea5971e181d70ffc39.zip
stage2: add error for private decls accessed from other files
Diffstat (limited to 'src/Sema.zig')
-rw-r--r--src/Sema.zig6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 09c38f3a65..1b6941806e 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -4708,7 +4708,8 @@ fn namedFieldPtr(
.Struct, .Opaque, .Union => {
if (child_type.getContainerScope()) |container_scope| {
if (mod.lookupDeclName(&container_scope.base, field_name)) |decl| {
- // TODO if !decl.is_pub and inDifferentFiles() "{} is private"
+ if (!decl.is_pub and !(decl.container.file_scope == block.base.namespace().file_scope))
+ return mod.fail(&block.base, src, "'{s}' is private", .{field_name});
return sema.analyzeDeclRef(block, src, decl);
}
@@ -4736,7 +4737,8 @@ fn namedFieldPtr(
.Enum => {
if (child_type.getContainerScope()) |container_scope| {
if (mod.lookupDeclName(&container_scope.base, field_name)) |decl| {
- // TODO if !decl.is_pub and inDifferentFiles() "{} is private"
+ if (!decl.is_pub and !(decl.container.file_scope == block.base.namespace().file_scope))
+ return mod.fail(&block.base, src, "'{s}' is private", .{field_name});
return sema.analyzeDeclRef(block, src, decl);
}
}