authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2022-03-19 12:26:21+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-19 19:40:46-04:00
log5c3325588ef4e85e85cb201ad9328fe26bbb8dca
tree032f631f03759b73175e4f2ce8abbf7f91cc8a53
parenta318aeed9b8ccec453e9f15415ea3fd20cb13c8d

stage1: make type names more unique


4 files changed, 12 insertions(+), 7 deletions(-)

doc/langref.html.in+2
......@@ -3454,6 +3454,8 @@ test "aligned struct fields" {
34543454 <li>If the struct is in the {#syntax#}return{#endsyntax#} expression, it gets named after
34553455 the function it is returning from, with the parameter values serialized.</li>
34563456 <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>
34573459 </ul>
34583460 {#code_begin|exe|struct_name#}
34593461const std = @import("std");
lib/std/fmt.zig+1-1
......@@ -2188,7 +2188,7 @@ test "enum" {
21882188 try expectFmt("enum: Enum.Two\n", "enum: {X}\n", .{Enum.Two});
21892189
21902190 // 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});
21922192}
21932193
21942194test "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
76807680
76817681 if (!force_generic) {
76827682 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);
76847689 Buf *namespace_name = buf_alloc();
7685 append_namespace_qualification(codegen, namespace_name, import);
7686 buf_append_buf(namespace_name, exec->name);
7687 buf_init_from_buf(out_bare_name, exec->name);
7690 buf_append_buf(namespace_name, out_bare_name);
76887691 return namespace_name;
76897692 }
76907693 if (exec != nullptr && exec->name_fn != nullptr) {
test/compile_errors.zig+2-2
......@@ -267,7 +267,7 @@ pub fn addCases(ctx: *TestContext) !void {
267267 \\ });
268268 \\}
269269 , &[_][]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'",
271271 });
272272
273273 ctx.objErrStage1("indexing a undefined slice at comptime",
......@@ -3461,7 +3461,7 @@ pub fn addCases(ctx: *TestContext) !void {
34613461 \\ _ = field;
34623462 \\}
34633463 , &[_][]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",
34653465 });
34663466
34673467 ctx.objErrStage1("compile log statement inside function which must be comptime evaluated",