Sema: add missing failWithBadMemberAccess to zirExport

The assumption that AstGen would error only holds when exporting
a identifier not a namespace member.
This commit is contained in:
Veikka Tuominen 2022-11-29 18:59:58 +02:00
parent 4b0ef6a409
commit b2b1d421c3
2 changed files with 12 additions and 1 deletions

View File

@ -5391,7 +5391,8 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
const container_namespace = container_ty.getNamespace().?;
const maybe_index = try sema.lookupInNamespace(block, operand_src, container_namespace, decl_name, false);
break :index_blk maybe_index.?; // AstGen would produce error in case of unidentified name
break :index_blk maybe_index orelse
return sema.failWithBadMemberAccess(block, container_ty, operand_src, decl_name);
} else try sema.lookupIdentifier(block, operand_src, decl_name);
const options = sema.resolveExportOptions(block, .unneeded, extra.options) catch |err| switch (err) {
error.NeededSourceLocation => {

View File

@ -0,0 +1,10 @@
const S = struct {};
comptime {
@export(S.foo, .{ .name = "foo" });
}
// error
// target=native
//
// :3:14: error: struct 'tmp.S' has no member named 'foo'
// :1:11: note: struct declared here