diff --git a/doc/langref.html.in b/doc/langref.html.in
index abe83d2117..a7e8058a25 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -3454,6 +3454,8 @@ test "aligned struct fields" {
If the struct is in the {#syntax#}return{#endsyntax#} expression, it gets named after
the function it is returning from, with the parameter values serialized.
Otherwise, the struct gets a name such as (anonymous struct at file.zig:7:38).
+ If the struct is declared inside another struct, it gets named after both the parent
+ struct and the name inferred by the previous rules, separated by a dot.
{#code_begin|exe|struct_name#}
const std = @import("std");
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index b6594f193c..1f76d90452 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -2188,7 +2188,7 @@ test "enum" {
try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two});
// test very large enum to verify ct branch quota is large enough
- try expectFmt("enum: Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION});
+ try expectFmt("enum: os.windows.win32error.Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION});
}
test "non-exhaustive enum" {
diff --git a/src/stage1/astgen.cpp b/src/stage1/astgen.cpp
index ee59aef04a..35566e2143 100644
--- a/src/stage1/astgen.cpp
+++ b/src/stage1/astgen.cpp
@@ -7680,11 +7680,14 @@ Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name
if (!force_generic) {
if (exec != nullptr && exec->name != nullptr) {
- ZigType *import = get_scope_import(scope);
+ buf_resize(out_bare_name, 0);
+ if (scope->id == ScopeIdDecls) {
+ ScopeDecls *decls_scope = reinterpret_cast(scope);
+ append_namespace_qualification(codegen, out_bare_name, decls_scope->container_type);
+ }
+ buf_append_buf(out_bare_name, exec->name);
Buf *namespace_name = buf_alloc();
- append_namespace_qualification(codegen, namespace_name, import);
- buf_append_buf(namespace_name, exec->name);
- buf_init_from_buf(out_bare_name, exec->name);
+ buf_append_buf(namespace_name, out_bare_name);
return namespace_name;
}
if (exec != nullptr && exec->name_fn != nullptr) {
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 22e1e527b9..3a84617222 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -267,7 +267,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ });
\\}
, &[_][]const u8{
- "tmp.zig:3:31: error: expected type 'std.builtin.Type', found 'std.builtin.Int'",
+ "tmp.zig:3:31: error: expected type 'std.builtin.Type', found 'std.builtin.Type.Int'",
});
ctx.objErrStage1("indexing a undefined slice at comptime",
@@ -3461,7 +3461,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ _ = field;
\\}
, &[_][]const u8{
- "tmp.zig:9:51: error: values of type 'std.builtin.StructField' must be comptime known, but index value is runtime known",
+ "tmp.zig:9:51: error: values of type 'std.builtin.Type.StructField' must be comptime known, but index value is runtime known",
});
ctx.objErrStage1("compile log statement inside function which must be comptime evaluated",