| author | |
| committer | |
| log | 5c3325588ef4e85e85cb201ad9328fe26bbb8dca |
| tree | 032f631f03759b73175e4f2ce8abbf7f91cc8a53 |
| parent | a318aeed9b8ccec453e9f15415ea3fd20cb13c8d |
4 files changed, 12 insertions(+), 7 deletions(-)
doc/langref.html.in+2| ... | @@ -3454,6 +3454,8 @@ test "aligned struct fields" { | ... | @@ -3454,6 +3454,8 @@ test "aligned struct fields" { |
| 3454 | <li>If the struct is in the {#syntax#}return{#endsyntax#} expression, it gets named after | 3454 | <li>If the struct is in the {#syntax#}return{#endsyntax#} expression, it gets named after |
| 3455 | the function it is returning from, with the parameter values serialized.</li> | 3455 | the function it is returning from, with the parameter values serialized.</li> |
| 3456 | <li>Otherwise, the struct gets a name such as <code>(anonymous struct at file.zig:7:38)</code>.</li> | 3456 | <li>Otherwise, the struct gets a name such as <code>(anonymous struct at file.zig:7:38)</code>.</li> |
| 3457 | <li>If the struct is declared inside another struct, it gets named after both the parent | ||
| 3458 | struct and the name inferred by the previous rules, separated by a dot.</li> | ||
| 3457 | </ul> | 3459 | </ul> |
| 3458 | {#code_begin|exe|struct_name#} | 3460 | {#code_begin|exe|struct_name#} |
| 3459 | const std = @import("std"); | 3461 | const std = @import("std"); |
lib/std/fmt.zig+1-1| ... | @@ -2188,7 +2188,7 @@ test "enum" { | ... | @@ -2188,7 +2188,7 @@ test "enum" { |
| 2188 | try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two}); | 2188 | try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two}); |
| 2189 | 2189 | ||
| 2190 | // test very large enum to verify ct branch quota is large enough | 2190 | // test very large enum to verify ct branch quota is large enough |
| 2191 | try expectFmt("enum: Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION}); | 2191 | try expectFmt("enum: os.windows.win32error.Win32Error.INVALID_FUNCTION\n", "enum: {}\n", .{std.os.windows.Win32Error.INVALID_FUNCTION}); |
| 2192 | } | 2192 | } |
| 2193 | 2193 | ||
| 2194 | test "non-exhaustive enum" { | 2194 | test "non-exhaustive enum" { |
src/stage1/astgen.cpp+7-4| ... | @@ -7680,11 +7680,14 @@ Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name | ... | @@ -7680,11 +7680,14 @@ Buf *get_anon_type_name(CodeGen *codegen, Stage1Zir *exec, const char *kind_name |
| 7680 | 7680 | ||
| 7681 | if (!force_generic) { | 7681 | if (!force_generic) { |
| 7682 | if (exec != nullptr && exec->name != nullptr) { | 7682 | if (exec != nullptr && exec->name != nullptr) { |
| 7683 | ZigType *import = get_scope_import(scope); | 7683 | buf_resize(out_bare_name, 0); |
| 7684 | if (scope->id == ScopeIdDecls) { | ||
| 7685 | ScopeDecls *decls_scope = reinterpret_cast<ScopeDecls *>(scope); | ||
| 7686 | append_namespace_qualification(codegen, out_bare_name, decls_scope->container_type); | ||
| 7687 | } | ||
| 7688 | buf_append_buf(out_bare_name, exec->name); | ||
| 7684 | Buf *namespace_name = buf_alloc(); | 7689 | Buf *namespace_name = buf_alloc(); |
| 7685 | append_namespace_qualification(codegen, namespace_name, import); | 7690 | buf_append_buf(namespace_name, out_bare_name); |
| 7686 | buf_append_buf(namespace_name, exec->name); | ||
| 7687 | buf_init_from_buf(out_bare_name, exec->name); | ||
| 7688 | return namespace_name; | 7691 | return namespace_name; |
| 7689 | } | 7692 | } |
| 7690 | if (exec != nullptr && exec->name_fn != nullptr) { | 7693 | if (exec != nullptr && exec->name_fn != nullptr) { |
test/compile_errors.zig+2-2| ... | @@ -267,7 +267,7 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -267,7 +267,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 267 | \\ }); | 267 | \\ }); |
| 268 | \\} | 268 | \\} |
| 269 | , &[_][]const u8{ | 269 | , &[_][]const u8{ |
| 270 | "tmp.zig:3:31: error: expected type 'std.builtin.Type', found 'std.builtin.Int'", | 270 | "tmp.zig:3:31: error: expected type 'std.builtin.Type', found 'std.builtin.Type.Int'", |
| 271 | }); | 271 | }); |
| 272 | 272 | ||
| 273 | ctx.objErrStage1("indexing a undefined slice at comptime", | 273 | ctx.objErrStage1("indexing a undefined slice at comptime", |
| ... | @@ -3461,7 +3461,7 @@ pub fn addCases(ctx: *TestContext) !void { | ... | @@ -3461,7 +3461,7 @@ pub fn addCases(ctx: *TestContext) !void { |
| 3461 | \\ _ = field; | 3461 | \\ _ = field; |
| 3462 | \\} | 3462 | \\} |
| 3463 | , &[_][]const u8{ | 3463 | , &[_][]const u8{ |
| 3464 | "tmp.zig:9:51: error: values of type 'std.builtin.StructField' must be comptime known, but index value is runtime known", | 3464 | "tmp.zig:9:51: error: values of type 'std.builtin.Type.StructField' must be comptime known, but index value is runtime known", |
| 3465 | }); | 3465 | }); |
| 3466 | 3466 | ||
| 3467 | ctx.objErrStage1("compile log statement inside function which must be comptime evaluated", | 3467 | ctx.objErrStage1("compile log statement inside function which must be comptime evaluated", |