mirror of
https://github.com/ziglang/zig.git
synced 2025-02-11 15:10:20 +00:00
Sema: handle tuple and anon_struct in resolveTypeFully
This commit is contained in:
parent
c1eb6c30e8
commit
002df65b6e
@ -2111,7 +2111,6 @@ test "slice" {
|
||||
}
|
||||
|
||||
test "escape non-printable" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
try expectFmt("abc", "{s}", .{fmtSliceEscapeLower("abc")});
|
||||
try expectFmt("ab\\xffc", "{s}", .{fmtSliceEscapeLower("ab\xffc")});
|
||||
try expectFmt("ab\\xFFc", "{s}", .{fmtSliceEscapeUpper("ab\xffc")});
|
||||
@ -2148,7 +2147,6 @@ test "cstr" {
|
||||
}
|
||||
|
||||
test "filesize" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeDec(42)});
|
||||
try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeBin(42)});
|
||||
try expectFmt("file size: 63MB\n", "file size: {}\n", .{fmtIntSizeDec(63 * 1000 * 1000)});
|
||||
@ -2448,7 +2446,6 @@ test "struct.zero-size" {
|
||||
}
|
||||
|
||||
test "bytes.hex" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
const some_bytes = "\xCA\xFE\xBA\xBE";
|
||||
try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{fmtSliceHexLower(some_bytes)});
|
||||
try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{fmtSliceHexUpper(some_bytes)});
|
||||
@ -2480,7 +2477,6 @@ pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 {
|
||||
}
|
||||
|
||||
test "hexToBytes" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
var buf: [32]u8 = undefined;
|
||||
try expectFmt("90" ** 32, "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "90" ** 32))});
|
||||
try expectFmt("ABCD", "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "ABCD"))});
|
||||
|
@ -804,7 +804,6 @@ pub fn fmtUtf16le(utf16le: []const u16) std.fmt.Formatter(formatUtf16le) {
|
||||
}
|
||||
|
||||
test "fmtUtf16le" {
|
||||
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
|
||||
const expectFmt = std.testing.expectFmt;
|
||||
try expectFmt("", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral(""))});
|
||||
try expectFmt("foo", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral("foo"))});
|
||||
|
14
src/Sema.zig
14
src/Sema.zig
@ -23328,7 +23328,17 @@ pub fn resolveTypeFully(
|
||||
const child_ty = try sema.resolveTypeFields(block, src, ty.childType());
|
||||
return resolveTypeFully(sema, block, src, child_ty);
|
||||
},
|
||||
.Struct => return resolveStructFully(sema, block, src, ty),
|
||||
.Struct => switch (ty.tag()) {
|
||||
.@"struct" => return resolveStructFully(sema, block, src, ty),
|
||||
.tuple, .anon_struct => {
|
||||
const tuple = ty.tupleFields();
|
||||
|
||||
for (tuple.types) |field_ty| {
|
||||
try sema.resolveTypeFully(block, src, field_ty);
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
},
|
||||
.Union => return resolveUnionFully(sema, block, src, ty),
|
||||
.Array => return resolveTypeFully(sema, block, src, ty.childType()),
|
||||
.Optional => {
|
||||
@ -23363,7 +23373,7 @@ fn resolveStructFully(
|
||||
try resolveStructLayout(sema, block, src, ty);
|
||||
|
||||
const resolved_ty = try sema.resolveTypeFields(block, src, ty);
|
||||
const payload = resolved_ty.castTag(.@"struct") orelse return;
|
||||
const payload = resolved_ty.castTag(.@"struct").?;
|
||||
const struct_obj = payload.data;
|
||||
|
||||
switch (struct_obj.status) {
|
||||
|
Loading…
Reference in New Issue
Block a user