mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 23:52:31 +00:00
Sema: fix unwrapping null when reporting error on member access
Closes #14399
This commit is contained in:
parent
5259d11e3b
commit
1f475de852
@ -4643,11 +4643,11 @@ fn failWithBadMemberAccess(
|
||||
.Enum => "enum",
|
||||
else => unreachable,
|
||||
};
|
||||
if (sema.mod.declIsRoot(agg_ty.getOwnerDecl())) {
|
||||
if (agg_ty.getOwnerDeclOrNull()) |some| if (sema.mod.declIsRoot(some)) {
|
||||
return sema.fail(block, field_src, "root struct of file '{}' has no member named '{s}'", .{
|
||||
agg_ty.fmt(sema.mod), field_name,
|
||||
});
|
||||
}
|
||||
};
|
||||
const msg = msg: {
|
||||
const msg = try sema.errMsg(block, field_src, "{s} '{}' has no member named '{s}'", .{
|
||||
kw_name, agg_ty.fmt(sema.mod), field_name,
|
||||
|
9
test/cases/compile_errors/bad_member_access_on_tuple.zig
Normal file
9
test/cases/compile_errors/bad_member_access_on_tuple.zig
Normal file
@ -0,0 +1,9 @@
|
||||
comptime {
|
||||
_ = @TypeOf(.{}).is_optional;
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:21: error: struct '@TypeOf(.{})' has no member named 'is_optional'
|
Loading…
Reference in New Issue
Block a user