authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-09-04 22:49:14+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-09-04 22:49:14+03:00
log09c861b829480be525a787e54117c108705256e6
tree8bb830533e368e68446ce1feb10275802beb6db3
parent1df0f3ac24f090e8c58cd4cd6e752110cc5262b8
signature Commit is signed but in an unrecognized format.

update rest of tests


4 files changed, 19 insertions(+), 28 deletions(-)

doc/langref.html.in+10-10
......@@ -2156,7 +2156,7 @@ test "pointer casting" {
21562156
21572157test "pointer child type" {
21582158 // pointer types have a `child` field which tells you the type they point to.
2159 assert((*u32).Child == u32);
2159 assert(@typeInfo(*u32).Pointer.child == u32);
21602160}
21612161 {#code_end#}
21622162 {#header_open|Alignment#}
......@@ -2184,7 +2184,7 @@ test "variable alignment" {
21842184 assert(@TypeOf(&x) == *i32);
21852185 assert(*i32 == *align(align_of_i32) i32);
21862186 if (std.Target.current.cpu.arch == .x86_64) {
2187 assert((*i32).alignment == 4);
2187 assert(@typeInfo(*i32).Pointer.alignment == 4);
21882188 }
21892189}
21902190 {#code_end#}
......@@ -2202,7 +2202,7 @@ const assert = @import("std").debug.assert;
22022202var foo: u8 align(4) = 100;
22032203
22042204test "global variable alignment" {
2205 assert(@TypeOf(&foo).alignment == 4);
2205 assert(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
22062206 assert(@TypeOf(&foo) == *align(4) u8);
22072207 const as_pointer_to_array: *[1]u8 = &foo;
22082208 const as_slice: []u8 = as_pointer_to_array;
......@@ -4310,8 +4310,8 @@ test "fn type inference" {
43104310const assert = @import("std").debug.assert;
43114311
43124312test "fn reflection" {
4313 assert(@TypeOf(assert).ReturnType == void);
4314 assert(@TypeOf(assert).is_var_args == false);
4313 assert(@typeInfo(@TypeOf(assert)).Fn.return_type.? == void);
4314 assert(@typeInfo(@TypeOf(assert)).Fn.is_var_args == false);
43154315}
43164316 {#code_end#}
43174317 {#header_close#}
......@@ -4611,10 +4611,10 @@ test "error union" {
46114611 foo = error.SomeError;
46124612
46134613 // Use compile-time reflection to access the payload type of an error union:
4614 comptime assert(@TypeOf(foo).Payload == i32);
4614 comptime assert(@typeInfo(@TypeOf(foo)).ErrorUnion.payload == i32);
46154615
46164616 // Use compile-time reflection to access the error set type of an error union:
4617 comptime assert(@TypeOf(foo).ErrorSet == anyerror);
4617 comptime assert(@typeInfo(@TypeOf(foo)).ErrorUnion.error_set == anyerror);
46184618}
46194619 {#code_end#}
46204620 {#header_open|Merging Error Sets#}
......@@ -4991,7 +4991,7 @@ test "optional type" {
49914991 foo = 1234;
49924992
49934993 // Use compile-time reflection to access the child type of the optional:
4994 comptime assert(@TypeOf(foo).Child == i32);
4994 comptime assert(@typeInfo(@TypeOf(foo)).Optional.child == i32);
49954995}
49964996 {#code_end#}
49974997 {#header_close#}
......@@ -7211,7 +7211,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
72117211 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
72127212 an integer or an enum.
72137213 </p>
7214 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
7214 <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
72157215 {#see_also|Compile Variables|cmpxchgWeak#}
72167216 {#header_close#}
72177217 {#header_open|@cmpxchgWeak#}
......@@ -7240,7 +7240,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
72407240 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
72417241 an integer or an enum.
72427242 </p>
7243 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
7243 <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
72447244 {#see_also|Compile Variables|cmpxchgStrong#}
72457245 {#header_close#}
72467246
lib/std/pdb.zig+1-1
......@@ -636,7 +636,7 @@ const MsfStream = struct {
636636 blocks: []u32 = undefined,
637637 block_size: u32 = undefined,
638638
639 pub const Error = @TypeOf(read).ReturnType.ErrorSet;
639 pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).Fn.return_type.?).ErrorUnion.error_set;
640640
641641 fn init(block_size: u32, file: File, blocks: []u32) MsfStream {
642642 const stream = MsfStream{
lib/std/start.zig+1-1
......@@ -67,7 +67,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
6767 uefi.handle = handle;
6868 uefi.system_table = system_table;
6969
70 switch (@TypeOf(root.main).ReturnType) {
70 switch (@typeInfo(@TypeOf(read)).Fn.return_type.?) {
7171 noreturn => {
7272 root.main();
7373 },
test/compile_errors.zig+7-16
......@@ -176,11 +176,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
176176 , &[_][]const u8{
177177 "tmp.zig:2:17: error: expected type 'u32', found 'error{Ohno}'",
178178 "tmp.zig:1:17: note: function cannot return an error",
179 "tmp.zig:8:5: error: expected type 'void', found '@TypeOf(bar).ReturnType.ErrorSet'",
179 "tmp.zig:8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set'",
180180 "tmp.zig:7:17: note: function cannot return an error",
181 "tmp.zig:11:15: error: expected type 'u32', found '@TypeOf(bar).ReturnType.ErrorSet!u32'",
181 "tmp.zig:11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
182182 "tmp.zig:10:17: note: function cannot return an error",
183 "tmp.zig:15:14: error: expected type 'u32', found '@TypeOf(bar).ReturnType.ErrorSet!u32'",
183 "tmp.zig:15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(bar)).Fn.return_type.?).ErrorUnion.error_set!u32'",
184184 "tmp.zig:14:5: note: cannot store an error in type 'u32'",
185185 });
186186
......@@ -1224,7 +1224,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
12241224 \\ };
12251225 \\}
12261226 , &[_][]const u8{
1227 "tmp.zig:11:25: error: expected type 'u32', found '@TypeOf(get_uval).ReturnType.ErrorSet!u32'",
1227 "tmp.zig:11:25: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32'",
12281228 });
12291229
12301230 cases.add("assigning to struct or union fields that are not optionals with a function that returns an optional",
......@@ -1929,7 +1929,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
19291929 \\ const info = @TypeOf(slice).unknown;
19301930 \\}
19311931 , &[_][]const u8{
1932 "tmp.zig:3:32: error: type '[]i32' does not support field access",
1932 "tmp.zig:3:32: error: type 'type' does not support field access",
19331933 });
19341934
19351935 cases.add("peer cast then implicit cast const pointer to mutable C pointer",
......@@ -3542,7 +3542,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
35423542 \\ }
35433543 \\}
35443544 , &[_][]const u8{
3545 "tmp.zig:5:14: error: duplicate switch value: '@TypeOf(foo).ReturnType.ErrorSet.Foo'",
3545 "tmp.zig:5:14: error: duplicate switch value: '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set.Foo'",
35463546 "tmp.zig:3:14: note: other value is here",
35473547 });
35483548
......@@ -3674,7 +3674,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36743674 \\ try foo();
36753675 \\}
36763676 , &[_][]const u8{
3677 "tmp.zig:5:5: error: cannot resolve inferred error set '@TypeOf(foo).ReturnType.ErrorSet': function 'foo' not fully analyzed yet",
3677 "tmp.zig:5:5: error: cannot resolve inferred error set '@typeInfo(@typeInfo(@TypeOf(foo)).Fn.return_type.?).ErrorUnion.error_set': function 'foo' not fully analyzed yet",
36783678 });
36793679
36803680 cases.add("implicit cast of error set not a subset",
......@@ -7206,15 +7206,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
72067206 "tmp.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set",
72077207 });
72087208
7209 cases.add("getting return type of generic function",
7210 \\fn generic(a: anytype) void {}
7211 \\comptime {
7212 \\ _ = @TypeOf(generic).ReturnType;
7213 \\}
7214 , &[_][]const u8{
7215 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(anytype) anytype' is generic",
7216 });
7217
72187209 cases.add("unsupported modifier at start of asm output constraint",
72197210 \\export fn foo() void {
72207211 \\ var bar: u32 = 3;