mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
stage1: make type names more unique
This commit is contained in:
parent
a318aeed9b
commit
5c3325588e
@ -3454,6 +3454,8 @@ test "aligned struct fields" {
|
||||
<li>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.</li>
|
||||
<li>Otherwise, the struct gets a name such as <code>(anonymous struct at file.zig:7:38)</code>.</li>
|
||||
<li>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.</li>
|
||||
</ul>
|
||||
{#code_begin|exe|struct_name#}
|
||||
const std = @import("std");
|
||||
|
||||
@ -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" {
|
||||
|
||||
@ -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<ScopeDecls *>(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) {
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user