authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-09 15:36:18+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-06-11 11:02:56+03:00
log002df65b6ec55684d6bc6790ae7b0c0f4abb1375
treece5687738de8b663c123a5d59b9d84e6f283758b
parentc1eb6c30e84b0b161b634f7410088f44c80caa90

Sema: handle tuple and anon_struct in resolveTypeFully


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

lib/std/fmt.zig-4
...@@ -2111,7 +2111,6 @@ test "slice" {...@@ -2111,7 +2111,6 @@ test "slice" {
2111}2111}
21122112
2113test "escape non-printable" {2113test "escape non-printable" {
2114 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
2115 try expectFmt("abc", "{s}", .{fmtSliceEscapeLower("abc")});2114 try expectFmt("abc", "{s}", .{fmtSliceEscapeLower("abc")});
2116 try expectFmt("ab\\xffc", "{s}", .{fmtSliceEscapeLower("ab\xffc")});2115 try expectFmt("ab\\xffc", "{s}", .{fmtSliceEscapeLower("ab\xffc")});
2117 try expectFmt("ab\\xFFc", "{s}", .{fmtSliceEscapeUpper("ab\xffc")});2116 try expectFmt("ab\\xFFc", "{s}", .{fmtSliceEscapeUpper("ab\xffc")});
...@@ -2148,7 +2147,6 @@ test "cstr" {...@@ -2148,7 +2147,6 @@ test "cstr" {
2148}2147}
21492148
2150test "filesize" {2149test "filesize" {
2151 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
2152 try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeDec(42)});2150 try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeDec(42)});
2153 try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeBin(42)});2151 try expectFmt("file size: 42B\n", "file size: {}\n", .{fmtIntSizeBin(42)});
2154 try expectFmt("file size: 63MB\n", "file size: {}\n", .{fmtIntSizeDec(63 * 1000 * 1000)});2152 try expectFmt("file size: 63MB\n", "file size: {}\n", .{fmtIntSizeDec(63 * 1000 * 1000)});
...@@ -2448,7 +2446,6 @@ test "struct.zero-size" {...@@ -2448,7 +2446,6 @@ test "struct.zero-size" {
2448}2446}
24492447
2450test "bytes.hex" {2448test "bytes.hex" {
2451 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
2452 const some_bytes = "\xCA\xFE\xBA\xBE";2449 const some_bytes = "\xCA\xFE\xBA\xBE";
2453 try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{fmtSliceHexLower(some_bytes)});2450 try expectFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{fmtSliceHexLower(some_bytes)});
2454 try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{fmtSliceHexUpper(some_bytes)});2451 try expectFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{fmtSliceHexUpper(some_bytes)});
...@@ -2480,7 +2477,6 @@ pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 {...@@ -2480,7 +2477,6 @@ pub fn hexToBytes(out: []u8, input: []const u8) ![]u8 {
2480}2477}
24812478
2482test "hexToBytes" {2479test "hexToBytes" {
2483 if (builtin.zig_backend != .stage1) return error.SkipZigTest;
2484 var buf: [32]u8 = undefined;2480 var buf: [32]u8 = undefined;
2485 try expectFmt("90" ** 32, "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "90" ** 32))});2481 try expectFmt("90" ** 32, "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "90" ** 32))});
2486 try expectFmt("ABCD", "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "ABCD"))});2482 try expectFmt("ABCD", "{s}", .{fmtSliceHexUpper(try hexToBytes(&buf, "ABCD"))});
lib/std/unicode.zig-1
...@@ -804,7 +804,6 @@ pub fn fmtUtf16le(utf16le: []const u16) std.fmt.Formatter(formatUtf16le) {...@@ -804,7 +804,6 @@ pub fn fmtUtf16le(utf16le: []const u16) std.fmt.Formatter(formatUtf16le) {
804}804}
805805
806test "fmtUtf16le" {806test "fmtUtf16le" {
807 if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest;
808 const expectFmt = std.testing.expectFmt;807 const expectFmt = std.testing.expectFmt;
809 try expectFmt("", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral(""))});808 try expectFmt("", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral(""))});
810 try expectFmt("foo", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral("foo"))});809 try expectFmt("foo", "{}", .{fmtUtf16le(utf8ToUtf16LeStringLiteral("foo"))});
src/Sema.zig+12-2
...@@ -23328,7 +23328,17 @@ pub fn resolveTypeFully(...@@ -23328,7 +23328,17 @@ pub fn resolveTypeFully(
23328 const child_ty = try sema.resolveTypeFields(block, src, ty.childType());23328 const child_ty = try sema.resolveTypeFields(block, src, ty.childType());
23329 return resolveTypeFully(sema, block, src, child_ty);23329 return resolveTypeFully(sema, block, src, child_ty);
23330 },23330 },
23331 .Struct => return resolveStructFully(sema, block, src, ty),23331 .Struct => switch (ty.tag()) {
23332 .@"struct" => return resolveStructFully(sema, block, src, ty),
23333 .tuple, .anon_struct => {
23334 const tuple = ty.tupleFields();
23335
23336 for (tuple.types) |field_ty| {
23337 try sema.resolveTypeFully(block, src, field_ty);
23338 }
23339 },
23340 else => {},
23341 },
23332 .Union => return resolveUnionFully(sema, block, src, ty),23342 .Union => return resolveUnionFully(sema, block, src, ty),
23333 .Array => return resolveTypeFully(sema, block, src, ty.childType()),23343 .Array => return resolveTypeFully(sema, block, src, ty.childType()),
23334 .Optional => {23344 .Optional => {
...@@ -23363,7 +23373,7 @@ fn resolveStructFully(...@@ -23363,7 +23373,7 @@ fn resolveStructFully(
23363 try resolveStructLayout(sema, block, src, ty);23373 try resolveStructLayout(sema, block, src, ty);
2336423374
23365 const resolved_ty = try sema.resolveTypeFields(block, src, ty);23375 const resolved_ty = try sema.resolveTypeFields(block, src, ty);
23366 const payload = resolved_ty.castTag(.@"struct") orelse return;23376 const payload = resolved_ty.castTag(.@"struct").?;
23367 const struct_obj = payload.data;23377 const struct_obj = payload.data;
2336823378
23369 switch (struct_obj.status) {23379 switch (struct_obj.status) {