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" {...@@ -2156,7 +2156,7 @@ test "pointer casting" {
21562156
2157test "pointer child type" {2157test "pointer child type" {
2158 // pointer types have a `child` field which tells you the type they point to.2158 // 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);
2160}2160}
2161 {#code_end#}2161 {#code_end#}
2162 {#header_open|Alignment#}2162 {#header_open|Alignment#}
...@@ -2184,7 +2184,7 @@ test "variable alignment" {...@@ -2184,7 +2184,7 @@ test "variable alignment" {
2184 assert(@TypeOf(&x) == *i32);2184 assert(@TypeOf(&x) == *i32);
2185 assert(*i32 == *align(align_of_i32) i32);2185 assert(*i32 == *align(align_of_i32) i32);
2186 if (std.Target.current.cpu.arch == .x86_64) {2186 if (std.Target.current.cpu.arch == .x86_64) {
2187 assert((*i32).alignment == 4);2187 assert(@typeInfo(*i32).Pointer.alignment == 4);
2188 }2188 }
2189}2189}
2190 {#code_end#}2190 {#code_end#}
...@@ -2202,7 +2202,7 @@ const assert = @import("std").debug.assert;...@@ -2202,7 +2202,7 @@ const assert = @import("std").debug.assert;
2202var foo: u8 align(4) = 100;2202var foo: u8 align(4) = 100;
22032203
2204test "global variable alignment" {2204test "global variable alignment" {
2205 assert(@TypeOf(&foo).alignment == 4);2205 assert(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
2206 assert(@TypeOf(&foo) == *align(4) u8);2206 assert(@TypeOf(&foo) == *align(4) u8);
2207 const as_pointer_to_array: *[1]u8 = &foo;2207 const as_pointer_to_array: *[1]u8 = &foo;
2208 const as_slice: []u8 = as_pointer_to_array;2208 const as_slice: []u8 = as_pointer_to_array;
...@@ -4310,8 +4310,8 @@ test "fn type inference" {...@@ -4310,8 +4310,8 @@ test "fn type inference" {
4310const assert = @import("std").debug.assert;4310const assert = @import("std").debug.assert;
43114311
4312test "fn reflection" {4312test "fn reflection" {
4313 assert(@TypeOf(assert).ReturnType == void);4313 assert(@typeInfo(@TypeOf(assert)).Fn.return_type.? == void);
4314 assert(@TypeOf(assert).is_var_args == false);4314 assert(@typeInfo(@TypeOf(assert)).Fn.is_var_args == false);
4315}4315}
4316 {#code_end#}4316 {#code_end#}
4317 {#header_close#}4317 {#header_close#}
...@@ -4611,10 +4611,10 @@ test "error union" {...@@ -4611,10 +4611,10 @@ test "error union" {
4611 foo = error.SomeError;4611 foo = error.SomeError;
46124612
4613 // Use compile-time reflection to access the payload type of an error union:4613 // 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
4616 // Use compile-time reflection to access the error set type of an error union:4616 // 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);
4618}4618}
4619 {#code_end#}4619 {#code_end#}
4620 {#header_open|Merging Error Sets#}4620 {#header_open|Merging Error Sets#}
...@@ -4991,7 +4991,7 @@ test "optional type" {...@@ -4991,7 +4991,7 @@ test "optional type" {
4991 foo = 1234;4991 foo = 1234;
49924992
4993 // Use compile-time reflection to access the child type of the optional:4993 // 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);
4995}4995}
4996 {#code_end#}4996 {#code_end#}
4997 {#header_close#}4997 {#header_close#}
...@@ -7211,7 +7211,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v...@@ -7211,7 +7211,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
7211 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,7211 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
7212 an integer or an enum.7212 an integer or an enum.
7213 </p>7213 </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>
7215 {#see_also|Compile Variables|cmpxchgWeak#}7215 {#see_also|Compile Variables|cmpxchgWeak#}
7216 {#header_close#}7216 {#header_close#}
7217 {#header_open|@cmpxchgWeak#}7217 {#header_open|@cmpxchgWeak#}
...@@ -7240,7 +7240,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -7240,7 +7240,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
7240 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,7240 {#syntax#}T{#endsyntax#} must be a {#syntax#}bool{#endsyntax#}, a float,
7241 an integer or an enum.7241 an integer or an enum.
7242 </p>7242 </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>
7244 {#see_also|Compile Variables|cmpxchgStrong#}7244 {#see_also|Compile Variables|cmpxchgStrong#}
7245 {#header_close#}7245 {#header_close#}
72467246
lib/std/pdb.zig+1-1
...@@ -636,7 +636,7 @@ const MsfStream = struct {...@@ -636,7 +636,7 @@ const MsfStream = struct {
636 blocks: []u32 = undefined,636 blocks: []u32 = undefined,
637 block_size: u32 = undefined,637 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
641 fn init(block_size: u32, file: File, blocks: []u32) MsfStream {641 fn init(block_size: u32, file: File, blocks: []u32) MsfStream {
642 const stream = MsfStream{642 const stream = MsfStream{
lib/std/start.zig+1-1
...@@ -67,7 +67,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv...@@ -67,7 +67,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
67 uefi.handle = handle;67 uefi.handle = handle;
68 uefi.system_table = system_table;68 uefi.system_table = system_table;
6969
70 switch (@TypeOf(root.main).ReturnType) {70 switch (@typeInfo(@TypeOf(read)).Fn.return_type.?) {
71 noreturn => {71 noreturn => {
72 root.main();72 root.main();
73 },73 },
test/compile_errors.zig+7-16
...@@ -176,11 +176,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -176,11 +176,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
176 , &[_][]const u8{176 , &[_][]const u8{
177 "tmp.zig:2:17: error: expected type 'u32', found 'error{Ohno}'",177 "tmp.zig:2:17: error: expected type 'u32', found 'error{Ohno}'",
178 "tmp.zig:1:17: note: function cannot return an error",178 "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'",
180 "tmp.zig:7:17: note: function cannot return an error",180 "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'",
182 "tmp.zig:10:17: note: function cannot return an error",182 "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'",
184 "tmp.zig:14:5: note: cannot store an error in type 'u32'",184 "tmp.zig:14:5: note: cannot store an error in type 'u32'",
185 });185 });
186186
...@@ -1224,7 +1224,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1224,7 +1224,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1224 \\ };1224 \\ };
1225 \\}1225 \\}
1226 , &[_][]const u8{1226 , &[_][]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'",
1228 });1228 });
12291229
1230 cases.add("assigning to struct or union fields that are not optionals with a function that returns an optional",1230 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 {...@@ -1929,7 +1929,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1929 \\ const info = @TypeOf(slice).unknown;1929 \\ const info = @TypeOf(slice).unknown;
1930 \\}1930 \\}
1931 , &[_][]const u8{1931 , &[_][]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",
1933 });1933 });
19341934
1935 cases.add("peer cast then implicit cast const pointer to mutable C pointer",1935 cases.add("peer cast then implicit cast const pointer to mutable C pointer",
...@@ -3542,7 +3542,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3542,7 +3542,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3542 \\ }3542 \\ }
3543 \\}3543 \\}
3544 , &[_][]const u8{3544 , &[_][]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'",
3546 "tmp.zig:3:14: note: other value is here",3546 "tmp.zig:3:14: note: other value is here",
3547 });3547 });
35483548
...@@ -3674,7 +3674,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3674,7 +3674,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3674 \\ try foo();3674 \\ try foo();
3675 \\}3675 \\}
3676 , &[_][]const u8{3676 , &[_][]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",
3678 });3678 });
36793679
3680 cases.add("implicit cast of error set not a subset",3680 cases.add("implicit cast of error set not a subset",
...@@ -7206,15 +7206,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -7206,15 +7206,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
7206 "tmp.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set",7206 "tmp.zig:7:24: error: accessing union field 'Bar' while field 'Baz' is set",
7207 });7207 });
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
7218 cases.add("unsupported modifier at start of asm output constraint",7209 cases.add("unsupported modifier at start of asm output constraint",
7219 \\export fn foo() void {7210 \\export fn foo() void {
7220 \\ var bar: u32 = 3;7211 \\ var bar: u32 = 3;