authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-10 11:13:39-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-10 11:13:39-05:00
log9561e7c6b9fb2d9ebcbfd611196db698372ae7bd
tree6b4fd0751e80a9c4128756d59d3c0bfecd230498
parentcd4d638d10365e47bcb371119dcee22581355ac4
parent30715560c829d5636734edf7eabff3ee4d170e5d
signaturelock-open Commit is signed but in an unrecognized format.

Merge branch 'Snektron-typeOf-to-TypeOf'

closes #3875 closes #1348

134 files changed, 604 insertions(+), 585 deletions(-)

doc/langref.html.in+52-52
......@@ -307,7 +307,7 @@ pub fn main() void {
307307 assert(optional_value == null);
308308
309309 warn("\noptional 1\ntype: {}\nvalue: {}\n", .{
310 @typeName(@typeOf(optional_value)),
310 @typeName(@TypeOf(optional_value)),
311311 optional_value,
312312 });
313313
......@@ -315,7 +315,7 @@ pub fn main() void {
315315 assert(optional_value != null);
316316
317317 warn("\noptional 2\ntype: {}\nvalue: {}\n", .{
318 @typeName(@typeOf(optional_value)),
318 @typeName(@TypeOf(optional_value)),
319319 optional_value,
320320 });
321321
......@@ -323,14 +323,14 @@ pub fn main() void {
323323 var number_or_error: anyerror!i32 = error.ArgNotFound;
324324
325325 warn("\nerror union 1\ntype: {}\nvalue: {}\n", .{
326 @typeName(@typeOf(number_or_error)),
326 @typeName(@TypeOf(number_or_error)),
327327 number_or_error,
328328 });
329329
330330 number_or_error = 1234;
331331
332332 warn("\nerror union 2\ntype: {}\nvalue: {}\n", .{
333 @typeName(@typeOf(number_or_error)),
333 @typeName(@TypeOf(number_or_error)),
334334 number_or_error,
335335 });
336336}
......@@ -572,7 +572,7 @@ const mem = @import("std").mem;
572572
573573test "string literals" {
574574 const bytes = "hello";
575 assert(@typeOf(bytes) == *const [5:0]u8);
575 assert(@TypeOf(bytes) == *const [5:0]u8);
576576 assert(bytes.len == 5);
577577 assert(bytes[1] == 'e');
578578 assert(bytes[5] == 0);
......@@ -1802,7 +1802,7 @@ const assert = std.debug.assert;
18021802test "null terminated array" {
18031803 const array = [_:0]u8 {1, 2, 3, 4};
18041804
1805 assert(@typeOf(array) == [4:0]u8);
1805 assert(@TypeOf(array) == [4:0]u8);
18061806 assert(array.len == 4);
18071807 assert(array[4] == 0);
18081808}
......@@ -1885,12 +1885,12 @@ test "address of syntax" {
18851885 assert(x_ptr.* == 1234);
18861886
18871887 // When you get the address of a const variable, you get a const pointer to a single item.
1888 assert(@typeOf(x_ptr) == *const i32);
1888 assert(@TypeOf(x_ptr) == *const i32);
18891889
18901890 // If you want to mutate the value, you'd need an address of a mutable variable:
18911891 var y: i32 = 5678;
18921892 const y_ptr = &y;
1893 assert(@typeOf(y_ptr) == *i32);
1893 assert(@TypeOf(y_ptr) == *i32);
18941894 y_ptr.* += 1;
18951895 assert(y_ptr.* == 5679);
18961896}
......@@ -1901,7 +1901,7 @@ test "pointer array access" {
19011901 // does not support pointer arithmetic.
19021902 var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
19031903 const ptr = &array[2];
1904 assert(@typeOf(ptr) == *u8);
1904 assert(@TypeOf(ptr) == *u8);
19051905
19061906 assert(array[2] == 3);
19071907 ptr.* += 1;
......@@ -1953,7 +1953,7 @@ const assert = @import("std").debug.assert;
19531953test "@ptrToInt and @intToPtr" {
19541954 const ptr = @intToPtr(*i32, 0xdeadbeef);
19551955 const addr = @ptrToInt(ptr);
1956 assert(@typeOf(addr) == usize);
1956 assert(@TypeOf(addr) == usize);
19571957 assert(addr == 0xdeadbeef);
19581958}
19591959 {#code_end#}
......@@ -1968,7 +1968,7 @@ test "comptime @intToPtr" {
19681968 // ptr is never dereferenced.
19691969 const ptr = @intToPtr(*i32, 0xdeadbeef);
19701970 const addr = @ptrToInt(ptr);
1971 assert(@typeOf(addr) == usize);
1971 assert(@TypeOf(addr) == usize);
19721972 assert(addr == 0xdeadbeef);
19731973 }
19741974}
......@@ -1984,7 +1984,7 @@ const assert = @import("std").debug.assert;
19841984
19851985test "volatile" {
19861986 const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);
1987 assert(@typeOf(mmio_ptr) == *volatile u8);
1987 assert(@TypeOf(mmio_ptr) == *volatile u8);
19881988}
19891989 {#code_end#}
19901990 <p>
......@@ -2041,8 +2041,8 @@ const builtin = @import("builtin");
20412041
20422042test "variable alignment" {
20432043 var x: i32 = 1234;
2044 const align_of_i32 = @alignOf(@typeOf(x));
2045 assert(@typeOf(&x) == *i32);
2044 const align_of_i32 = @alignOf(@TypeOf(x));
2045 assert(@TypeOf(&x) == *i32);
20462046 assert(*i32 == *align(align_of_i32) i32);
20472047 if (builtin.arch == builtin.Arch.x86_64) {
20482048 assert((*i32).alignment == 4);
......@@ -2063,10 +2063,10 @@ const assert = @import("std").debug.assert;
20632063var foo: u8 align(4) = 100;
20642064
20652065test "global variable alignment" {
2066 assert(@typeOf(&foo).alignment == 4);
2067 assert(@typeOf(&foo) == *align(4) u8);
2066 assert(@TypeOf(&foo).alignment == 4);
2067 assert(@TypeOf(&foo) == *align(4) u8);
20682068 const slice = @as(*[1]u8, &foo)[0..];
2069 assert(@typeOf(slice) == []align(4) u8);
2069 assert(@TypeOf(slice) == []align(4) u8);
20702070}
20712071
20722072fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; }
......@@ -2075,8 +2075,8 @@ fn noop4() align(4) void {}
20752075
20762076test "function alignment" {
20772077 assert(derp() == 1234);
2078 assert(@typeOf(noop1) == fn() align(1) void);
2079 assert(@typeOf(noop4) == fn() align(4) void);
2078 assert(@TypeOf(noop1) == fn() align(1) void);
2079 assert(@TypeOf(noop4) == fn() align(4) void);
20802080 noop1();
20812081 noop4();
20822082}
......@@ -2162,8 +2162,8 @@ test "basic slices" {
21622162
21632163 // Using the address-of operator on a slice gives a pointer to a single
21642164 // item, while using the `ptr` field gives an unknown length pointer.
2165 assert(@typeOf(slice.ptr) == [*]i32);
2166 assert(@typeOf(&slice[0]) == *i32);
2165 assert(@TypeOf(slice.ptr) == [*]i32);
2166 assert(@TypeOf(&slice[0]) == *i32);
21672167 assert(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));
21682168
21692169 // Slices have array bounds checking. If you try to access something out
......@@ -2208,7 +2208,7 @@ test "slice pointer" {
22082208 slice[2] = 3;
22092209 assert(slice[2] == 3);
22102210 // The slice is mutable because we sliced a mutable pointer.
2211 assert(@typeOf(slice) == []u8);
2211 assert(@TypeOf(slice) == []u8);
22122212
22132213 // You can also slice a slice:
22142214 const slice2 = slice[2..3];
......@@ -3566,7 +3566,7 @@ test "for basics" {
35663566 // This is zero-indexed.
35673567 var sum2: i32 = 0;
35683568 for (items) |value, i| {
3569 assert(@typeOf(i) == usize);
3569 assert(@TypeOf(i) == usize);
35703570 sum2 += @intCast(i32, i);
35713571 }
35723572 assert(sum2 == 10);
......@@ -3909,7 +3909,7 @@ test "type of unreachable" {
39093909 // However this assertion will still fail because
39103910 // evaluating unreachable at compile-time is a compile error.
39113911
3912 assert(@typeOf(unreachable) == noreturn);
3912 assert(@TypeOf(unreachable) == noreturn);
39133913 }
39143914}
39153915 {#code_end#}
......@@ -4018,7 +4018,7 @@ test "function" {
40184018const assert = @import("std").debug.assert;
40194019
40204020comptime {
4021 assert(@typeOf(foo) == fn()void);
4021 assert(@TypeOf(foo) == fn()void);
40224022 assert(@sizeOf(fn()void) == @sizeOf(?fn()void));
40234023}
40244024
......@@ -4062,35 +4062,35 @@ test "pass struct to function" {
40624062 </p>
40634063 {#header_close#}
40644064 {#header_open|Function Parameter Type Inference#}
4065 <p>
4066 Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.
4065 <p>
4066 Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.
40674067 In this case the parameter types will be inferred when the function is called.
4068 Use {#link|@typeOf#} and {#link|@typeInfo#} to get information about the inferred type.
4068 Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type.
40694069 </p>
40704070 {#code_begin|test#}
40714071const assert = @import("std").debug.assert;
40724072
4073fn addFortyTwo(x: var) @typeOf(x) {
4073fn addFortyTwo(x: var) @TypeOf(x) {
40744074 return x + 42;
40754075}
40764076
40774077test "fn type inference" {
40784078 assert(addFortyTwo(1) == 43);
4079 assert(@typeOf(addFortyTwo(1)) == comptime_int);
4079 assert(@TypeOf(addFortyTwo(1)) == comptime_int);
40804080 var y: i64 = 2;
40814081 assert(addFortyTwo(y) == 44);
4082 assert(@typeOf(addFortyTwo(y)) == i64);
4082 assert(@TypeOf(addFortyTwo(y)) == i64);
40834083}
40844084 {#code_end#}
4085
4085
40864086 {#header_close#}
40874087 {#header_open|Function Reflection#}
40884088 {#code_begin|test#}
40894089const assert = @import("std").debug.assert;
40904090
40914091test "fn reflection" {
4092 assert(@typeOf(assert).ReturnType == void);
4093 assert(@typeOf(assert).is_var_args == false);
4092 assert(@TypeOf(assert).ReturnType == void);
4093 assert(@TypeOf(assert).is_var_args == false);
40944094}
40954095 {#code_end#}
40964096 {#header_close#}
......@@ -4390,10 +4390,10 @@ test "error union" {
43904390 foo = error.SomeError;
43914391
43924392 // Use compile-time reflection to access the payload type of an error union:
4393 comptime assert(@typeOf(foo).Payload == i32);
4393 comptime assert(@TypeOf(foo).Payload == i32);
43944394
43954395 // Use compile-time reflection to access the error set type of an error union:
4396 comptime assert(@typeOf(foo).ErrorSet == anyerror);
4396 comptime assert(@TypeOf(foo).ErrorSet == anyerror);
43974397}
43984398 {#code_end#}
43994399 {#header_open|Merging Error Sets#}
......@@ -4770,7 +4770,7 @@ test "optional type" {
47704770 foo = 1234;
47714771
47724772 // Use compile-time reflection to access the child type of the optional:
4773 comptime assert(@typeOf(foo).Child == i32);
4773 comptime assert(@TypeOf(foo).Child == i32);
47744774}
47754775 {#code_end#}
47764776 {#header_close#}
......@@ -5154,7 +5154,7 @@ test "peer resolve int widening" {
51545154 var b: i16 = 34;
51555155 var c = a + b;
51565156 assert(c == 46);
5157 assert(@typeOf(c) == i16);
5157 assert(@TypeOf(c) == i16);
51585158}
51595159
51605160test "peer resolve arrays of different size to const slice" {
......@@ -5949,7 +5949,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
59495949 </p>
59505950 {#code_begin|syntax#}
59515951pub fn printValue(self: *OutStream, value: var) !void {
5952 const T = @typeOf(value);
5952 const T = @TypeOf(value);
59535953 if (@isInteger(T)) {
59545954 return self.printInt(T, value);
59555955 } else if (@isFloat(T)) {
......@@ -6265,7 +6265,7 @@ test "async function suspend with block" {
62656265
62666266fn testSuspendBlock() void {
62676267 suspend {
6268 comptime assert(@typeOf(@frame()) == *@Frame(testSuspendBlock));
6268 comptime assert(@TypeOf(@frame()) == *@Frame(testSuspendBlock));
62696269 the_frame = @frame();
62706270 }
62716271 result = true;
......@@ -6332,7 +6332,7 @@ test "async and await" {
63326332
63336333fn amain() void {
63346334 var frame = async func();
6335 comptime assert(@typeOf(frame) == @Frame(func));
6335 comptime assert(@TypeOf(frame) == @Frame(func));
63366336
63376337 const ptr: anyframe->void = &frame;
63386338 const any_ptr: anyframe = ptr;
......@@ -6740,7 +6740,7 @@ async fn func(y: *i32) void {
67406740 Converts a value of one type to another type.
67416741 </p>
67426742 <p>
6743 Asserts that {#syntax#}@sizeOf(@typeOf(value)) == @sizeOf(DestType){#endsyntax#}.
6743 Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
67446744 </p>
67456745 <p>
67466746 Asserts that {#syntax#}@typeId(DestType) != @import("builtin").TypeId.Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
......@@ -7045,7 +7045,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
70457045 <p>
70467046 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
70477047 </p>
7048 <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
7048 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
70497049 {#see_also|Compile Variables|cmpxchgWeak#}
70507050 {#header_close#}
70517051 {#header_open|@cmpxchgWeak#}
......@@ -7073,7 +7073,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
70737073 <p>
70747074 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
70757075 </p>
7076 <p>{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
7076 <p>{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
70777077 {#see_also|Compile Variables|cmpxchgStrong#}
70787078 {#header_close#}
70797079
......@@ -8020,7 +8020,7 @@ test "@setRuntimeSafety" {
80208020 {#header_close#}
80218021
80228022 {#header_open|@splat#}
8023 <pre>{#syntax#}@splat(comptime len: u32, scalar: var) @Vector(len, @typeOf(scalar)){#endsyntax#}</pre>
8023 <pre>{#syntax#}@splat(comptime len: u32, scalar: var) @Vector(len, @TypeOf(scalar)){#endsyntax#}</pre>
80248024 <p>
80258025 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value
80268026 {#syntax#}scalar{#endsyntax#}:
......@@ -8032,7 +8032,7 @@ const assert = std.debug.assert;
80328032test "vector @splat" {
80338033 const scalar: u32 = 5;
80348034 const result = @splat(4, scalar);
8035 comptime assert(@typeOf(result) == @Vector(4, u32));
8035 comptime assert(@TypeOf(result) == @Vector(4, u32));
80368036 assert(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
80378037}
80388038 {#code_end#}
......@@ -8250,8 +8250,8 @@ test "integer truncation" {
82508250 <li>{#link|Pointers#}</li>
82518251 <li>{#syntax#}comptime_int{#endsyntax#}</li>
82528252 <li>{#syntax#}comptime_float{#endsyntax#}</li>
8253 <li>{#syntax#}@typeOf(undefined){#endsyntax#}</li>
8254 <li>{#syntax#}@typeOf(null){#endsyntax#}</li>
8253 <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li>
8254 <li>{#syntax#}@TypeOf(null){#endsyntax#}</li>
82558255 </ul>
82568256 <p>
82578257 For these types it is a
......@@ -8516,20 +8516,20 @@ pub const TypeInfo = union(TypeId) {
85168516
85178517 {#header_close#}
85188518
8519 {#header_open|@typeOf#}
8520 <pre>{#syntax#}@typeOf(expression) type{#endsyntax#}</pre>
8519 {#header_open|@TypeOf#}
8520 <pre>{#syntax#}@TypeOf(expression) type{#endsyntax#}</pre>
85218521 <p>
85228522 This function returns a compile-time constant, which is the type of the
85238523 expression passed as an argument. The expression is evaluated.
85248524 </p>
8525 <p>{#syntax#}@typeOf{#endsyntax#} guarantees no run-time side-effects within the expression:</p>
8525 <p>{#syntax#}@TypeOf{#endsyntax#} guarantees no run-time side-effects within the expression:</p>
85268526 {#code_begin|test#}
85278527const std = @import("std");
85288528const assert = std.debug.assert;
85298529
85308530test "no runtime side effects" {
85318531 var data: i32 = 0;
8532 const T = @typeOf(foo(i32, &data));
8532 const T = @TypeOf(foo(i32, &data));
85338533 comptime assert(T == i32);
85348534 assert(data == 0);
85358535}
lib/std/array_list.zig+1-1
......@@ -40,7 +40,7 @@ pub fn AlignedArrayList(comptime T: type, comptime alignment: ?u29) type {
4040 .allocator = allocator,
4141 };
4242 }
43
43
4444 /// Initialize with capacity to hold at least num elements.
4545 /// Deinitialize with `deinit` or use `toOwnedSlice`.
4646 pub fn initCapacity(allocator: *Allocator, num: usize) !Self {
lib/std/atomic/queue.zig+1-1
......@@ -106,7 +106,7 @@ pub fn Queue(comptime T: type) type {
106106 pub fn dump(self: *Self) void {
107107 var stderr_file = std.io.getStdErr() catch return;
108108 const stderr = &stderr_file.outStream().stream;
109 const Error = @typeInfo(@typeOf(stderr)).Pointer.child.Error;
109 const Error = @typeInfo(@TypeOf(stderr)).Pointer.child.Error;
110110
111111 self.dumpToStream(Error, stderr) catch return;
112112 }
lib/std/atomic/stack.zig+1-1
......@@ -9,7 +9,7 @@ const expect = std.testing.expect;
99pub fn Stack(comptime T: type) type {
1010 return struct {
1111 root: ?*Node,
12 lock: @typeOf(lock_init),
12 lock: @TypeOf(lock_init),
1313
1414 const lock_init = if (builtin.single_threaded) {} else @as(u8, 0);
1515
lib/std/debug.zig+4-4
......@@ -1290,7 +1290,7 @@ pub const DwarfInfo = struct {
12901290 try di.dwarf_seekable_stream.seekTo(this_unit_offset);
12911291
12921292 var is_64: bool = undefined;
1293 const unit_length = try readInitialLength(@typeOf(di.dwarf_in_stream.readFn).ReturnType.ErrorSet, di.dwarf_in_stream, &is_64);
1293 const unit_length = try readInitialLength(@TypeOf(di.dwarf_in_stream.readFn).ReturnType.ErrorSet, di.dwarf_in_stream, &is_64);
12941294 if (unit_length == 0) return;
12951295 const next_offset = unit_length + (if (is_64) @as(usize, 12) else @as(usize, 4));
12961296
......@@ -1392,7 +1392,7 @@ pub const DwarfInfo = struct {
13921392 try di.dwarf_seekable_stream.seekTo(this_unit_offset);
13931393
13941394 var is_64: bool = undefined;
1395 const unit_length = try readInitialLength(@typeOf(di.dwarf_in_stream.readFn).ReturnType.ErrorSet, di.dwarf_in_stream, &is_64);
1395 const unit_length = try readInitialLength(@TypeOf(di.dwarf_in_stream.readFn).ReturnType.ErrorSet, di.dwarf_in_stream, &is_64);
13961396 if (unit_length == 0) return;
13971397 const next_offset = unit_length + (if (is_64) @as(usize, 12) else @as(usize, 4));
13981398
......@@ -1551,7 +1551,7 @@ pub const DwarfInfo = struct {
15511551 try di.dwarf_seekable_stream.seekTo(di.debug_line.offset + line_info_offset);
15521552
15531553 var is_64: bool = undefined;
1554 const unit_length = try readInitialLength(@typeOf(di.dwarf_in_stream.readFn).ReturnType.ErrorSet, di.dwarf_in_stream, &is_64);
1554 const unit_length = try readInitialLength(@TypeOf(di.dwarf_in_stream.readFn).ReturnType.ErrorSet, di.dwarf_in_stream, &is_64);
15551555 if (unit_length == 0) {
15561556 return error.MissingDebugInfo;
15571557 }
......@@ -2080,7 +2080,7 @@ fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, is_64
20802080 DW.FORM_strp => FormValue{ .StrPtr = try parseFormValueDwarfOffsetSize(in_stream, is_64) },
20812081 DW.FORM_indirect => {
20822082 const child_form_id = try noasync leb.readULEB128(u64, in_stream);
2083 const F = @typeOf(async parseFormValue(allocator, in_stream, child_form_id, is_64));
2083 const F = @TypeOf(async parseFormValue(allocator, in_stream, child_form_id, is_64));
20842084 var frame = try allocator.create(F);
20852085 defer allocator.destroy(frame);
20862086 return await @asyncCall(frame, {}, parseFormValue, allocator, in_stream, child_form_id, is_64);
lib/std/event/group.zig+1-1
......@@ -61,7 +61,7 @@ pub fn Group(comptime ReturnType: type) type {
6161 /// `func` must be async and have return type `ReturnType`.
6262 /// Thread-safe.
6363 pub fn call(self: *Self, comptime func: var, args: var) error{OutOfMemory}!void {
64 var frame = try self.allocator.create(@typeOf(@call(.{ .modifier = .async_kw }, func, args)));
64 var frame = try self.allocator.create(@TypeOf(@call(.{ .modifier = .async_kw }, func, args)));
6565 errdefer self.allocator.destroy(frame);
6666 const node = try self.allocator.create(AllocStack.Node);
6767 errdefer self.allocator.destroy(node);
lib/std/event/loop.zig+1-1
......@@ -42,7 +42,7 @@ pub const Loop = struct {
4242 },
4343 else => {},
4444 };
45 pub const Overlapped = @typeOf(overlapped_init);
45 pub const Overlapped = @TypeOf(overlapped_init);
4646
4747 pub const Id = enum {
4848 Basic,
lib/std/fmt.zig+34-34
......@@ -80,7 +80,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool {
8080///
8181/// If a formatted user type contains a function of the type
8282/// ```
83/// fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, context: var, comptime Errors: type, output: fn (@typeOf(context), []const u8) Errors!void) Errors!void
83/// fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, context: var, comptime Errors: type, output: fn (@TypeOf(context), []const u8) Errors!void) Errors!void
8484/// ```
8585/// with `?` being the type formatted, this function will be called instead of the default implementation.
8686/// This allows user types to be formatted in a logical manner instead of dumping all fields of the type.
......@@ -89,7 +89,7 @@ fn peekIsAlign(comptime fmt: []const u8) bool {
8989pub fn format(
9090 context: var,
9191 comptime Errors: type,
92 output: fn (@typeOf(context), []const u8) Errors!void,
92 output: fn (@TypeOf(context), []const u8) Errors!void,
9393 comptime fmt: []const u8,
9494 args: var,
9595) Errors!void {
......@@ -320,17 +320,17 @@ pub fn formatType(
320320 options: FormatOptions,
321321 context: var,
322322 comptime Errors: type,
323 output: fn (@typeOf(context), []const u8) Errors!void,
323 output: fn (@TypeOf(context), []const u8) Errors!void,
324324 max_depth: usize,
325325) Errors!void {
326326 if (comptime std.mem.eql(u8, fmt, "*")) {
327 try output(context, @typeName(@typeOf(value).Child));
327 try output(context, @typeName(@TypeOf(value).Child));
328328 try output(context, "@");
329329 try formatInt(@ptrToInt(value), 16, false, FormatOptions{}, context, Errors, output);
330330 return;
331331 }
332332
333 const T = @typeOf(value);
333 const T = @TypeOf(value);
334334 switch (@typeInfo(T)) {
335335 .ComptimeInt, .Int, .Float => {
336336 return formatValue(value, fmt, options, context, Errors, output);
......@@ -478,7 +478,7 @@ fn formatValue(
478478 options: FormatOptions,
479479 context: var,
480480 comptime Errors: type,
481 output: fn (@typeOf(context), []const u8) Errors!void,
481 output: fn (@TypeOf(context), []const u8) Errors!void,
482482) Errors!void {
483483 if (comptime std.mem.eql(u8, fmt, "B")) {
484484 return formatBytes(value, options, 1000, context, Errors, output);
......@@ -486,7 +486,7 @@ fn formatValue(
486486 return formatBytes(value, options, 1024, context, Errors, output);
487487 }
488488
489 const T = @typeOf(value);
489 const T = @TypeOf(value);
490490 switch (@typeId(T)) {
491491 .Float => return formatFloatValue(value, fmt, options, context, Errors, output),
492492 .Int, .ComptimeInt => return formatIntValue(value, fmt, options, context, Errors, output),
......@@ -500,12 +500,12 @@ pub fn formatIntValue(
500500 options: FormatOptions,
501501 context: var,
502502 comptime Errors: type,
503 output: fn (@typeOf(context), []const u8) Errors!void,
503 output: fn (@TypeOf(context), []const u8) Errors!void,
504504) Errors!void {
505505 comptime var radix = 10;
506506 comptime var uppercase = false;
507507
508 const int_value = if (@typeOf(value) == comptime_int) blk: {
508 const int_value = if (@TypeOf(value) == comptime_int) blk: {
509509 const Int = math.IntFittingRange(value, value);
510510 break :blk @as(Int, value);
511511 } else
......@@ -515,7 +515,7 @@ pub fn formatIntValue(
515515 radix = 10;
516516 uppercase = false;
517517 } else if (comptime std.mem.eql(u8, fmt, "c")) {
518 if (@typeOf(int_value).bit_count <= 8) {
518 if (@TypeOf(int_value).bit_count <= 8) {
519519 return formatAsciiChar(@as(u8, int_value), options, context, Errors, output);
520520 } else {
521521 @compileError("Cannot print integer that is larger than 8 bits as a ascii");
......@@ -542,7 +542,7 @@ fn formatFloatValue(
542542 options: FormatOptions,
543543 context: var,
544544 comptime Errors: type,
545 output: fn (@typeOf(context), []const u8) Errors!void,
545 output: fn (@TypeOf(context), []const u8) Errors!void,
546546) Errors!void {
547547 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) {
548548 return formatFloatScientific(value, options, context, Errors, output);
......@@ -559,7 +559,7 @@ pub fn formatText(
559559 options: FormatOptions,
560560 context: var,
561561 comptime Errors: type,
562 output: fn (@typeOf(context), []const u8) Errors!void,
562 output: fn (@TypeOf(context), []const u8) Errors!void,
563563) Errors!void {
564564 if (fmt.len == 0) {
565565 return output(context, bytes);
......@@ -580,7 +580,7 @@ pub fn formatAsciiChar(
580580 options: FormatOptions,
581581 context: var,
582582 comptime Errors: type,
583 output: fn (@typeOf(context), []const u8) Errors!void,
583 output: fn (@TypeOf(context), []const u8) Errors!void,
584584) Errors!void {
585585 return output(context, @as(*const [1]u8, &c)[0..]);
586586}
......@@ -590,7 +590,7 @@ pub fn formatBuf(
590590 options: FormatOptions,
591591 context: var,
592592 comptime Errors: type,
593 output: fn (@typeOf(context), []const u8) Errors!void,
593 output: fn (@TypeOf(context), []const u8) Errors!void,
594594) Errors!void {
595595 try output(context, buf);
596596
......@@ -610,7 +610,7 @@ pub fn formatFloatScientific(
610610 options: FormatOptions,
611611 context: var,
612612 comptime Errors: type,
613 output: fn (@typeOf(context), []const u8) Errors!void,
613 output: fn (@TypeOf(context), []const u8) Errors!void,
614614) Errors!void {
615615 var x = @floatCast(f64, value);
616616
......@@ -672,7 +672,7 @@ pub fn formatFloatScientific(
672672 try output(context, float_decimal.digits[0..1]);
673673 try output(context, ".");
674674 if (float_decimal.digits.len > 1) {
675 const num_digits = if (@typeOf(value) == f32) math.min(@as(usize, 9), float_decimal.digits.len) else float_decimal.digits.len;
675 const num_digits = if (@TypeOf(value) == f32) math.min(@as(usize, 9), float_decimal.digits.len) else float_decimal.digits.len;
676676
677677 try output(context, float_decimal.digits[1..num_digits]);
678678 } else {
......@@ -705,7 +705,7 @@ pub fn formatFloatDecimal(
705705 options: FormatOptions,
706706 context: var,
707707 comptime Errors: type,
708 output: fn (@typeOf(context), []const u8) Errors!void,
708 output: fn (@TypeOf(context), []const u8) Errors!void,
709709) Errors!void {
710710 var x = @as(f64, value);
711711
......@@ -851,7 +851,7 @@ pub fn formatBytes(
851851 comptime radix: usize,
852852 context: var,
853853 comptime Errors: type,
854 output: fn (@typeOf(context), []const u8) Errors!void,
854 output: fn (@TypeOf(context), []const u8) Errors!void,
855855) Errors!void {
856856 if (value == 0) {
857857 return output(context, "0B");
......@@ -892,15 +892,15 @@ pub fn formatInt(
892892 options: FormatOptions,
893893 context: var,
894894 comptime Errors: type,
895 output: fn (@typeOf(context), []const u8) Errors!void,
895 output: fn (@TypeOf(context), []const u8) Errors!void,
896896) Errors!void {
897 const int_value = if (@typeOf(value) == comptime_int) blk: {
897 const int_value = if (@TypeOf(value) == comptime_int) blk: {
898898 const Int = math.IntFittingRange(value, value);
899899 break :blk @as(Int, value);
900900 } else
901901 value;
902902
903 if (@typeOf(int_value).is_signed) {
903 if (@TypeOf(int_value).is_signed) {
904904 return formatIntSigned(int_value, base, uppercase, options, context, Errors, output);
905905 } else {
906906 return formatIntUnsigned(int_value, base, uppercase, options, context, Errors, output);
......@@ -914,7 +914,7 @@ fn formatIntSigned(
914914 options: FormatOptions,
915915 context: var,
916916 comptime Errors: type,
917 output: fn (@typeOf(context), []const u8) Errors!void,
917 output: fn (@TypeOf(context), []const u8) Errors!void,
918918) Errors!void {
919919 const new_options = FormatOptions{
920920 .width = if (options.width) |w| (if (w == 0) 0 else w - 1) else null,
......@@ -922,7 +922,7 @@ fn formatIntSigned(
922922 .fill = options.fill,
923923 };
924924
925 const uint = @IntType(false, @typeOf(value).bit_count);
925 const uint = @IntType(false, @TypeOf(value).bit_count);
926926 if (value < 0) {
927927 const minus_sign: u8 = '-';
928928 try output(context, @as(*const [1]u8, &minus_sign)[0..]);
......@@ -945,12 +945,12 @@ fn formatIntUnsigned(
945945 options: FormatOptions,
946946 context: var,
947947 comptime Errors: type,
948 output: fn (@typeOf(context), []const u8) Errors!void,
948 output: fn (@TypeOf(context), []const u8) Errors!void,
949949) Errors!void {
950950 assert(base >= 2);
951 var buf: [math.max(@typeOf(value).bit_count, 1)]u8 = undefined;
952 const min_int_bits = comptime math.max(@typeOf(value).bit_count, @typeOf(base).bit_count);
953 const MinInt = @IntType(@typeOf(value).is_signed, min_int_bits);
951 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
952 const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count);
953 const MinInt = @IntType(@TypeOf(value).is_signed, min_int_bits);
954954 var a: MinInt = value;
955955 var index: usize = buf.len;
956956
......@@ -1420,7 +1420,7 @@ test "custom" {
14201420 options: FormatOptions,
14211421 context: var,
14221422 comptime Errors: type,
1423 output: fn (@typeOf(context), []const u8) Errors!void,
1423 output: fn (@TypeOf(context), []const u8) Errors!void,
14241424 ) Errors!void {
14251425 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {
14261426 return std.fmt.format(context, Errors, output, "({d:.3},{d:.3})", .{ self.x, self.y });
......@@ -1610,7 +1610,7 @@ test "formatIntValue with comptime_int" {
16101610 const value: comptime_int = 123456789123456789;
16111611
16121612 var buf = try std.Buffer.init(std.debug.global_allocator, "");
1613 try formatIntValue(value, "", FormatOptions{}, &buf, @typeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append);
1613 try formatIntValue(value, "", FormatOptions{}, &buf, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append);
16141614 std.testing.expect(mem.eql(u8, buf.toSlice(), "123456789123456789"));
16151615}
16161616
......@@ -1626,7 +1626,7 @@ test "formatType max_depth" {
16261626 options: FormatOptions,
16271627 context: var,
16281628 comptime Errors: type,
1629 output: fn (@typeOf(context), []const u8) Errors!void,
1629 output: fn (@TypeOf(context), []const u8) Errors!void,
16301630 ) Errors!void {
16311631 if (fmt.len == 0) {
16321632 return std.fmt.format(context, Errors, output, "({d:.3},{d:.3})", .{ self.x, self.y });
......@@ -1664,19 +1664,19 @@ test "formatType max_depth" {
16641664 inst.tu.ptr = &inst.tu;
16651665
16661666 var buf0 = try std.Buffer.init(std.debug.global_allocator, "");
1667 try formatType(inst, "", FormatOptions{}, &buf0, @typeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 0);
1667 try formatType(inst, "", FormatOptions{}, &buf0, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 0);
16681668 std.testing.expect(mem.eql(u8, buf0.toSlice(), "S{ ... }"));
16691669
16701670 var buf1 = try std.Buffer.init(std.debug.global_allocator, "");
1671 try formatType(inst, "", FormatOptions{}, &buf1, @typeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 1);
1671 try formatType(inst, "", FormatOptions{}, &buf1, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 1);
16721672 std.testing.expect(mem.eql(u8, buf1.toSlice(), "S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }"));
16731673
16741674 var buf2 = try std.Buffer.init(std.debug.global_allocator, "");
1675 try formatType(inst, "", FormatOptions{}, &buf2, @typeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 2);
1675 try formatType(inst, "", FormatOptions{}, &buf2, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 2);
16761676 std.testing.expect(mem.eql(u8, buf2.toSlice(), "S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }"));
16771677
16781678 var buf3 = try std.Buffer.init(std.debug.global_allocator, "");
1679 try formatType(inst, "", FormatOptions{}, &buf3, @typeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 3);
1679 try formatType(inst, "", FormatOptions{}, &buf3, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 3);
16801680 std.testing.expect(mem.eql(u8, buf3.toSlice(), "S{ .a = S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ .ptr = TU{ ... } } }, .e = E.Two, .vec = (10.200,2.220) }"));
16811681}
16821682
lib/std/hash/auto_hash.zig+3-3
......@@ -22,7 +22,7 @@ pub const HashStrategy = enum {
2222
2323/// Helper function to hash a pointer and mutate the strategy if needed.
2424pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void {
25 const info = @typeInfo(@typeOf(key));
25 const info = @typeInfo(@TypeOf(key));
2626
2727 switch (info.Pointer.size) {
2828 builtin.TypeInfo.Pointer.Size.One => switch (strat) {
......@@ -74,7 +74,7 @@ pub fn hashArray(hasher: var, key: var, comptime strat: HashStrategy) void {
7474/// Provides generic hashing for any eligible type.
7575/// Strategy is provided to determine if pointers should be followed or not.
7676pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
77 const Key = @typeOf(key);
77 const Key = @TypeOf(key);
7878 switch (@typeInfo(Key)) {
7979 .NoReturn,
8080 .Opaque,
......@@ -164,7 +164,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
164164/// Only hashes `key` itself, pointers are not followed.
165165/// Slices are rejected to avoid ambiguity on the user's intention.
166166pub fn autoHash(hasher: var, key: var) void {
167 const Key = @typeOf(key);
167 const Key = @TypeOf(key);
168168 if (comptime meta.trait.isSlice(Key)) {
169169 comptime assert(@hasDecl(std, "StringHashMap")); // detect when the following message needs updated
170170 const extra_help = if (Key == []const u8)
lib/std/hash/cityhash.zig+4-4
......@@ -360,9 +360,9 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
360360 var hashes: [hashbytes * 256]u8 = undefined;
361361 var final: [hashbytes]u8 = undefined;
362362
363 @memset(@ptrCast([*]u8, &key[0]), 0, @sizeOf(@typeOf(key)));
364 @memset(@ptrCast([*]u8, &hashes[0]), 0, @sizeOf(@typeOf(hashes)));
365 @memset(@ptrCast([*]u8, &final[0]), 0, @sizeOf(@typeOf(final)));
363 @memset(@ptrCast([*]u8, &key[0]), 0, @sizeOf(@TypeOf(key)));
364 @memset(@ptrCast([*]u8, &hashes[0]), 0, @sizeOf(@TypeOf(hashes)));
365 @memset(@ptrCast([*]u8, &final[0]), 0, @sizeOf(@TypeOf(final)));
366366
367367 var i: u32 = 0;
368368 while (i < 256) : (i += 1) {
......@@ -370,7 +370,7 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
370370
371371 var h = hash_fn(key[0..i], 256 - i);
372372 if (builtin.endian == builtin.Endian.Big)
373 h = @byteSwap(@typeOf(h), h);
373 h = @byteSwap(@TypeOf(h), h);
374374 @memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes);
375375 }
376376
lib/std/hash/murmur.zig+4-4
......@@ -285,9 +285,9 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
285285 var hashes: [hashbytes * 256]u8 = undefined;
286286 var final: [hashbytes]u8 = undefined;
287287
288 @memset(@ptrCast([*]u8, &key[0]), 0, @sizeOf(@typeOf(key)));
289 @memset(@ptrCast([*]u8, &hashes[0]), 0, @sizeOf(@typeOf(hashes)));
290 @memset(@ptrCast([*]u8, &final[0]), 0, @sizeOf(@typeOf(final)));
288 @memset(@ptrCast([*]u8, &key[0]), 0, @sizeOf(@TypeOf(key)));
289 @memset(@ptrCast([*]u8, &hashes[0]), 0, @sizeOf(@TypeOf(hashes)));
290 @memset(@ptrCast([*]u8, &final[0]), 0, @sizeOf(@TypeOf(final)));
291291
292292 var i: u32 = 0;
293293 while (i < 256) : (i += 1) {
......@@ -295,7 +295,7 @@ fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
295295
296296 var h = hash_fn(key[0..i], 256 - i);
297297 if (builtin.endian == builtin.Endian.Big)
298 h = @byteSwap(@typeOf(h), h);
298 h = @byteSwap(@TypeOf(h), h);
299299 @memcpy(@ptrCast([*]u8, &hashes[i * hashbytes]), @ptrCast([*]u8, &h), hashbytes);
300300 }
301301
lib/std/http/headers.zig+1-1
......@@ -367,7 +367,7 @@ pub const Headers = struct {
367367 options: std.fmt.FormatOptions,
368368 context: var,
369369 comptime Errors: type,
370 output: fn (@typeOf(context), []const u8) Errors!void,
370 output: fn (@TypeOf(context), []const u8) Errors!void,
371371 ) Errors!void {
372372 var it = self.iterator();
373373 while (it.next()) |entry| {
lib/std/io.zig+4-4
......@@ -663,7 +663,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime Error: type) type {
663663 pub fn writeBits(self: *Self, value: var, bits: usize) Error!void {
664664 if (bits == 0) return;
665665
666 const U = @typeOf(value);
666 const U = @TypeOf(value);
667667 comptime assert(trait.isUnsignedInt(U));
668668
669669 //by extending the buffer to a minimum of u8 we can cover a number of edge cases
......@@ -962,7 +962,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
962962
963963 /// Deserializes data into the type pointed to by `ptr`
964964 pub fn deserializeInto(self: *Self, ptr: var) !void {
965 const T = @typeOf(ptr);
965 const T = @TypeOf(ptr);
966966 comptime assert(trait.is(builtin.TypeId.Pointer)(T));
967967
968968 if (comptime trait.isSlice(T) or comptime trait.isPtrTo(builtin.TypeId.Array)(T)) {
......@@ -1091,7 +1091,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
10911091 }
10921092
10931093 fn serializeInt(self: *Self, value: var) Error!void {
1094 const T = @typeOf(value);
1094 const T = @TypeOf(value);
10951095 comptime assert(trait.is(builtin.TypeId.Int)(T) or trait.is(builtin.TypeId.Float)(T));
10961096
10971097 const t_bit_count = comptime meta.bitCount(T);
......@@ -1123,7 +1123,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
11231123
11241124 /// Serializes the passed value into the stream
11251125 pub fn serialize(self: *Self, value: var) Error!void {
1126 const T = comptime @typeOf(value);
1126 const T = comptime @TypeOf(value);
11271127
11281128 if (comptime trait.isIndexable(T)) {
11291129 for (value) |v|
lib/std/json.zig+3-3
......@@ -1038,7 +1038,7 @@ pub const Value = union(enum) {
10381038 }
10391039
10401040 pub fn dumpStream(self: @This(), stream: var, comptime max_depth: usize) !void {
1041 var w = std.json.WriteStream(@typeOf(stream).Child, max_depth).init(stream);
1041 var w = std.json.WriteStream(@TypeOf(stream).Child, max_depth).init(stream);
10421042 w.newline = "";
10431043 w.one_indent = "";
10441044 w.space = "";
......@@ -1048,7 +1048,7 @@ pub const Value = union(enum) {
10481048 pub fn dumpStreamIndent(self: @This(), comptime indent: usize, stream: var, comptime max_depth: usize) !void {
10491049 var one_indent = " " ** indent;
10501050
1051 var w = std.json.WriteStream(@typeOf(stream).Child, max_depth).init(stream);
1051 var w = std.json.WriteStream(@TypeOf(stream).Child, max_depth).init(stream);
10521052 w.one_indent = one_indent;
10531053 try w.emitJson(self);
10541054 }
......@@ -1338,7 +1338,7 @@ test "write json then parse it" {
13381338
13391339 var slice_out_stream = std.io.SliceOutStream.init(&out_buffer);
13401340 const out_stream = &slice_out_stream.stream;
1341 var jw = WriteStream(@typeOf(out_stream).Child, 4).init(out_stream);
1341 var jw = WriteStream(@TypeOf(out_stream).Child, 4).init(out_stream);
13421342
13431343 try jw.beginObject();
13441344
lib/std/json/write_stream.zig+2-2
......@@ -155,7 +155,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
155155 value: var,
156156 ) !void {
157157 assert(self.state[self.state_index] == State.Value);
158 switch (@typeInfo(@typeOf(value))) {
158 switch (@typeInfo(@TypeOf(value))) {
159159 .Int => |info| {
160160 if (info.bits < 53) {
161161 try self.stream.print("{}", .{value});
......@@ -257,7 +257,7 @@ test "json write stream" {
257257 var mem_buf: [1024 * 10]u8 = undefined;
258258 const allocator = &std.heap.FixedBufferAllocator.init(&mem_buf).allocator;
259259
260 var w = std.json.WriteStream(@typeOf(out).Child, 10).init(out);
260 var w = std.json.WriteStream(@TypeOf(out).Child, 10).init(out);
261261 try w.emitJson(try getJson(allocator));
262262
263263 const result = slice_stream.getWritten();
lib/std/math.zig+34-34
......@@ -95,7 +95,7 @@ pub fn approxEq(comptime T: type, x: T, y: T, epsilon: T) bool {
9595
9696// TODO: Hide the following in an internal module.
9797pub fn forceEval(value: var) void {
98 const T = @typeOf(value);
98 const T = @TypeOf(value);
9999 switch (T) {
100100 f16 => {
101101 var x: f16 = undefined;
......@@ -239,13 +239,13 @@ pub fn Min(comptime A: type, comptime B: type) type {
239239 },
240240 else => {},
241241 }
242 return @typeOf(@as(A, 0) + @as(B, 0));
242 return @TypeOf(@as(A, 0) + @as(B, 0));
243243}
244244
245245/// Returns the smaller number. When one of the parameter's type's full range fits in the other,
246246/// the return type is the smaller type.
247pub fn min(x: var, y: var) Min(@typeOf(x), @typeOf(y)) {
248 const Result = Min(@typeOf(x), @typeOf(y));
247pub fn min(x: var, y: var) Min(@TypeOf(x), @TypeOf(y)) {
248 const Result = Min(@TypeOf(x), @TypeOf(y));
249249 if (x < y) {
250250 // TODO Zig should allow this as an implicit cast because x is immutable and in this
251251 // scope it is known to fit in the return type.
......@@ -269,33 +269,33 @@ test "math.min" {
269269 var a: u16 = 999;
270270 var b: u32 = 10;
271271 var result = min(a, b);
272 testing.expect(@typeOf(result) == u16);
272 testing.expect(@TypeOf(result) == u16);
273273 testing.expect(result == 10);
274274 }
275275 {
276276 var a: f64 = 10.34;
277277 var b: f32 = 999.12;
278278 var result = min(a, b);
279 testing.expect(@typeOf(result) == f64);
279 testing.expect(@TypeOf(result) == f64);
280280 testing.expect(result == 10.34);
281281 }
282282 {
283283 var a: i8 = -127;
284284 var b: i16 = -200;
285285 var result = min(a, b);
286 testing.expect(@typeOf(result) == i16);
286 testing.expect(@TypeOf(result) == i16);
287287 testing.expect(result == -200);
288288 }
289289 {
290290 const a = 10.34;
291291 var b: f32 = 999.12;
292292 var result = min(a, b);
293 testing.expect(@typeOf(result) == f32);
293 testing.expect(@TypeOf(result) == f32);
294294 testing.expect(result == 10.34);
295295 }
296296}
297297
298pub fn max(x: var, y: var) @typeOf(x + y) {
298pub fn max(x: var, y: var) @TypeOf(x + y) {
299299 return if (x > y) x else y;
300300}
301301
......@@ -318,8 +318,8 @@ pub fn sub(comptime T: type, a: T, b: T) (error{Overflow}!T) {
318318 return if (@subWithOverflow(T, a, b, &answer)) error.Overflow else answer;
319319}
320320
321pub fn negate(x: var) !@typeOf(x) {
322 return sub(@typeOf(x), 0, x);
321pub fn negate(x: var) !@TypeOf(x) {
322 return sub(@TypeOf(x), 0, x);
323323}
324324
325325pub fn shlExact(comptime T: type, a: T, shift_amt: Log2Int(T)) !T {
......@@ -333,7 +333,7 @@ pub fn shl(comptime T: type, a: T, shift_amt: var) T {
333333 const abs_shift_amt = absCast(shift_amt);
334334 const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt);
335335
336 if (@typeOf(shift_amt) == comptime_int or @typeOf(shift_amt).is_signed) {
336 if (@TypeOf(shift_amt) == comptime_int or @TypeOf(shift_amt).is_signed) {
337337 if (shift_amt < 0) {
338338 return a >> casted_shift_amt;
339339 }
......@@ -359,7 +359,7 @@ pub fn shr(comptime T: type, a: T, shift_amt: var) T {
359359 const abs_shift_amt = absCast(shift_amt);
360360 const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt);
361361
362 if (@typeOf(shift_amt) == comptime_int or @typeOf(shift_amt).is_signed) {
362 if (@TypeOf(shift_amt) == comptime_int or @TypeOf(shift_amt).is_signed) {
363363 if (shift_amt >= 0) {
364364 return a >> casted_shift_amt;
365365 } else {
......@@ -505,12 +505,12 @@ fn testOverflow() void {
505505 testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);
506506}
507507
508pub fn absInt(x: var) !@typeOf(x) {
509 const T = @typeOf(x);
508pub fn absInt(x: var) !@TypeOf(x) {
509 const T = @TypeOf(x);
510510 comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer to absInt
511511 comptime assert(T.is_signed); // must pass a signed integer to absInt
512512
513 if (x == minInt(@typeOf(x))) {
513 if (x == minInt(@TypeOf(x))) {
514514 return error.Overflow;
515515 } else {
516516 @setRuntimeSafety(false);
......@@ -654,16 +654,16 @@ fn testRem() void {
654654/// Returns the absolute value of the integer parameter.
655655/// Result is an unsigned integer.
656656pub fn absCast(x: var) t: {
657 if (@typeOf(x) == comptime_int) {
657 if (@TypeOf(x) == comptime_int) {
658658 break :t comptime_int;
659659 } else {
660 break :t @IntType(false, @typeOf(x).bit_count);
660 break :t @IntType(false, @TypeOf(x).bit_count);
661661 }
662662} {
663 if (@typeOf(x) == comptime_int) {
663 if (@TypeOf(x) == comptime_int) {
664664 return if (x < 0) -x else x;
665665 }
666 const uint = @IntType(false, @typeOf(x).bit_count);
666 const uint = @IntType(false, @TypeOf(x).bit_count);
667667 if (x >= 0) return @intCast(uint, x);
668668
669669 return @intCast(uint, -(x + 1)) + 1;
......@@ -671,23 +671,23 @@ pub fn absCast(x: var) t: {
671671
672672test "math.absCast" {
673673 testing.expect(absCast(@as(i32, -999)) == 999);
674 testing.expect(@typeOf(absCast(@as(i32, -999))) == u32);
674 testing.expect(@TypeOf(absCast(@as(i32, -999))) == u32);
675675
676676 testing.expect(absCast(@as(i32, 999)) == 999);
677 testing.expect(@typeOf(absCast(@as(i32, 999))) == u32);
677 testing.expect(@TypeOf(absCast(@as(i32, 999))) == u32);
678678
679679 testing.expect(absCast(@as(i32, minInt(i32))) == -minInt(i32));
680 testing.expect(@typeOf(absCast(@as(i32, minInt(i32)))) == u32);
680 testing.expect(@TypeOf(absCast(@as(i32, minInt(i32)))) == u32);
681681
682682 testing.expect(absCast(-999) == 999);
683683}
684684
685685/// Returns the negation of the integer parameter.
686686/// Result is a signed integer.
687pub fn negateCast(x: var) !@IntType(true, @typeOf(x).bit_count) {
688 if (@typeOf(x).is_signed) return negate(x);
687pub fn negateCast(x: var) !@IntType(true, @TypeOf(x).bit_count) {
688 if (@TypeOf(x).is_signed) return negate(x);
689689
690 const int = @IntType(true, @typeOf(x).bit_count);
690 const int = @IntType(true, @TypeOf(x).bit_count);
691691 if (x > -minInt(int)) return error.Overflow;
692692
693693 if (x == -minInt(int)) return minInt(int);
......@@ -697,10 +697,10 @@ pub fn negateCast(x: var) !@IntType(true, @typeOf(x).bit_count) {
697697
698698test "math.negateCast" {
699699 testing.expect((negateCast(@as(u32, 999)) catch unreachable) == -999);
700 testing.expect(@typeOf(negateCast(@as(u32, 999)) catch unreachable) == i32);
700 testing.expect(@TypeOf(negateCast(@as(u32, 999)) catch unreachable) == i32);
701701
702702 testing.expect((negateCast(@as(u32, -minInt(i32))) catch unreachable) == minInt(i32));
703 testing.expect(@typeOf(negateCast(@as(u32, -minInt(i32))) catch unreachable) == i32);
703 testing.expect(@TypeOf(negateCast(@as(u32, -minInt(i32))) catch unreachable) == i32);
704704
705705 testing.expectError(error.Overflow, negateCast(@as(u32, maxInt(i32) + 10)));
706706}
......@@ -709,10 +709,10 @@ test "math.negateCast" {
709709/// return an error.
710710pub fn cast(comptime T: type, x: var) (error{Overflow}!T) {
711711 comptime assert(@typeId(T) == builtin.TypeId.Int); // must pass an integer
712 comptime assert(@typeId(@typeOf(x)) == builtin.TypeId.Int); // must pass an integer
713 if (maxInt(@typeOf(x)) > maxInt(T) and x > maxInt(T)) {
712 comptime assert(@typeId(@TypeOf(x)) == builtin.TypeId.Int); // must pass an integer
713 if (maxInt(@TypeOf(x)) > maxInt(T) and x > maxInt(T)) {
714714 return error.Overflow;
715 } else if (minInt(@typeOf(x)) < minInt(T) and x < minInt(T)) {
715 } else if (minInt(@TypeOf(x)) < minInt(T) and x < minInt(T)) {
716716 return error.Overflow;
717717 } else {
718718 return @intCast(T, x);
......@@ -726,13 +726,13 @@ test "math.cast" {
726726 testing.expectError(error.Overflow, cast(u64, @as(i8, -1)));
727727
728728 testing.expect((try cast(u8, @as(u32, 255))) == @as(u8, 255));
729 testing.expect(@typeOf(try cast(u8, @as(u32, 255))) == u8);
729 testing.expect(@TypeOf(try cast(u8, @as(u32, 255))) == u8);
730730}
731731
732732pub const AlignCastError = error{UnalignedMemory};
733733
734734/// Align cast a pointer but return an error if it's the wrong alignment
735pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@typeOf(@alignCast(alignment, ptr)) {
735pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) {
736736 const addr = @ptrToInt(ptr);
737737 if (addr % alignment != 0) {
738738 return error.UnalignedMemory;
......@@ -858,7 +858,7 @@ test "std.math.log2_int_ceil" {
858858}
859859
860860pub fn lossyCast(comptime T: type, value: var) T {
861 switch (@typeInfo(@typeOf(value))) {
861 switch (@typeInfo(@TypeOf(value))) {
862862 builtin.TypeId.Int => return @intToFloat(T, value),
863863 builtin.TypeId.Float => return @floatCast(T, value),
864864 builtin.TypeId.ComptimeInt => return @as(T, value),
lib/std/math/acos.zig+2-2
......@@ -12,8 +12,8 @@ const expect = std.testing.expect;
1212///
1313/// Special cases:
1414/// - acos(x) = nan if x < -1 or x > 1
15pub fn acos(x: var) @typeOf(x) {
16 const T = @typeOf(x);
15pub fn acos(x: var) @TypeOf(x) {
16 const T = @TypeOf(x);
1717 return switch (T) {
1818 f32 => acos32(x),
1919 f64 => acos64(x),
lib/std/math/acosh.zig+2-2
......@@ -14,8 +14,8 @@ const expect = std.testing.expect;
1414/// Special cases:
1515/// - acosh(x) = snan if x < 1
1616/// - acosh(nan) = nan
17pub fn acosh(x: var) @typeOf(x) {
18 const T = @typeOf(x);
17pub fn acosh(x: var) @TypeOf(x) {
18 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => acosh32(x),
2121 f64 => acosh64(x),
lib/std/math/asin.zig+2-2
......@@ -13,8 +13,8 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - asin(+-0) = +-0
1515/// - asin(x) = nan if x < -1 or x > 1
16pub fn asin(x: var) @typeOf(x) {
17 const T = @typeOf(x);
16pub fn asin(x: var) @TypeOf(x) {
17 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => asin32(x),
2020 f64 => asin64(x),
lib/std/math/asinh.zig+2-2
......@@ -15,8 +15,8 @@ const maxInt = std.math.maxInt;
1515/// - asinh(+-0) = +-0
1616/// - asinh(+-inf) = +-inf
1717/// - asinh(nan) = nan
18pub fn asinh(x: var) @typeOf(x) {
19 const T = @typeOf(x);
18pub fn asinh(x: var) @TypeOf(x) {
19 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => asinh32(x),
2222 f64 => asinh64(x),
lib/std/math/atan.zig+2-2
......@@ -13,8 +13,8 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - atan(+-0) = +-0
1515/// - atan(+-inf) = +-pi/2
16pub fn atan(x: var) @typeOf(x) {
17 const T = @typeOf(x);
16pub fn atan(x: var) @TypeOf(x) {
17 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => atan32(x),
2020 f64 => atan64(x),
lib/std/math/atanh.zig+2-2
......@@ -15,8 +15,8 @@ const maxInt = std.math.maxInt;
1515/// - atanh(+-1) = +-inf with signal
1616/// - atanh(x) = nan if |x| > 1 with signal
1717/// - atanh(nan) = nan
18pub fn atanh(x: var) @typeOf(x) {
19 const T = @typeOf(x);
18pub fn atanh(x: var) @TypeOf(x) {
19 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => atanh_32(x),
2222 f64 => atanh_64(x),
lib/std/math/big/int.zig+2-2
......@@ -268,7 +268,7 @@ pub const Int = struct {
268268 /// Sets an Int to value. Value must be an primitive integer type.
269269 pub fn set(self: *Int, value: var) Allocator.Error!void {
270270 self.assertWritable();
271 const T = @typeOf(value);
271 const T = @TypeOf(value);
272272
273273 switch (@typeInfo(T)) {
274274 TypeId.Int => |info| {
......@@ -522,7 +522,7 @@ pub const Int = struct {
522522 options: std.fmt.FormatOptions,
523523 context: var,
524524 comptime FmtError: type,
525 output: fn (@typeOf(context), []const u8) FmtError!void,
525 output: fn (@TypeOf(context), []const u8) FmtError!void,
526526 ) FmtError!void {
527527 self.assertWritable();
528528 // TODO look at fmt and support other bases
lib/std/math/cbrt.zig+2-2
......@@ -14,8 +14,8 @@ const expect = std.testing.expect;
1414/// - cbrt(+-0) = +-0
1515/// - cbrt(+-inf) = +-inf
1616/// - cbrt(nan) = nan
17pub fn cbrt(x: var) @typeOf(x) {
18 const T = @typeOf(x);
17pub fn cbrt(x: var) @TypeOf(x) {
18 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => cbrt32(x),
2121 f64 => cbrt64(x),
lib/std/math/ceil.zig+2-2
......@@ -15,8 +15,8 @@ const expect = std.testing.expect;
1515/// - ceil(+-0) = +-0
1616/// - ceil(+-inf) = +-inf
1717/// - ceil(nan) = nan
18pub fn ceil(x: var) @typeOf(x) {
19 const T = @typeOf(x);
18pub fn ceil(x: var) @TypeOf(x) {
19 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => ceil32(x),
2222 f64 => ceil64(x),
lib/std/math/complex/abs.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the absolute value (modulus) of z.
8pub fn abs(z: var) @typeOf(z.re) {
9 const T = @typeOf(z.re);
8pub fn abs(z: var) @TypeOf(z.re) {
9 const T = @TypeOf(z.re);
1010 return math.hypot(T, z.re, z.im);
1111}
1212
lib/std/math/complex/acos.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the arc-cosine of z.
8pub fn acos(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn acos(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const q = cmath.asin(z);
1111 return Complex(T).new(@as(T, math.pi) / 2 - q.re, -q.im);
1212}
lib/std/math/complex/acosh.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the hyperbolic arc-cosine of z.
8pub fn acosh(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn acosh(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const q = cmath.acos(z);
1111 return Complex(T).new(-q.im, q.re);
1212}
lib/std/math/complex/arg.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the angular component (in radians) of z.
8pub fn arg(z: var) @typeOf(z.re) {
9 const T = @typeOf(z.re);
8pub fn arg(z: var) @TypeOf(z.re) {
9 const T = @TypeOf(z.re);
1010 return math.atan2(T, z.im, z.re);
1111}
1212
lib/std/math/complex/asin.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77// Returns the arc-sine of z.
8pub fn asin(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn asin(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const x = z.re;
1111 const y = z.im;
1212
lib/std/math/complex/asinh.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the hyperbolic arc-sine of z.
8pub fn asinh(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn asinh(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const q = Complex(T).new(-z.im, z.re);
1111 const r = cmath.asin(q);
1212 return Complex(T).new(r.im, -r.re);
lib/std/math/complex/atan.zig+2-2
......@@ -12,8 +12,8 @@ const cmath = math.complex;
1212const Complex = cmath.Complex;
1313
1414/// Returns the arc-tangent of z.
15pub fn atan(z: var) @typeOf(z) {
16 const T = @typeOf(z.re);
15pub fn atan(z: var) @TypeOf(z) {
16 const T = @TypeOf(z.re);
1717 return switch (T) {
1818 f32 => atan32(z),
1919 f64 => atan64(z),
lib/std/math/complex/atanh.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the hyperbolic arc-tangent of z.
8pub fn atanh(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn atanh(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const q = Complex(T).new(-z.im, z.re);
1111 const r = cmath.atan(q);
1212 return Complex(T).new(r.im, -r.re);
lib/std/math/complex/conj.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the complex conjugate of z.
8pub fn conj(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn conj(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 return Complex(T).new(z.re, -z.im);
1111}
1212
lib/std/math/complex/cos.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the cosine of z.
8pub fn cos(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn cos(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const p = Complex(T).new(-z.im, z.re);
1111 return cmath.cosh(p);
1212}
lib/std/math/complex/cosh.zig+2-2
......@@ -14,8 +14,8 @@ const Complex = cmath.Complex;
1414const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
1616/// Returns the hyperbolic arc-cosine of z.
17pub fn cosh(z: var) Complex(@typeOf(z.re)) {
18 const T = @typeOf(z.re);
17pub fn cosh(z: var) Complex(@TypeOf(z.re)) {
18 const T = @TypeOf(z.re);
1919 return switch (T) {
2020 f32 => cosh32(z),
2121 f64 => cosh64(z),
lib/std/math/complex/exp.zig+2-2
......@@ -14,8 +14,8 @@ const Complex = cmath.Complex;
1414const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
1616/// Returns e raised to the power of z (e^z).
17pub fn exp(z: var) @typeOf(z) {
18 const T = @typeOf(z.re);
17pub fn exp(z: var) @TypeOf(z) {
18 const T = @TypeOf(z.re);
1919
2020 return switch (T) {
2121 f32 => exp32(z),
lib/std/math/complex/ldexp.zig+2-2
......@@ -11,8 +11,8 @@ const cmath = math.complex;
1111const Complex = cmath.Complex;
1212
1313/// Returns exp(z) scaled to avoid overflow.
14pub fn ldexp_cexp(z: var, expt: i32) @typeOf(z) {
15 const T = @typeOf(z.re);
14pub fn ldexp_cexp(z: var, expt: i32) @TypeOf(z) {
15 const T = @TypeOf(z.re);
1616
1717 return switch (T) {
1818 f32 => ldexp_cexp32(z, expt),
lib/std/math/complex/log.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the natural logarithm of z.
8pub fn log(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn log(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const r = cmath.abs(z);
1111 const phi = cmath.arg(z);
1212
lib/std/math/complex/proj.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the projection of z onto the riemann sphere.
8pub fn proj(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn proj(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010
1111 if (math.isInf(z.re) or math.isInf(z.im)) {
1212 return Complex(T).new(math.inf(T), math.copysign(T, 0, z.re));
lib/std/math/complex/sin.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the sine of z.
8pub fn sin(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn sin(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const p = Complex(T).new(-z.im, z.re);
1111 const q = cmath.sinh(p);
1212 return Complex(T).new(q.im, -q.re);
lib/std/math/complex/sinh.zig+2-2
......@@ -14,8 +14,8 @@ const Complex = cmath.Complex;
1414const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
1616/// Returns the hyperbolic sine of z.
17pub fn sinh(z: var) @typeOf(z) {
18 const T = @typeOf(z.re);
17pub fn sinh(z: var) @TypeOf(z) {
18 const T = @TypeOf(z.re);
1919 return switch (T) {
2020 f32 => sinh32(z),
2121 f64 => sinh64(z),
lib/std/math/complex/sqrt.zig+2-2
......@@ -12,8 +12,8 @@ const Complex = cmath.Complex;
1212
1313/// Returns the square root of z. The real and imaginary parts of the result have the same sign
1414/// as the imaginary part of z.
15pub fn sqrt(z: var) @typeOf(z) {
16 const T = @typeOf(z.re);
15pub fn sqrt(z: var) @TypeOf(z) {
16 const T = @TypeOf(z.re);
1717
1818 return switch (T) {
1919 f32 => sqrt32(z),
lib/std/math/complex/tan.zig+2-2
......@@ -5,8 +5,8 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the tanget of z.
8pub fn tan(z: var) Complex(@typeOf(z.re)) {
9 const T = @typeOf(z.re);
8pub fn tan(z: var) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);
1010 const q = Complex(T).new(-z.im, z.re);
1111 const r = cmath.tanh(q);
1212 return Complex(T).new(r.im, -r.re);
lib/std/math/complex/tanh.zig+2-2
......@@ -12,8 +12,8 @@ const cmath = math.complex;
1212const Complex = cmath.Complex;
1313
1414/// Returns the hyperbolic tangent of z.
15pub fn tanh(z: var) @typeOf(z) {
16 const T = @typeOf(z.re);
15pub fn tanh(z: var) @TypeOf(z) {
16 const T = @TypeOf(z.re);
1717 return switch (T) {
1818 f32 => tanh32(z),
1919 f64 => tanh64(z),
lib/std/math/cos.zig+2-2
......@@ -13,8 +13,8 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - cos(+-inf) = nan
1515/// - cos(nan) = nan
16pub fn cos(x: var) @typeOf(x) {
17 const T = @typeOf(x);
16pub fn cos(x: var) @TypeOf(x) {
17 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => cos_(f32, x),
2020 f64 => cos_(f64, x),
lib/std/math/cosh.zig+2-2
......@@ -17,8 +17,8 @@ const maxInt = std.math.maxInt;
1717/// - cosh(+-0) = 1
1818/// - cosh(+-inf) = +inf
1919/// - cosh(nan) = nan
20pub fn cosh(x: var) @typeOf(x) {
21 const T = @typeOf(x);
20pub fn cosh(x: var) @TypeOf(x) {
21 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => cosh32(x),
2424 f64 => cosh64(x),
lib/std/math/exp.zig+2-2
......@@ -14,8 +14,8 @@ const builtin = @import("builtin");
1414/// Special Cases:
1515/// - exp(+inf) = +inf
1616/// - exp(nan) = nan
17pub fn exp(x: var) @typeOf(x) {
18 const T = @typeOf(x);
17pub fn exp(x: var) @TypeOf(x) {
18 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => exp32(x),
2121 f64 => exp64(x),
lib/std/math/exp2.zig+2-2
......@@ -13,8 +13,8 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - exp2(+inf) = +inf
1515/// - exp2(nan) = nan
16pub fn exp2(x: var) @typeOf(x) {
17 const T = @typeOf(x);
16pub fn exp2(x: var) @TypeOf(x) {
17 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => exp2_32(x),
2020 f64 => exp2_64(x),
lib/std/math/expm1.zig+2-2
......@@ -18,8 +18,8 @@ const expect = std.testing.expect;
1818/// - expm1(+inf) = +inf
1919/// - expm1(-inf) = -1
2020/// - expm1(nan) = nan
21pub fn expm1(x: var) @typeOf(x) {
22 const T = @typeOf(x);
21pub fn expm1(x: var) @TypeOf(x) {
22 const T = @TypeOf(x);
2323 return switch (T) {
2424 f32 => expm1_32(x),
2525 f64 => expm1_64(x),
lib/std/math/expo2.zig+2-2
......@@ -7,8 +7,8 @@
77const math = @import("../math.zig");
88
99/// Returns exp(x) / 2 for x >= log(maxFloat(T)).
10pub fn expo2(x: var) @typeOf(x) {
11 const T = @typeOf(x);
10pub fn expo2(x: var) @TypeOf(x) {
11 const T = @TypeOf(x);
1212 return switch (T) {
1313 f32 => expo2f(x),
1414 f64 => expo2d(x),
lib/std/math/fabs.zig+2-2
......@@ -14,8 +14,8 @@ const maxInt = std.math.maxInt;
1414/// Special Cases:
1515/// - fabs(+-inf) = +inf
1616/// - fabs(nan) = nan
17pub fn fabs(x: var) @typeOf(x) {
18 const T = @typeOf(x);
17pub fn fabs(x: var) @TypeOf(x) {
18 const T = @TypeOf(x);
1919 return switch (T) {
2020 f16 => fabs16(x),
2121 f32 => fabs32(x),
lib/std/math/floor.zig+2-2
......@@ -15,8 +15,8 @@ const math = std.math;
1515/// - floor(+-0) = +-0
1616/// - floor(+-inf) = +-inf
1717/// - floor(nan) = nan
18pub fn floor(x: var) @typeOf(x) {
19 const T = @typeOf(x);
18pub fn floor(x: var) @TypeOf(x) {
19 const T = @TypeOf(x);
2020 return switch (T) {
2121 f16 => floor16(x),
2222 f32 => floor32(x),
lib/std/math/frexp.zig+2-2
......@@ -24,8 +24,8 @@ pub const frexp64_result = frexp_result(f64);
2424/// - frexp(+-0) = +-0, 0
2525/// - frexp(+-inf) = +-inf, 0
2626/// - frexp(nan) = nan, undefined
27pub fn frexp(x: var) frexp_result(@typeOf(x)) {
28 const T = @typeOf(x);
27pub fn frexp(x: var) frexp_result(@TypeOf(x)) {
28 const T = @TypeOf(x);
2929 return switch (T) {
3030 f32 => frexp32(x),
3131 f64 => frexp64(x),
lib/std/math/ilogb.zig+1-1
......@@ -17,7 +17,7 @@ const minInt = std.math.minInt;
1717/// - ilogb(0) = maxInt(i32)
1818/// - ilogb(nan) = maxInt(i32)
1919pub fn ilogb(x: var) i32 {
20 const T = @typeOf(x);
20 const T = @TypeOf(x);
2121 return switch (T) {
2222 f32 => ilogb32(x),
2323 f64 => ilogb64(x),
lib/std/math/isfinite.zig+1-1
......@@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
55
66/// Returns whether x is a finite value.
77pub fn isFinite(x: var) bool {
8 const T = @typeOf(x);
8 const T = @TypeOf(x);
99 switch (T) {
1010 f16 => {
1111 const bits = @bitCast(u16, x);
lib/std/math/isinf.zig+3-3
......@@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
55
66/// Returns whether x is an infinity, ignoring sign.
77pub fn isInf(x: var) bool {
8 const T = @typeOf(x);
8 const T = @TypeOf(x);
99 switch (T) {
1010 f16 => {
1111 const bits = @bitCast(u16, x);
......@@ -31,7 +31,7 @@ pub fn isInf(x: var) bool {
3131
3232/// Returns whether x is an infinity with a positive sign.
3333pub fn isPositiveInf(x: var) bool {
34 const T = @typeOf(x);
34 const T = @TypeOf(x);
3535 switch (T) {
3636 f16 => {
3737 return @bitCast(u16, x) == 0x7C00;
......@@ -53,7 +53,7 @@ pub fn isPositiveInf(x: var) bool {
5353
5454/// Returns whether x is an infinity with a negative sign.
5555pub fn isNegativeInf(x: var) bool {
56 const T = @typeOf(x);
56 const T = @TypeOf(x);
5757 switch (T) {
5858 f16 => {
5959 return @bitCast(u16, x) == 0xFC00;
lib/std/math/isnormal.zig+1-1
......@@ -5,7 +5,7 @@ const maxInt = std.math.maxInt;
55
66// Returns whether x has a normalized representation (i.e. integer part of mantissa is 1).
77pub fn isNormal(x: var) bool {
8 const T = @typeOf(x);
8 const T = @TypeOf(x);
99 switch (T) {
1010 f16 => {
1111 const bits = @bitCast(u16, x);
lib/std/math/ln.zig+4-4
......@@ -17,11 +17,11 @@ const TypeId = builtin.TypeId;
1717/// - ln(0) = -inf
1818/// - ln(x) = nan if x < 0
1919/// - ln(nan) = nan
20pub fn ln(x: var) @typeOf(x) {
21 const T = @typeOf(x);
20pub fn ln(x: var) @TypeOf(x) {
21 const T = @TypeOf(x);
2222 switch (@typeId(T)) {
2323 TypeId.ComptimeFloat => {
24 return @typeOf(1.0)(ln_64(x));
24 return @TypeOf(1.0)(ln_64(x));
2525 },
2626 TypeId.Float => {
2727 return switch (T) {
......@@ -31,7 +31,7 @@ pub fn ln(x: var) @typeOf(x) {
3131 };
3232 },
3333 TypeId.ComptimeInt => {
34 return @typeOf(1)(math.floor(ln_64(@as(f64, x))));
34 return @TypeOf(1)(math.floor(ln_64(@as(f64, x))));
3535 },
3636 TypeId.Int => {
3737 return @as(T, math.floor(ln_64(@as(f64, x))));
lib/std/math/log.zig+2-2
......@@ -23,10 +23,10 @@ pub fn log(comptime T: type, base: T, x: T) T {
2323 const float_base = math.lossyCast(f64, base);
2424 switch (@typeId(T)) {
2525 TypeId.ComptimeFloat => {
26 return @typeOf(1.0)(math.ln(@as(f64, x)) / math.ln(float_base));
26 return @TypeOf(1.0)(math.ln(@as(f64, x)) / math.ln(float_base));
2727 },
2828 TypeId.ComptimeInt => {
29 return @typeOf(1)(math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
29 return @TypeOf(1)(math.floor(math.ln(@as(f64, x)) / math.ln(float_base)));
3030 },
3131 builtin.TypeId.Int => {
3232 // TODO implement integer log without using float math
lib/std/math/log10.zig+4-4
......@@ -18,11 +18,11 @@ const maxInt = std.math.maxInt;
1818/// - log10(0) = -inf
1919/// - log10(x) = nan if x < 0
2020/// - log10(nan) = nan
21pub fn log10(x: var) @typeOf(x) {
22 const T = @typeOf(x);
21pub fn log10(x: var) @TypeOf(x) {
22 const T = @TypeOf(x);
2323 switch (@typeId(T)) {
2424 TypeId.ComptimeFloat => {
25 return @typeOf(1.0)(log10_64(x));
25 return @TypeOf(1.0)(log10_64(x));
2626 },
2727 TypeId.Float => {
2828 return switch (T) {
......@@ -32,7 +32,7 @@ pub fn log10(x: var) @typeOf(x) {
3232 };
3333 },
3434 TypeId.ComptimeInt => {
35 return @typeOf(1)(math.floor(log10_64(@as(f64, x))));
35 return @TypeOf(1)(math.floor(log10_64(@as(f64, x))));
3636 },
3737 TypeId.Int => {
3838 return @floatToInt(T, math.floor(log10_64(@intToFloat(f64, x))));
lib/std/math/log1p.zig+2-2
......@@ -17,8 +17,8 @@ const expect = std.testing.expect;
1717/// - log1p(-1) = -inf
1818/// - log1p(x) = nan if x < -1
1919/// - log1p(nan) = nan
20pub fn log1p(x: var) @typeOf(x) {
21 const T = @typeOf(x);
20pub fn log1p(x: var) @TypeOf(x) {
21 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => log1p_32(x),
2424 f64 => log1p_64(x),
lib/std/math/log2.zig+3-3
......@@ -18,11 +18,11 @@ const maxInt = std.math.maxInt;
1818/// - log2(0) = -inf
1919/// - log2(x) = nan if x < 0
2020/// - log2(nan) = nan
21pub fn log2(x: var) @typeOf(x) {
22 const T = @typeOf(x);
21pub fn log2(x: var) @TypeOf(x) {
22 const T = @TypeOf(x);
2323 switch (@typeId(T)) {
2424 TypeId.ComptimeFloat => {
25 return @typeOf(1.0)(log2_64(x));
25 return @TypeOf(1.0)(log2_64(x));
2626 },
2727 TypeId.Float => {
2828 return switch (T) {
lib/std/math/modf.zig+2-2
......@@ -24,8 +24,8 @@ pub const modf64_result = modf_result(f64);
2424/// Special Cases:
2525/// - modf(+-inf) = +-inf, nan
2626/// - modf(nan) = nan, nan
27pub fn modf(x: var) modf_result(@typeOf(x)) {
28 const T = @typeOf(x);
27pub fn modf(x: var) modf_result(@TypeOf(x)) {
28 const T = @TypeOf(x);
2929 return switch (T) {
3030 f32 => modf32(x),
3131 f64 => modf64(x),
lib/std/math/round.zig+2-2
......@@ -15,8 +15,8 @@ const math = std.math;
1515/// - round(+-0) = +-0
1616/// - round(+-inf) = +-inf
1717/// - round(nan) = nan
18pub fn round(x: var) @typeOf(x) {
19 const T = @typeOf(x);
18pub fn round(x: var) @TypeOf(x) {
19 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => round32(x),
2222 f64 => round64(x),
lib/std/math/scalbn.zig+2-2
......@@ -9,8 +9,8 @@ const math = std.math;
99const expect = std.testing.expect;
1010
1111/// Returns x * 2^n.
12pub fn scalbn(x: var, n: i32) @typeOf(x) {
13 const T = @typeOf(x);
12pub fn scalbn(x: var, n: i32) @TypeOf(x) {
13 const T = @TypeOf(x);
1414 return switch (T) {
1515 f32 => scalbn32(x, n),
1616 f64 => scalbn64(x, n),
lib/std/math/signbit.zig+1-1
......@@ -4,7 +4,7 @@ const expect = std.testing.expect;
44
55/// Returns whether x is negative or negative 0.
66pub fn signbit(x: var) bool {
7 const T = @typeOf(x);
7 const T = @TypeOf(x);
88 return switch (T) {
99 f16 => signbit16(x),
1010 f32 => signbit32(x),
lib/std/math/sin.zig+2-2
......@@ -14,8 +14,8 @@ const expect = std.testing.expect;
1414/// - sin(+-0) = +-0
1515/// - sin(+-inf) = nan
1616/// - sin(nan) = nan
17pub fn sin(x: var) @typeOf(x) {
18 const T = @typeOf(x);
17pub fn sin(x: var) @TypeOf(x) {
18 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => sin_(T, x),
2121 f64 => sin_(T, x),
lib/std/math/sinh.zig+2-2
......@@ -17,8 +17,8 @@ const maxInt = std.math.maxInt;
1717/// - sinh(+-0) = +-0
1818/// - sinh(+-inf) = +-inf
1919/// - sinh(nan) = nan
20pub fn sinh(x: var) @typeOf(x) {
21 const T = @typeOf(x);
20pub fn sinh(x: var) @TypeOf(x) {
21 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => sinh32(x),
2424 f64 => sinh64(x),
lib/std/math/sqrt.zig+2-2
......@@ -12,8 +12,8 @@ const maxInt = std.math.maxInt;
1212/// - sqrt(+-0) = +-0
1313/// - sqrt(x) = nan if x < 0
1414/// - sqrt(nan) = nan
15pub fn sqrt(x: var) (if (@typeId(@typeOf(x)) == TypeId.Int) @IntType(false, @typeOf(x).bit_count / 2) else @typeOf(x)) {
16 const T = @typeOf(x);
15pub fn sqrt(x: var) (if (@typeId(@TypeOf(x)) == TypeId.Int) @IntType(false, @TypeOf(x).bit_count / 2) else @TypeOf(x)) {
16 const T = @TypeOf(x);
1717 switch (@typeId(T)) {
1818 TypeId.ComptimeFloat => return @as(T, @sqrt(f64, x)), // TODO upgrade to f128
1919 TypeId.Float => return @sqrt(T, x),
lib/std/math/tan.zig+2-2
......@@ -14,8 +14,8 @@ const expect = std.testing.expect;
1414/// - tan(+-0) = +-0
1515/// - tan(+-inf) = nan
1616/// - tan(nan) = nan
17pub fn tan(x: var) @typeOf(x) {
18 const T = @typeOf(x);
17pub fn tan(x: var) @TypeOf(x) {
18 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => tan_(f32, x),
2121 f64 => tan_(f64, x),
lib/std/math/tanh.zig+2-2
......@@ -17,8 +17,8 @@ const maxInt = std.math.maxInt;
1717/// - sinh(+-0) = +-0
1818/// - sinh(+-inf) = +-1
1919/// - sinh(nan) = nan
20pub fn tanh(x: var) @typeOf(x) {
21 const T = @typeOf(x);
20pub fn tanh(x: var) @TypeOf(x) {
21 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => tanh32(x),
2424 f64 => tanh64(x),
lib/std/math/trunc.zig+2-2
......@@ -15,8 +15,8 @@ const maxInt = std.math.maxInt;
1515/// - trunc(+-0) = +-0
1616/// - trunc(+-inf) = +-inf
1717/// - trunc(nan) = nan
18pub fn trunc(x: var) @typeOf(x) {
19 const T = @typeOf(x);
18pub fn trunc(x: var) @TypeOf(x) {
19 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => trunc32(x),
2222 f64 => trunc64(x),
lib/std/mem.zig+18-18
......@@ -86,7 +86,7 @@ pub const Allocator = struct {
8686 /// `ptr` should be the return value of `create`, or otherwise
8787 /// have the same address and alignment property.
8888 pub fn destroy(self: *Allocator, ptr: var) void {
89 const T = @typeOf(ptr).Child;
89 const T = @TypeOf(ptr).Child;
9090 if (@sizeOf(T) == 0) return;
9191 const non_const_ptr = @intToPtr([*]u8, @ptrToInt(ptr));
9292 const shrink_result = self.shrinkFn(self, non_const_ptr[0..@sizeOf(T)], @alignOf(T), 0, 1);
......@@ -147,10 +147,10 @@ pub const Allocator = struct {
147147 /// If you need guaranteed success, call `shrink`.
148148 /// If `new_n` is 0, this is the same as `free` and it always succeeds.
149149 pub fn realloc(self: *Allocator, old_mem: var, new_n: usize) t: {
150 const Slice = @typeInfo(@typeOf(old_mem)).Pointer;
150 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
151151 break :t Error![]align(Slice.alignment) Slice.child;
152152 } {
153 const old_alignment = @typeInfo(@typeOf(old_mem)).Pointer.alignment;
153 const old_alignment = @typeInfo(@TypeOf(old_mem)).Pointer.alignment;
154154 return self.alignedRealloc(old_mem, old_alignment, new_n);
155155 }
156156
......@@ -162,8 +162,8 @@ pub const Allocator = struct {
162162 old_mem: var,
163163 comptime new_alignment: u29,
164164 new_n: usize,
165 ) Error![]align(new_alignment) @typeInfo(@typeOf(old_mem)).Pointer.child {
166 const Slice = @typeInfo(@typeOf(old_mem)).Pointer;
165 ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {
166 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
167167 const T = Slice.child;
168168 if (old_mem.len == 0) {
169169 return self.alignedAlloc(T, new_alignment, new_n);
......@@ -189,10 +189,10 @@ pub const Allocator = struct {
189189 /// Returned slice has same alignment as old_mem.
190190 /// Shrinking to 0 is the same as calling `free`.
191191 pub fn shrink(self: *Allocator, old_mem: var, new_n: usize) t: {
192 const Slice = @typeInfo(@typeOf(old_mem)).Pointer;
192 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
193193 break :t []align(Slice.alignment) Slice.child;
194194 } {
195 const old_alignment = @typeInfo(@typeOf(old_mem)).Pointer.alignment;
195 const old_alignment = @typeInfo(@TypeOf(old_mem)).Pointer.alignment;
196196 return self.alignedShrink(old_mem, old_alignment, new_n);
197197 }
198198
......@@ -204,8 +204,8 @@ pub const Allocator = struct {
204204 old_mem: var,
205205 comptime new_alignment: u29,
206206 new_n: usize,
207 ) []align(new_alignment) @typeInfo(@typeOf(old_mem)).Pointer.child {
208 const Slice = @typeInfo(@typeOf(old_mem)).Pointer;
207 ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {
208 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
209209 const T = Slice.child;
210210
211211 if (new_n == 0) {
......@@ -229,7 +229,7 @@ pub const Allocator = struct {
229229 /// Free an array allocated with `alloc`. To free a single item,
230230 /// see `destroy`.
231231 pub fn free(self: *Allocator, memory: var) void {
232 const Slice = @typeInfo(@typeOf(memory)).Pointer;
232 const Slice = @typeInfo(@TypeOf(memory)).Pointer;
233233 const bytes = @sliceToBytes(memory);
234234 if (bytes.len == 0) return;
235235 const non_const_ptr = @intToPtr([*]u8, @ptrToInt(bytes.ptr));
......@@ -1323,8 +1323,8 @@ fn AsBytesReturnType(comptime P: type) type {
13231323}
13241324
13251325///Given a pointer to a single item, returns a slice of the underlying bytes, preserving constness.
1326pub fn asBytes(ptr: var) AsBytesReturnType(@typeOf(ptr)) {
1327 const P = @typeOf(ptr);
1326pub fn asBytes(ptr: var) AsBytesReturnType(@TypeOf(ptr)) {
1327 const P = @TypeOf(ptr);
13281328 return @ptrCast(AsBytesReturnType(P), ptr);
13291329}
13301330
......@@ -1363,7 +1363,7 @@ test "asBytes" {
13631363}
13641364
13651365///Given any value, returns a copy of its bytes in an array.
1366pub fn toBytes(value: var) [@sizeOf(@typeOf(value))]u8 {
1366pub fn toBytes(value: var) [@sizeOf(@TypeOf(value))]u8 {
13671367 return asBytes(&value).*;
13681368}
13691369
......@@ -1397,8 +1397,8 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
13971397
13981398///Given a pointer to an array of bytes, returns a pointer to a value of the specified type
13991399/// backed by those bytes, preserving constness.
1400pub fn bytesAsValue(comptime T: type, bytes: var) BytesAsValueReturnType(T, @typeOf(bytes)) {
1401 return @ptrCast(BytesAsValueReturnType(T, @typeOf(bytes)), bytes);
1400pub fn bytesAsValue(comptime T: type, bytes: var) BytesAsValueReturnType(T, @TypeOf(bytes)) {
1401 return @ptrCast(BytesAsValueReturnType(T, @TypeOf(bytes)), bytes);
14021402}
14031403
14041404test "bytesAsValue" {
......@@ -1460,11 +1460,11 @@ fn SubArrayPtrReturnType(comptime T: type, comptime length: usize) type {
14601460}
14611461
14621462///Given a pointer to an array, returns a pointer to a portion of that array, preserving constness.
1463pub fn subArrayPtr(ptr: var, comptime start: usize, comptime length: usize) SubArrayPtrReturnType(@typeOf(ptr), length) {
1463pub fn subArrayPtr(ptr: var, comptime start: usize, comptime length: usize) SubArrayPtrReturnType(@TypeOf(ptr), length) {
14641464 assert(start + length <= ptr.*.len);
14651465
1466 const ReturnType = SubArrayPtrReturnType(@typeOf(ptr), length);
1467 const T = meta.Child(meta.Child(@typeOf(ptr)));
1466 const ReturnType = SubArrayPtrReturnType(@TypeOf(ptr), length);
1467 const T = meta.Child(meta.Child(@TypeOf(ptr)));
14681468 return @ptrCast(ReturnType, &ptr[start]);
14691469}
14701470
lib/std/meta.zig+7-7
......@@ -11,7 +11,7 @@ const TypeId = builtin.TypeId;
1111const TypeInfo = builtin.TypeInfo;
1212
1313pub fn tagName(v: var) []const u8 {
14 const T = @typeOf(v);
14 const T = @TypeOf(v);
1515 switch (@typeInfo(T)) {
1616 TypeId.ErrorSet => return @errorName(v),
1717 else => return @tagName(v),
......@@ -339,8 +339,8 @@ test "std.meta.TagType" {
339339}
340340
341341///Returns the active tag of a tagged union
342pub fn activeTag(u: var) @TagType(@typeOf(u)) {
343 const T = @typeOf(u);
342pub fn activeTag(u: var) @TagType(@TypeOf(u)) {
343 const T = @TypeOf(u);
344344 return @as(@TagType(T), u);
345345}
346346
......@@ -365,7 +365,7 @@ test "std.meta.activeTag" {
365365///Given a tagged union type, and an enum, return the type of the union
366366/// field corresponding to the enum tag.
367367pub fn TagPayloadType(comptime U: type, tag: var) type {
368 const Tag = @typeOf(tag);
368 const Tag = @TypeOf(tag);
369369 testing.expect(trait.is(builtin.TypeId.Union)(U));
370370 testing.expect(trait.is(builtin.TypeId.Enum)(Tag));
371371
......@@ -386,13 +386,13 @@ test "std.meta.TagPayloadType" {
386386 };
387387 const MovedEvent = TagPayloadType(Event, Event.Moved);
388388 var e: Event = undefined;
389 testing.expect(MovedEvent == @typeOf(e.Moved));
389 testing.expect(MovedEvent == @TypeOf(e.Moved));
390390}
391391
392392///Compares two of any type for equality. Containers are compared on a field-by-field basis,
393393/// where possible. Pointers are not followed.
394pub fn eql(a: var, b: @typeOf(a)) bool {
395 const T = @typeOf(a);
394pub fn eql(a: var, b: @TypeOf(a)) bool {
395 const T = @TypeOf(a);
396396
397397 switch (@typeId(T)) {
398398 builtin.TypeId.Struct => {
lib/std/meta/trait.zig+21-21
......@@ -13,7 +13,7 @@ fn traitFnWorkaround(comptime T: type) bool {
1313 return false;
1414}
1515
16pub const TraitFn = @typeOf(traitFnWorkaround);
16pub const TraitFn = @TypeOf(traitFnWorkaround);
1717///
1818
1919//////Trait generators
......@@ -61,7 +61,7 @@ pub fn hasFn(comptime name: []const u8) TraitFn {
6161 pub fn trait(comptime T: type) bool {
6262 if (!comptime isContainer(T)) return false;
6363 if (!comptime @hasDecl(T, name)) return false;
64 const DeclType = @typeOf(@field(T, name));
64 const DeclType = @TypeOf(@field(T, name));
6565 const decl_type_id = @typeId(DeclType);
6666 return decl_type_id == builtin.TypeId.Fn;
6767 }
......@@ -236,9 +236,9 @@ pub fn isSingleItemPtr(comptime T: type) bool {
236236
237237test "std.meta.trait.isSingleItemPtr" {
238238 const array = [_]u8{0} ** 10;
239 testing.expect(isSingleItemPtr(@typeOf(&array[0])));
240 testing.expect(!isSingleItemPtr(@typeOf(array)));
241 testing.expect(!isSingleItemPtr(@typeOf(array[0..1])));
239 testing.expect(isSingleItemPtr(@TypeOf(&array[0])));
240 testing.expect(!isSingleItemPtr(@TypeOf(array)));
241 testing.expect(!isSingleItemPtr(@TypeOf(array[0..1])));
242242}
243243
244244///
......@@ -253,9 +253,9 @@ pub fn isManyItemPtr(comptime T: type) bool {
253253test "std.meta.trait.isManyItemPtr" {
254254 const array = [_]u8{0} ** 10;
255255 const mip = @ptrCast([*]const u8, &array[0]);
256 testing.expect(isManyItemPtr(@typeOf(mip)));
257 testing.expect(!isManyItemPtr(@typeOf(array)));
258 testing.expect(!isManyItemPtr(@typeOf(array[0..1])));
256 testing.expect(isManyItemPtr(@TypeOf(mip)));
257 testing.expect(!isManyItemPtr(@TypeOf(array)));
258 testing.expect(!isManyItemPtr(@TypeOf(array[0..1])));
259259}
260260
261261///
......@@ -269,9 +269,9 @@ pub fn isSlice(comptime T: type) bool {
269269
270270test "std.meta.trait.isSlice" {
271271 const array = [_]u8{0} ** 10;
272 testing.expect(isSlice(@typeOf(array[0..])));
273 testing.expect(!isSlice(@typeOf(array)));
274 testing.expect(!isSlice(@typeOf(&array[0])));
272 testing.expect(isSlice(@TypeOf(array[0..])));
273 testing.expect(!isSlice(@TypeOf(array)));
274 testing.expect(!isSlice(@TypeOf(&array[0])));
275275}
276276
277277///
......@@ -291,10 +291,10 @@ test "std.meta.trait.isIndexable" {
291291 const array = [_]u8{0} ** 10;
292292 const slice = array[0..];
293293
294 testing.expect(isIndexable(@typeOf(array)));
295 testing.expect(isIndexable(@typeOf(&array)));
296 testing.expect(isIndexable(@typeOf(slice)));
297 testing.expect(!isIndexable(meta.Child(@typeOf(slice))));
294 testing.expect(isIndexable(@TypeOf(array)));
295 testing.expect(isIndexable(@TypeOf(&array)));
296 testing.expect(isIndexable(@TypeOf(slice)));
297 testing.expect(!isIndexable(meta.Child(@TypeOf(slice))));
298298}
299299
300300///
......@@ -313,8 +313,8 @@ test "std.meta.trait.isNumber" {
313313 testing.expect(isNumber(u32));
314314 testing.expect(isNumber(f32));
315315 testing.expect(isNumber(u64));
316 testing.expect(isNumber(@typeOf(102)));
317 testing.expect(isNumber(@typeOf(102.123)));
316 testing.expect(isNumber(@TypeOf(102)));
317 testing.expect(isNumber(@TypeOf(102.123)));
318318 testing.expect(!isNumber([]u8));
319319 testing.expect(!isNumber(NotANumber));
320320}
......@@ -328,10 +328,10 @@ pub fn isConstPtr(comptime T: type) bool {
328328test "std.meta.trait.isConstPtr" {
329329 var t = @as(u8, 0);
330330 const c = @as(u8, 0);
331 testing.expect(isConstPtr(*const @typeOf(t)));
332 testing.expect(isConstPtr(@typeOf(&c)));
333 testing.expect(!isConstPtr(*@typeOf(t)));
334 testing.expect(!isConstPtr(@typeOf(6)));
331 testing.expect(isConstPtr(*const @TypeOf(t)));
332 testing.expect(isConstPtr(@TypeOf(&c)));
333 testing.expect(!isConstPtr(*@TypeOf(t)));
334 testing.expect(!isConstPtr(@TypeOf(6)));
335335}
336336
337337pub fn isContainer(comptime T: type) bool {
lib/std/mutex.zig+1-1
......@@ -11,7 +11,7 @@ const ResetEvent = std.ResetEvent;
1111/// no-ops. In single threaded debug mode, there is deadlock detection.
1212pub const Mutex = if (builtin.single_threaded)
1313 struct {
14 lock: @typeOf(lock_init),
14 lock: @TypeOf(lock_init),
1515
1616 const lock_init = if (std.debug.runtime_safety) false else {};
1717
lib/std/net.zig+1-1
......@@ -271,7 +271,7 @@ pub const Address = extern union {
271271 options: std.fmt.FormatOptions,
272272 context: var,
273273 comptime Errors: type,
274 output: fn (@typeOf(context), []const u8) Errors!void,
274 output: fn (@TypeOf(context), []const u8) Errors!void,
275275 ) !void {
276276 switch (self.any.family) {
277277 os.AF_INET => {
lib/std/os.zig+1-1
......@@ -2974,7 +2974,7 @@ pub fn res_mkquery(
29742974 // Make a reasonably unpredictable id
29752975 var ts: timespec = undefined;
29762976 clock_gettime(CLOCK_REALTIME, &ts) catch {};
2977 const UInt = @IntType(false, @typeOf(ts.tv_nsec).bit_count);
2977 const UInt = @IntType(false, @TypeOf(ts.tv_nsec).bit_count);
29782978 const unsec = @bitCast(UInt, ts.tv_nsec);
29792979 const id = @truncate(u32, unsec + unsec / 65536);
29802980 q[0] = @truncate(u8, id / 256);
lib/std/os/linux.zig+2-2
......@@ -706,7 +706,7 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
706706 .restorer = @ptrCast(extern fn () void, restorer_fn),
707707 };
708708 var ksa_old: k_sigaction = undefined;
709 const ksa_mask_size = @sizeOf(@typeOf(ksa_old.mask));
709 const ksa_mask_size = @sizeOf(@TypeOf(ksa_old.mask));
710710 @memcpy(@ptrCast([*]u8, &ksa.mask), @ptrCast([*]const u8, &act.mask), ksa_mask_size);
711711 const result = syscall4(SYS_rt_sigaction, sig, @ptrToInt(&ksa), @ptrToInt(&ksa_old), ksa_mask_size);
712712 const err = getErrno(result);
......@@ -786,7 +786,7 @@ pub fn sendmsg(fd: i32, msg: *msghdr_const, flags: u32) usize {
786786}
787787
788788pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize {
789 if (@typeInfo(usize).Int.bits > @typeInfo(@typeOf(mmsghdr(undefined).msg_len)).Int.bits) {
789 if (@typeInfo(usize).Int.bits > @typeInfo(@TypeOf(mmsghdr(undefined).msg_len)).Int.bits) {
790790 // workaround kernel brokenness:
791791 // if adding up all iov_len overflows a i32 then split into multiple calls
792792 // see https://www.openwall.com/lists/musl/2014/06/07/5
lib/std/os/uefi.zig+1-1
......@@ -32,7 +32,7 @@ pub const Guid = extern struct {
3232 options: fmt.FormatOptions,
3333 context: var,
3434 comptime Errors: type,
35 output: fn (@typeOf(context), []const u8) Errors!void,
35 output: fn (@TypeOf(context), []const u8) Errors!void,
3636 ) Errors!void {
3737 if (f.len == 0) {
3838 return fmt.format(context, Errors, output, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", self.time_low, self.time_mid, self.time_high_and_version, self.clock_seq_high_and_reserved, self.clock_seq_low, self.node);
lib/std/os/windows/kernel32.zig+2-2
......@@ -214,12 +214,12 @@ pub extern "kernel32" stdcallcc fn WaitForSingleObject(hHandle: HANDLE, dwMillis
214214
215215pub extern "kernel32" stdcallcc fn WaitForSingleObjectEx(hHandle: HANDLE, dwMilliseconds: DWORD, bAlertable: BOOL) DWORD;
216216
217pub extern "kernel32" stdcallcc fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll:BOOL, dwMilliseconds: DWORD) DWORD;
217pub extern "kernel32" stdcallcc fn WaitForMultipleObjects(nCount: DWORD, lpHandle: [*]const HANDLE, bWaitAll: BOOL, dwMilliseconds: DWORD) DWORD;
218218
219219pub extern "kernel32" stdcallcc fn WaitForMultipleObjectsEx(
220220 nCount: DWORD,
221221 lpHandle: [*]const HANDLE,
222 bWaitAll:BOOL,
222 bWaitAll: BOOL,
223223 dwMilliseconds: DWORD,
224224 bAlertable: BOOL,
225225) DWORD;
lib/std/pdb.zig+1-1
......@@ -635,7 +635,7 @@ const MsfStream = struct {
635635 /// Implementation of InStream trait for Pdb.MsfStream
636636 stream: Stream = undefined,
637637
638 pub const Error = @typeOf(read).ReturnType.ErrorSet;
638 pub const Error = @TypeOf(read).ReturnType.ErrorSet;
639639 pub const Stream = io.InStream(Error);
640640
641641 fn init(block_size: u32, file: File, blocks: []u32) MsfStream {
lib/std/reset_event.zig+7-7
......@@ -27,7 +27,7 @@ pub const ResetEvent = struct {
2727 pub fn isSet(self: *ResetEvent) bool {
2828 return self.os_event.isSet();
2929 }
30
30
3131 /// Sets the event if not already set and
3232 /// wakes up AT LEAST one thread waiting the event.
3333 /// Returns whether or not a thread was woken up.
......@@ -62,7 +62,7 @@ const OsEvent = if (builtin.single_threaded) DebugEvent else switch (builtin.os)
6262};
6363
6464const DebugEvent = struct {
65 is_set: @typeOf(set_init),
65 is_set: @TypeOf(set_init),
6666
6767 const set_init = if (std.debug.runtime_safety) false else {};
6868
......@@ -283,7 +283,7 @@ const PosixEvent = struct {
283283
284284 pub fn init() PosixEvent {
285285 return PosixEvent{
286 .state = .0,
286 .state = 0,
287287 .cond = c.PTHREAD_COND_INITIALIZER,
288288 .mutex = c.PTHREAD_MUTEX_INITIALIZER,
289289 };
......@@ -345,8 +345,8 @@ const PosixEvent = struct {
345345 timeout_abs += @intCast(u64, ts.tv_sec) * time.second;
346346 timeout_abs += @intCast(u64, ts.tv_nsec);
347347 }
348 ts.tv_sec = @intCast(@typeOf(ts.tv_sec), @divFloor(timeout_abs, time.second));
349 ts.tv_nsec = @intCast(@typeOf(ts.tv_nsec), @mod(timeout_abs, time.second));
348 ts.tv_sec = @intCast(@TypeOf(ts.tv_sec), @divFloor(timeout_abs, time.second));
349 ts.tv_nsec = @intCast(@TypeOf(ts.tv_nsec), @mod(timeout_abs, time.second));
350350 }
351351
352352 var dummy_value: u32 = undefined;
......@@ -426,8 +426,8 @@ test "std.ResetEvent" {
426426 .event = event,
427427 .value = 0,
428428 };
429
429
430430 var receiver = try std.Thread.spawn(&context, Context.receiver);
431431 defer receiver.wait();
432432 try context.sender();
433}
\ No newline at end of file
433}
lib/std/segmented_list.zig+2-2
......@@ -122,7 +122,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
122122 self.* = undefined;
123123 }
124124
125 pub fn at(self: var, i: usize) AtType(@typeOf(self)) {
125 pub fn at(self: var, i: usize) AtType(@TypeOf(self)) {
126126 assert(i < self.len);
127127 return self.uncheckedAt(i);
128128 }
......@@ -213,7 +213,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
213213 self.len = new_len;
214214 }
215215
216 pub fn uncheckedAt(self: var, index: usize) AtType(@typeOf(self)) {
216 pub fn uncheckedAt(self: var, index: usize) AtType(@TypeOf(self)) {
217217 if (index < prealloc_item_count) {
218218 return &self.prealloc_segment[index];
219219 }
lib/std/special/build_runner.zig+1-1
......@@ -125,7 +125,7 @@ pub fn main() !void {
125125}
126126
127127fn runBuild(builder: *Builder) anyerror!void {
128 switch (@typeId(@typeOf(root.build).ReturnType)) {
128 switch (@typeId(@TypeOf(root.build).ReturnType)) {
129129 .Void => root.build(builder),
130130 .ErrorUnion => try root.build(builder),
131131 else => @compileError("expected return type of build to be 'void' or '!void'"),
lib/std/special/compiler_rt.zig+4-4
......@@ -384,7 +384,7 @@ extern fn __aeabi_uidivmod(n: u32, d: u32) extern struct {
384384} {
385385 @setRuntimeSafety(is_test);
386386
387 var result: @typeOf(__aeabi_uidivmod).ReturnType = undefined;
387 var result: @TypeOf(__aeabi_uidivmod).ReturnType = undefined;
388388 result.q = __udivmodsi4(n, d, &result.r);
389389 return result;
390390}
......@@ -395,7 +395,7 @@ extern fn __aeabi_uldivmod(n: u64, d: u64) extern struct {
395395} {
396396 @setRuntimeSafety(is_test);
397397
398 var result: @typeOf(__aeabi_uldivmod).ReturnType = undefined;
398 var result: @TypeOf(__aeabi_uldivmod).ReturnType = undefined;
399399 result.q = __udivmoddi4(n, d, &result.r);
400400 return result;
401401}
......@@ -406,7 +406,7 @@ extern fn __aeabi_idivmod(n: i32, d: i32) extern struct {
406406} {
407407 @setRuntimeSafety(is_test);
408408
409 var result: @typeOf(__aeabi_idivmod).ReturnType = undefined;
409 var result: @TypeOf(__aeabi_idivmod).ReturnType = undefined;
410410 result.q = __divmodsi4(n, d, &result.r);
411411 return result;
412412}
......@@ -417,7 +417,7 @@ extern fn __aeabi_ldivmod(n: i64, d: i64) extern struct {
417417} {
418418 @setRuntimeSafety(is_test);
419419
420 var result: @typeOf(__aeabi_ldivmod).ReturnType = undefined;
420 var result: @TypeOf(__aeabi_ldivmod).ReturnType = undefined;
421421 result.q = __divmoddi4(n, d, &result.r);
422422 return result;
423423}
lib/std/special/start.zig+4-4
......@@ -25,7 +25,7 @@ comptime {
2525 }
2626 } else if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
2727 if (builtin.link_libc and @hasDecl(root, "main")) {
28 if (@typeInfo(@typeOf(root.main)).Fn.calling_convention != .C) {
28 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {
2929 @export("main", main, .Weak);
3030 }
3131 } else if (builtin.os == .windows) {
......@@ -69,7 +69,7 @@ extern fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) u
6969 uefi.handle = handle;
7070 uefi.system_table = system_table;
7171
72 switch (@typeInfo(@typeOf(root.main).ReturnType)) {
72 switch (@typeInfo(@TypeOf(root.main).ReturnType)) {
7373 .NoReturn => {
7474 root.main();
7575 },
......@@ -248,7 +248,7 @@ async fn callMainAsync(loop: *std.event.Loop) u8 {
248248// This is not marked inline because it is called with @asyncCall when
249249// there is an event loop.
250250fn callMain() u8 {
251 switch (@typeInfo(@typeOf(root.main).ReturnType)) {
251 switch (@typeInfo(@TypeOf(root.main).ReturnType)) {
252252 .NoReturn => {
253253 root.main();
254254 },
......@@ -270,7 +270,7 @@ fn callMain() u8 {
270270 }
271271 return 1;
272272 };
273 switch (@typeInfo(@typeOf(result))) {
273 switch (@typeInfo(@TypeOf(result))) {
274274 .Void => return 0,
275275 .Int => |info| {
276276 if (info.bits != 8) {
lib/std/testing.zig+5-5
......@@ -21,14 +21,14 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
2121/// equal, prints diagnostics to stderr to show exactly how they are not equal,
2222/// then aborts.
2323/// The types must match exactly.
24pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
25 switch (@typeInfo(@typeOf(actual))) {
24pub fn expectEqual(expected: var, actual: @TypeOf(expected)) void {
25 switch (@typeInfo(@TypeOf(actual))) {
2626 .NoReturn,
2727 .BoundFn,
2828 .Opaque,
2929 .Frame,
3030 .AnyFrame,
31 => @compileError("value of type " ++ @typeName(@typeOf(actual)) ++ " encountered"),
31 => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),
3232
3333 .Undefined,
3434 .Null,
......@@ -87,7 +87,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
8787 @compileError("Unable to compare untagged union values");
8888 }
8989
90 const TagType = @TagType(@typeOf(expected));
90 const TagType = @TagType(@TypeOf(expected));
9191
9292 const expectedTag = @as(TagType, expected);
9393 const actualTag = @as(TagType, actual);
......@@ -95,7 +95,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
9595 expectEqual(expectedTag, actualTag);
9696
9797 // we only reach this loop if the tags are equal
98 inline for (std.meta.fields(@typeOf(actual))) |fld| {
98 inline for (std.meta.fields(@TypeOf(actual))) |fld| {
9999 if (std.mem.eql(u8, fld.name, @tagName(actualTag))) {
100100 expectEqual(@field(expected, fld.name), @field(actual, fld.name));
101101 return;
lib/std/thread.zig+5-5
......@@ -138,7 +138,7 @@ pub const Thread = struct {
138138 };
139139
140140 /// caller must call wait on the returned thread
141 /// fn startFn(@typeOf(context)) T
141 /// fn startFn(@TypeOf(context)) T
142142 /// where T is u8, noreturn, void, or !void
143143 /// caller must call wait on the returned thread
144144 pub fn spawn(context: var, comptime startFn: var) SpawnError!*Thread {
......@@ -147,8 +147,8 @@ pub const Thread = struct {
147147 // https://github.com/ziglang/zig/issues/157
148148 const default_stack_size = 16 * 1024 * 1024;
149149
150 const Context = @typeOf(context);
151 comptime assert(@ArgType(@typeOf(startFn), 0) == Context);
150 const Context = @TypeOf(context);
151 comptime assert(@ArgType(@TypeOf(startFn), 0) == Context);
152152
153153 if (builtin.os == builtin.Os.windows) {
154154 const WinThread = struct {
......@@ -158,7 +158,7 @@ pub const Thread = struct {
158158 };
159159 extern fn threadMain(raw_arg: windows.LPVOID) windows.DWORD {
160160 const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*;
161 switch (@typeId(@typeOf(startFn).ReturnType)) {
161 switch (@typeId(@TypeOf(startFn).ReturnType)) {
162162 .Int => {
163163 return startFn(arg);
164164 },
......@@ -201,7 +201,7 @@ pub const Thread = struct {
201201 extern fn linuxThreadMain(ctx_addr: usize) u8 {
202202 const arg = if (@sizeOf(Context) == 0) {} else @intToPtr(*const Context, ctx_addr).*;
203203
204 switch (@typeId(@typeOf(startFn).ReturnType)) {
204 switch (@typeId(@TypeOf(startFn).ReturnType)) {
205205 .Int => {
206206 return startFn(arg);
207207 },
lib/std/zig/parser_test.zig+13-2
......@@ -1,3 +1,14 @@
1// TODO: Remove condition after deprecating 'typeOf'. See https://github.com/ziglang/zig/issues/1348
2test "zig fmt: change @typeOf to @TypeOf" {
3 try testTransform(
4 \\const a = @typeOf(@as(usize, 10));
5 \\
6 ,
7 \\const a = @TypeOf(@as(usize, 10));
8 \\
9 );
10}
11
112test "zig fmt: comptime struct field" {
213 try testCanonical(
314 \\const Foo = struct {
......@@ -1060,7 +1071,7 @@ test "zig fmt: line comment after doc comment" {
10601071test "zig fmt: float literal with exponent" {
10611072 try testCanonical(
10621073 \\test "bit field alignment" {
1063 \\ assert(@typeOf(&blah.b) == *align(1:3:6) const u3);
1074 \\ assert(@TypeOf(&blah.b) == *align(1:3:6) const u3);
10641075 \\}
10651076 \\
10661077 );
......@@ -2593,7 +2604,7 @@ test "zig fmt: comments at several places in struct init" {
25932604 try testTransform(
25942605 \\var bar = Bar{
25952606 \\ .x = 10, // test
2596 \\ .y = "test"
2607 \\ .y = "test"
25972608 \\ // test
25982609 \\};
25992610 \\
lib/std/zig/render.zig+22-16
......@@ -13,19 +13,19 @@ pub const Error = error{
1313};
1414
1515/// Returns whether anything changed
16pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf(stream).Child.Error || Error)!bool {
17 comptime assert(@typeId(@typeOf(stream)) == builtin.TypeId.Pointer);
16pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(stream).Child.Error || Error)!bool {
17 comptime assert(@typeId(@TypeOf(stream)) == builtin.TypeId.Pointer);
1818
1919 var anything_changed: bool = false;
2020
2121 // make a passthrough stream that checks whether something changed
2222 const MyStream = struct {
2323 const MyStream = @This();
24 const StreamError = @typeOf(stream).Child.Error;
24 const StreamError = @TypeOf(stream).Child.Error;
2525 const Stream = std.io.OutStream(StreamError);
2626
2727 anything_changed_ptr: *bool,
28 child_stream: @typeOf(stream),
28 child_stream: @TypeOf(stream),
2929 stream: Stream,
3030 source_index: usize,
3131 source: []const u8,
......@@ -70,7 +70,7 @@ fn renderRoot(
7070 allocator: *mem.Allocator,
7171 stream: var,
7272 tree: *ast.Tree,
73) (@typeOf(stream).Child.Error || Error)!void {
73) (@TypeOf(stream).Child.Error || Error)!void {
7474 var tok_it = tree.tokens.iterator(0);
7575
7676 // render all the line comments at the beginning of the file
......@@ -190,7 +190,7 @@ fn renderRoot(
190190 }
191191}
192192
193fn renderExtraNewline(tree: *ast.Tree, stream: var, start_col: *usize, node: *ast.Node) @typeOf(stream).Child.Error!void {
193fn renderExtraNewline(tree: *ast.Tree, stream: var, start_col: *usize, node: *ast.Node) @TypeOf(stream).Child.Error!void {
194194 const first_token = node.firstToken();
195195 var prev_token = first_token;
196196 while (tree.tokens.at(prev_token - 1).id == .DocComment) {
......@@ -204,7 +204,7 @@ fn renderExtraNewline(tree: *ast.Tree, stream: var, start_col: *usize, node: *as
204204 }
205205}
206206
207fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@typeOf(stream).Child.Error || Error)!void {
207fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@TypeOf(stream).Child.Error || Error)!void {
208208 switch (decl.id) {
209209 .FnProto => {
210210 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);
......@@ -325,7 +325,7 @@ fn renderExpression(
325325 start_col: *usize,
326326 base: *ast.Node,
327327 space: Space,
328) (@typeOf(stream).Child.Error || Error)!void {
328) (@TypeOf(stream).Child.Error || Error)!void {
329329 switch (base.id) {
330330 .Identifier => {
331331 const identifier = @fieldParentPtr(ast.Node.Identifier, "base", base);
......@@ -1249,7 +1249,13 @@ fn renderExpression(
12491249 .BuiltinCall => {
12501250 const builtin_call = @fieldParentPtr(ast.Node.BuiltinCall, "base", base);
12511251
1252 try renderToken(tree, stream, builtin_call.builtin_token, indent, start_col, Space.None); // @name
1252 // TODO: Remove condition after deprecating 'typeOf'. See https://github.com/ziglang/zig/issues/1348
1253 if (mem.eql(u8, tree.tokenSlicePtr(tree.tokens.at(builtin_call.builtin_token)), "@typeOf")) {
1254 try stream.write("@TypeOf");
1255 } else {
1256 try renderToken(tree, stream, builtin_call.builtin_token, indent, start_col, Space.None); // @name
1257 }
1258
12531259 try renderToken(tree, stream, tree.nextToken(builtin_call.builtin_token), indent, start_col, Space.None); // (
12541260
12551261 var it = builtin_call.params.iterator(0);
......@@ -1897,7 +1903,7 @@ fn renderVarDecl(
18971903 indent: usize,
18981904 start_col: *usize,
18991905 var_decl: *ast.Node.VarDecl,
1900) (@typeOf(stream).Child.Error || Error)!void {
1906) (@TypeOf(stream).Child.Error || Error)!void {
19011907 if (var_decl.visib_token) |visib_token| {
19021908 try renderToken(tree, stream, visib_token, indent, start_col, Space.Space); // pub
19031909 }
......@@ -1970,7 +1976,7 @@ fn renderParamDecl(
19701976 start_col: *usize,
19711977 base: *ast.Node,
19721978 space: Space,
1973) (@typeOf(stream).Child.Error || Error)!void {
1979) (@TypeOf(stream).Child.Error || Error)!void {
19741980 const param_decl = @fieldParentPtr(ast.Node.ParamDecl, "base", base);
19751981
19761982 try renderDocComments(tree, stream, param_decl, indent, start_col);
......@@ -1999,7 +2005,7 @@ fn renderStatement(
19992005 indent: usize,
20002006 start_col: *usize,
20012007 base: *ast.Node,
2002) (@typeOf(stream).Child.Error || Error)!void {
2008) (@TypeOf(stream).Child.Error || Error)!void {
20032009 switch (base.id) {
20042010 .VarDecl => {
20052011 const var_decl = @fieldParentPtr(ast.Node.VarDecl, "base", base);
......@@ -2038,7 +2044,7 @@ fn renderTokenOffset(
20382044 start_col: *usize,
20392045 space: Space,
20402046 token_skip_bytes: usize,
2041) (@typeOf(stream).Child.Error || Error)!void {
2047) (@TypeOf(stream).Child.Error || Error)!void {
20422048 if (space == Space.BlockStart) {
20432049 if (start_col.* < indent + indent_delta)
20442050 return renderToken(tree, stream, token_index, indent, start_col, Space.Space);
......@@ -2226,7 +2232,7 @@ fn renderToken(
22262232 indent: usize,
22272233 start_col: *usize,
22282234 space: Space,
2229) (@typeOf(stream).Child.Error || Error)!void {
2235) (@TypeOf(stream).Child.Error || Error)!void {
22302236 return renderTokenOffset(tree, stream, token_index, indent, start_col, space, 0);
22312237}
22322238
......@@ -2236,7 +2242,7 @@ fn renderDocComments(
22362242 node: var,
22372243 indent: usize,
22382244 start_col: *usize,
2239) (@typeOf(stream).Child.Error || Error)!void {
2245) (@TypeOf(stream).Child.Error || Error)!void {
22402246 const comment = node.doc_comments orelse return;
22412247 var it = comment.lines.iterator(0);
22422248 const first_token = node.firstToken();
......@@ -2302,7 +2308,7 @@ const FindByteOutStream = struct {
23022308 }
23032309};
23042310
2305fn copyFixingWhitespace(stream: var, slice: []const u8) @typeOf(stream).Child.Error!void {
2311fn copyFixingWhitespace(stream: var, slice: []const u8) @TypeOf(stream).Child.Error!void {
23062312 for (slice) |byte| switch (byte) {
23072313 '\t' => try stream.write(" "),
23082314 '\r' => {},
src-self-hosted/dep_tokenizer.zig+2-2
......@@ -1021,8 +1021,8 @@ comptime {
10211021// output: must be a function that takes a `self` idiom parameter
10221022// and a bytes parameter
10231023// context: must be that self
1024fn makeOutput(output: var, context: var) Output(@typeOf(output)) {
1025 return Output(@typeOf(output)){
1024fn makeOutput(output: var, context: var) Output(@TypeOf(output)) {
1025 return Output(@TypeOf(output)){
10261026 .output = output,
10271027 .context = context,
10281028 };
src-self-hosted/ir.zig+1-1
......@@ -1807,7 +1807,7 @@ pub const Builder = struct {
18071807 // Look at the params and ref() other instructions
18081808 comptime var i = 0;
18091809 inline while (i < @memberCount(I.Params)) : (i += 1) {
1810 const FieldType = comptime @typeOf(@field(@as(I.Params, undefined), @memberName(I.Params, i)));
1810 const FieldType = comptime @TypeOf(@field(@as(I.Params, undefined), @memberName(I.Params, i)));
18111811 switch (FieldType) {
18121812 *Inst => @field(inst.params, @memberName(I.Params, i)).ref(self),
18131813 *BasicBlock => @field(inst.params, @memberName(I.Params, i)).ref(self),
src-self-hosted/libc_installation.zig+1-1
......@@ -72,7 +72,7 @@ pub const LibCInstallation = struct {
7272 inline for (keys) |key, i| {
7373 if (std.mem.eql(u8, name, key)) {
7474 found_keys[i].found = true;
75 switch (@typeInfo(@typeOf(@field(self, key)))) {
75 switch (@typeInfo(@TypeOf(@field(self, key)))) {
7676 .Optional => {
7777 if (value.len == 0) {
7878 @field(self, key) = null;
src-self-hosted/stage1.zig+4-6
......@@ -270,11 +270,9 @@ const FmtError = error{
270270 FileBusy,
271271} || fs.File.OpenError;
272272
273fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void {
274 const file_path = try std.mem.dupe(fmt.allocator, u8, file_path_ref);
275 defer fmt.allocator.free(file_path);
276
277 if (try fmt.seen.put(file_path, {})) |_| return;
273fn fmtPath(fmt: *Fmt, file_path: []const u8, check_mode: bool) FmtError!void {
274 if (fmt.seen.exists(file_path)) return;
275 try fmt.seen.put(file_path);
278276
279277 const source_code = io.readFileAlloc(fmt.allocator, file_path) catch |err| switch (err) {
280278 error.IsDir, error.AccessDenied => {
......@@ -341,7 +339,7 @@ const Fmt = struct {
341339 color: errmsg.Color,
342340 allocator: *mem.Allocator,
343341
344 const SeenMap = std.StringHashMap(void);
342 const SeenMap = std.BufSet;
345343};
346344
347345fn printErrMsgToFile(
src-self-hosted/translate_c.zig+2-2
......@@ -1147,7 +1147,7 @@ fn transCreateNodeAPInt(c: *Context, int: ?*const ZigClangAPSInt) !*ast.Node {
11471147 var big = try std.math.big.Int.initCapacity(c.a(), num_limbs);
11481148 defer big.deinit();
11491149 const data = ZigClangAPSInt_getRawData(int.?);
1150 var i: @typeOf(num_limbs) = 0;
1150 var i: @TypeOf(num_limbs) = 0;
11511151 while (i < num_limbs) : (i += 1) big.limbs[i] = data[i];
11521152 const str = big.toString(c.a(), 10) catch |err| switch (err) {
11531153 error.OutOfMemory => return error.OutOfMemory,
......@@ -1416,7 +1416,7 @@ fn revertAndWarn(
14161416 source_loc: ZigClangSourceLocation,
14171417 comptime format: []const u8,
14181418 args: var,
1419) (@typeOf(err) || error{OutOfMemory}) {
1419) (@TypeOf(err) || error{OutOfMemory}) {
14201420 rp.activate();
14211421 try emitWarning(rp.c, source_loc, format, args);
14221422 return err;
src-self-hosted/type.zig+3-3
......@@ -1038,14 +1038,14 @@ pub const Type = struct {
10381038};
10391039
10401040fn hashAny(x: var, comptime seed: u64) u32 {
1041 switch (@typeInfo(@typeOf(x))) {
1041 switch (@typeInfo(@TypeOf(x))) {
10421042 .Int => |info| {
10431043 comptime var rng = comptime std.rand.DefaultPrng.init(seed);
10441044 const unsigned_x = @bitCast(@IntType(false, info.bits), x);
10451045 if (info.bits <= 32) {
10461046 return @as(u32, unsigned_x) *% comptime rng.random.scalar(u32);
10471047 } else {
1048 return @truncate(u32, unsigned_x *% comptime rng.random.scalar(@typeOf(unsigned_x)));
1048 return @truncate(u32, unsigned_x *% comptime rng.random.scalar(@TypeOf(unsigned_x)));
10491049 }
10501050 },
10511051 .Pointer => |info| {
......@@ -1069,6 +1069,6 @@ fn hashAny(x: var, comptime seed: u64) u32 {
10691069 return hashAny(@as(u32, 1), seed);
10701070 }
10711071 },
1072 else => @compileError("implement hash function for " ++ @typeName(@typeOf(x))),
1072 else => @compileError("implement hash function for " ++ @typeName(@TypeOf(x))),
10731073 }
10741074}
src/all_types.hpp+1-1
......@@ -2393,7 +2393,7 @@ struct ScopeFnDef {
23932393 ZigFn *fn_entry;
23942394};
23952395
2396// This scope is created for a @typeOf.
2396// This scope is created for a @TypeOf.
23972397// All runtime side-effects are elided within it.
23982398// NodeTypeFnCallExpr
23992399struct ScopeTypeOf {
src/analyze.cpp+2-2
......@@ -121,7 +121,7 @@ static ScopeExpr *find_expr_scope(Scope *scope) {
121121}
122122
123123static void update_progress_display(CodeGen *g) {
124 stage2_progress_update_node(g->sub_progress_node,
124 stage2_progress_update_node(g->sub_progress_node,
125125 g->resolve_queue_index + g->fn_defs_index,
126126 g->resolve_queue.length + g->fn_defs.length);
127127}
......@@ -1732,7 +1732,7 @@ Error type_allowed_in_extern(CodeGen *g, ZigType *type_entry, bool *result) {
17321732ZigType *get_auto_err_set_type(CodeGen *g, ZigFn *fn_entry) {
17331733 ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet);
17341734 buf_resize(&err_set_type->name, 0);
1735 buf_appendf(&err_set_type->name, "@typeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name));
1735 buf_appendf(&err_set_type->name, "@TypeOf(%s).ReturnType.ErrorSet", buf_ptr(&fn_entry->symbol_name));
17361736 err_set_type->data.error_set.err_count = 0;
17371737 err_set_type->data.error_set.errors = nullptr;
17381738 err_set_type->data.error_set.infer_fn = fn_entry;
src/codegen.cpp+3-3
......@@ -1647,7 +1647,7 @@ static void gen_assign_raw(CodeGen *g, LLVMValueRef ptr, ZigType *ptr_type,
16471647 ptr_type->data.pointer.vector_index, false);
16481648 LLVMValueRef loaded_vector = gen_load(g, ptr, ptr_type, "");
16491649 LLVMValueRef new_vector = LLVMBuildInsertElement(g->builder, loaded_vector, value,
1650 index_val, "");
1650 index_val, "");
16511651 gen_store(g, new_vector, ptr, ptr_type);
16521652 return;
16531653 }
......@@ -8067,7 +8067,7 @@ static void define_builtin_fns(CodeGen *g) {
80678067 create_builtin_fn(g, BuiltinFnIdTypeInfo, "typeInfo", 1);
80688068 create_builtin_fn(g, BuiltinFnIdType, "Type", 1);
80698069 create_builtin_fn(g, BuiltinFnIdHasField, "hasField", 2);
8070 create_builtin_fn(g, BuiltinFnIdTypeof, "typeOf", 1); // TODO rename to TypeOf
8070 create_builtin_fn(g, BuiltinFnIdTypeof, "TypeOf", 1);
80718071 create_builtin_fn(g, BuiltinFnIdAddWithOverflow, "addWithOverflow", 4);
80728072 create_builtin_fn(g, BuiltinFnIdSubWithOverflow, "subWithOverflow", 4);
80738073 create_builtin_fn(g, BuiltinFnIdMulWithOverflow, "mulWithOverflow", 4);
......@@ -8407,7 +8407,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
84078407 break;
84088408 }
84098409 buf_appendf(contents, "pub const output_mode = OutputMode.%s;\n", out_type);
8410 const char *link_type = g->is_dynamic ? "Dynamic" : "Static";
8410 const char *link_type = g->is_dynamic ? "Dynamic" : "Static";
84118411 buf_appendf(contents, "pub const link_mode = LinkMode.%s;\n", link_type);
84128412 buf_appendf(contents, "pub const is_test = %s;\n", bool_to_str(g->is_test_build));
84138413 buf_appendf(contents, "pub const single_threaded = %s;\n", bool_to_str(g->is_single_threaded));
src/ir.cpp+6-6
......@@ -9267,7 +9267,7 @@ static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) {
92679267 }
92689268 }
92699269 if (get_scope_typeof(instruction->scope) != nullptr) {
9270 // doesn't count, it's inside a @typeOf()
9270 // doesn't count, it's inside a @TypeOf()
92719271 continue;
92729272 }
92739273 exec_add_error_node(codegen, exec, instruction->source_node,
......@@ -10413,7 +10413,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted
1041310413 return result;
1041410414 }
1041510415
10416 bool ok_cv_qualifiers =
10416 bool ok_cv_qualifiers =
1041710417 (!actual_ptr_type->data.pointer.is_const || wanted_ptr_type->data.pointer.is_const) &&
1041810418 (!actual_ptr_type->data.pointer.is_volatile || wanted_ptr_type->data.pointer.is_volatile);
1041910419 if (!ok_cv_qualifiers) {
......@@ -13779,7 +13779,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1377913779 (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum))
1378013780 {
1378113781 IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.maybe.child_type);
13782 if (result == ira->codegen->invalid_instruction)
13782 if (result == ira->codegen->invalid_instruction)
1378313783 return result;
1378413784
1378513785 return ir_analyze_optional_wrap(ira, result, value, wanted_type, nullptr);
......@@ -13790,9 +13790,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1379013790 (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum))
1379113791 {
1379213792 IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.error_union.payload_type);
13793 if (result == ira->codegen->invalid_instruction)
13793 if (result == ira->codegen->invalid_instruction)
1379413794 return result;
13795
13795
1379613796 return ir_analyze_err_wrap_payload(ira, result, value, wanted_type, nullptr);
1379713797 }
1379813798
......@@ -19328,7 +19328,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
1932819328 {
1932919329 size_t offset = ptr_field->data.x_ptr.data.base_array.elem_index;
1933019330 uint64_t new_index = offset + index;
19331 if (ptr_field->data.x_ptr.data.base_array.array_val->data.x_array.special !=
19331 if (ptr_field->data.x_ptr.data.base_array.array_val->data.x_array.special !=
1933219332 ConstArraySpecialBuf)
1933319333 {
1933419334 ir_assert(new_index <
src/ir_print.cpp+1-1
......@@ -873,7 +873,7 @@ static void ir_print_vector_store_elem(IrPrint *irp, IrInstructionVectorStoreEle
873873}
874874
875875static void ir_print_typeof(IrPrint *irp, IrInstructionTypeOf *instruction) {
876 fprintf(irp->f, "@typeOf(");
876 fprintf(irp->f, "@TypeOf(");
877877 ir_print_other_instruction(irp, instruction->value);
878878 fprintf(irp->f, ")");
879879}
src/translate_c.cpp+4-4
......@@ -4230,7 +4230,7 @@ static AstNode *resolve_typedef_decl(Context *c, const ZigClangTypedefNameDecl *
42304230 emit_warning(c, ZigClangTypedefNameDecl_getLocation(typedef_decl),
42314231 "typedef %s - unresolved child type", buf_ptr(type_name));
42324232 c->decl_table.put(typedef_decl, nullptr);
4233 // TODO add global var with type_name equal to @compileError("unable to resolve C type")
4233 // TODO add global var with type_name equal to @compileError("unable to resolve C type")
42344234 return nullptr;
42354235 }
42364236 add_global_var(c, type_name, type_node);
......@@ -4919,9 +4919,9 @@ static AstNode *parse_ctok_primary_expr(Context *c, CTokenize *ctok, size_t *tok
49194919 *tok_i += 1;
49204920
49214921
4922 //if (@typeId(@typeOf(x)) == @import("builtin").TypeId.Pointer)
4922 //if (@typeId(@TypeOf(x)) == @import("builtin").TypeId.Pointer)
49234923 // @ptrCast(dest, x)
4924 //else if (@typeId(@typeOf(x)) == @import("builtin").TypeId.Integer)
4924 //else if (@typeId(@TypeOf(x)) == @import("builtin").TypeId.Integer)
49254925 // @intToPtr(dest, x)
49264926 //else
49274927 // (dest)(x)
......@@ -4931,7 +4931,7 @@ static AstNode *parse_ctok_primary_expr(Context *c, CTokenize *ctok, size_t *tok
49314931 AstNode *typeid_type = trans_create_node_field_access_str(c, import_builtin, "TypeId");
49324932 AstNode *typeid_pointer = trans_create_node_field_access_str(c, typeid_type, "Pointer");
49334933 AstNode *typeid_integer = trans_create_node_field_access_str(c, typeid_type, "Int");
4934 AstNode *typeof_x = trans_create_node_builtin_fn_call_str(c, "typeOf");
4934 AstNode *typeof_x = trans_create_node_builtin_fn_call_str(c, "TypeOf");
49354935 typeof_x->data.fn_call_expr.params.append(node_to_cast);
49364936 AstNode *typeid_value = trans_create_node_builtin_fn_call_str(c, "typeId");
49374937 typeid_value->data.fn_call_expr.params.append(typeof_x);
test/compare_output.zig+2-2
......@@ -258,12 +258,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
258258 cases.add("order-independent declarations",
259259 \\const io = @import("std").io;
260260 \\const z = io.stdin_fileno;
261 \\const x : @typeOf(y) = 1234;
261 \\const x : @TypeOf(y) = 1234;
262262 \\const y : u16 = 5678;
263263 \\pub fn main() void {
264264 \\ var x_local : i32 = print_ok(x);
265265 \\}
266 \\fn print_ok(val: @typeOf(x)) @typeOf(foo) {
266 \\fn print_ok(val: @TypeOf(x)) @TypeOf(foo) {
267267 \\ const stdout = &io.getStdOut().outStream().stream;
268268 \\ stdout.print("OK\n", .{}) catch unreachable;
269269 \\ return 0;
test/compile_errors.zig+65-65
......@@ -154,7 +154,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
154154 \\ };
155155 \\}
156156 , &[_][]const u8{
157 "tmp.zig:11:25: error: expected type 'u32', found '@typeOf(get_uval).ReturnType.ErrorSet!u32'",
157 "tmp.zig:11:25: error: expected type 'u32', found '@TypeOf(get_uval).ReturnType.ErrorSet!u32'",
158158 });
159159
160160 cases.add("asigning to struct or union fields that are not optionals with a function that returns an optional",
......@@ -854,7 +854,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
854854 cases.add("field access of slices",
855855 \\export fn entry() void {
856856 \\ var slice: []i32 = undefined;
857 \\ const info = @typeOf(slice).unknown;
857 \\ const info = @TypeOf(slice).unknown;
858858 \\}
859859 , &[_][]const u8{
860860 "tmp.zig:3:32: error: type '[]i32' does not support field access",
......@@ -894,7 +894,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
894894
895895 cases.add("@sizeOf bad type",
896896 \\export fn entry() usize {
897 \\ return @sizeOf(@typeOf(null));
897 \\ return @sizeOf(@TypeOf(null));
898898 \\}
899899 , &[_][]const u8{
900900 "tmp.zig:2:20: error: no size available for type '(null)'",
......@@ -1033,7 +1033,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10331033
10341034 cases.add("bogus compile var",
10351035 \\const x = @import("builtin").bogus;
1036 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1036 \\export fn entry() usize { return @sizeOf(@TypeOf(x)); }
10371037 , &[_][]const u8{
10381038 "tmp.zig:1:29: error: container 'builtin' has no member called 'bogus'",
10391039 });
......@@ -1080,7 +1080,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10801080 \\var foo: Foo = undefined;
10811081 \\
10821082 \\export fn entry() usize {
1083 \\ return @sizeOf(@typeOf(foo.x));
1083 \\ return @sizeOf(@TypeOf(foo.x));
10841084 \\}
10851085 , &[_][]const u8{
10861086 "tmp.zig:1:13: error: struct 'Foo' depends on itself",
......@@ -1118,8 +1118,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11181118 });
11191119
11201120 cases.add("top level decl dependency loop",
1121 \\const a : @typeOf(b) = 0;
1122 \\const b : @typeOf(a) = 0;
1121 \\const a : @TypeOf(b) = 0;
1122 \\const b : @TypeOf(a) = 0;
11231123 \\export fn entry() void {
11241124 \\ const c = a + b;
11251125 \\}
......@@ -1620,7 +1620,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
16201620 \\var x: f64 = 1.0;
16211621 \\var y: f32 = x;
16221622 \\
1623 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
1623 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
16241624 , &[_][]const u8{
16251625 "tmp.zig:2:14: error: expected type 'f32', found 'f64'",
16261626 });
......@@ -2494,7 +2494,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
24942494 \\ }
24952495 \\}
24962496 , &[_][]const u8{
2497 "tmp.zig:5:14: error: duplicate switch value: '@typeOf(foo).ReturnType.ErrorSet.Foo'",
2497 "tmp.zig:5:14: error: duplicate switch value: '@TypeOf(foo).ReturnType.ErrorSet.Foo'",
24982498 "tmp.zig:3:14: note: other value is here",
24992499 });
25002500
......@@ -2626,7 +2626,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
26262626 \\ try foo();
26272627 \\}
26282628 , &[_][]const u8{
2629 "tmp.zig:5:5: error: cannot resolve inferred error set '@typeOf(foo).ReturnType.ErrorSet': function 'foo' not fully analyzed yet",
2629 "tmp.zig:5:5: error: cannot resolve inferred error set '@TypeOf(foo).ReturnType.ErrorSet': function 'foo' not fully analyzed yet",
26302630 });
26312631
26322632 cases.add("implicit cast of error set not a subset",
......@@ -3555,7 +3555,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
35553555 \\ }
35563556 \\}
35573557 \\
3558 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3558 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
35593559 , &[_][]const u8{
35603560 "tmp.zig:8:5: error: enumeration value 'Number.Four' not handled in switch",
35613561 });
......@@ -3577,7 +3577,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
35773577 \\ }
35783578 \\}
35793579 \\
3580 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3580 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
35813581 , &[_][]const u8{
35823582 "tmp.zig:13:15: error: duplicate switch value",
35833583 "tmp.zig:10:15: note: other value is here",
......@@ -3601,7 +3601,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36013601 \\ }
36023602 \\}
36033603 \\
3604 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3604 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
36053605 , &[_][]const u8{
36063606 "tmp.zig:13:15: error: duplicate switch value",
36073607 "tmp.zig:10:15: note: other value is here",
......@@ -3628,7 +3628,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36283628 \\ 0 => {},
36293629 \\ }
36303630 \\}
3631 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3631 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
36323632 , &[_][]const u8{
36333633 "tmp.zig:2:5: error: switch must handle all possibilities",
36343634 });
......@@ -3642,7 +3642,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36423642 \\ 206 ... 255 => 3,
36433643 \\ };
36443644 \\}
3645 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3645 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
36463646 , &[_][]const u8{
36473647 "tmp.zig:6:9: error: duplicate switch value",
36483648 "tmp.zig:5:14: note: previous value is here",
......@@ -3655,7 +3655,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36553655 \\ }
36563656 \\}
36573657 \\const y: u8 = 100;
3658 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3658 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
36593659 , &[_][]const u8{
36603660 "tmp.zig:2:5: error: else prong required when switching on type '*u8'",
36613661 });
......@@ -3673,7 +3673,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36733673 \\const derp: usize = 1234;
36743674 \\const a = derp ++ "foo";
36753675 \\
3676 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
3676 \\export fn entry() usize { return @sizeOf(@TypeOf(a)); }
36773677 , &[_][]const u8{
36783678 "tmp.zig:3:11: error: expected array, found 'usize'",
36793679 });
......@@ -3683,14 +3683,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
36833683 \\ return s ++ "foo";
36843684 \\}
36853685 \\var s: [10]u8 = undefined;
3686 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3686 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
36873687 , &[_][]const u8{
36883688 "tmp.zig:2:12: error: unable to evaluate constant expression",
36893689 });
36903690
36913691 cases.add("@cImport with bogus include",
36923692 \\const c = @cImport(@cInclude("bogus.h"));
3693 \\export fn entry() usize { return @sizeOf(@typeOf(c.bogo)); }
3693 \\export fn entry() usize { return @sizeOf(@TypeOf(c.bogo)); }
36943694 , &[_][]const u8{
36953695 "tmp.zig:1:11: error: C import failed",
36963696 ".h:1:10: note: 'bogus.h' file not found",
......@@ -3700,14 +3700,14 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37003700 \\const x = 3;
37013701 \\const y = &x;
37023702 \\fn foo() *const i32 { return y; }
3703 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3703 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
37043704 , &[_][]const u8{
37053705 "tmp.zig:3:30: error: expected type '*const i32', found '*const comptime_int'",
37063706 });
37073707
37083708 cases.add("integer overflow error",
37093709 \\const x : u8 = 300;
3710 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
3710 \\export fn entry() usize { return @sizeOf(@TypeOf(x)); }
37113711 , &[_][]const u8{
37123712 "tmp.zig:1:16: error: integer value 300 cannot be coerced to type 'u8'",
37133713 });
......@@ -3736,7 +3736,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37363736 \\ }
37373737 \\};
37383738 \\
3739 \\const member_fn_type = @typeOf(Foo.member_a);
3739 \\const member_fn_type = @TypeOf(Foo.member_a);
37403740 \\const members = [_]member_fn_type {
37413741 \\ Foo.member_a,
37423742 \\ Foo.member_b,
......@@ -3746,21 +3746,21 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37463746 \\ const result = members[index]();
37473747 \\}
37483748 \\
3749 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3749 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
37503750 , &[_][]const u8{
37513751 "tmp.zig:20:34: error: expected 1 arguments, found 0",
37523752 });
37533753
37543754 cases.add("missing function name",
37553755 \\fn () void {}
3756 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3756 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
37573757 , &[_][]const u8{
37583758 "tmp.zig:1:1: error: missing function name",
37593759 });
37603760
37613761 cases.add("missing param name",
37623762 \\fn f(i32) void {}
3763 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
3763 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
37643764 , &[_][]const u8{
37653765 "tmp.zig:1:6: error: missing parameter name",
37663766 });
......@@ -3770,7 +3770,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37703770 \\fn a() i32 {return 0;}
37713771 \\fn b() i32 {return 1;}
37723772 \\fn c() i32 {return 2;}
3773 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
3773 \\export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
37743774 , &[_][]const u8{
37753775 "tmp.zig:1:28: error: expected type 'fn() void', found 'fn() i32'",
37763776 });
......@@ -3781,7 +3781,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37813781 \\pub fn b(x: i32) i32 {return x + 1;}
37823782 \\export fn c(x: i32) i32 {return x + 2;}
37833783 \\
3784 \\export fn entry() usize { return @sizeOf(@typeOf(fns)); }
3784 \\export fn entry() usize { return @sizeOf(@TypeOf(fns)); }
37853785 , &[_][]const u8{
37863786 "tmp.zig:1:37: error: expected type 'fn(i32) i32', found 'extern fn(i32) i32'",
37873787 });
......@@ -3789,7 +3789,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
37893789 cases.add("colliding invalid top level functions",
37903790 \\fn func() bogus {}
37913791 \\fn func() bogus {}
3792 \\export fn entry() usize { return @sizeOf(@typeOf(func)); }
3792 \\export fn entry() usize { return @sizeOf(@TypeOf(func)); }
37933793 , &[_][]const u8{
37943794 "tmp.zig:2:1: error: redefinition of 'func'",
37953795 });
......@@ -3801,7 +3801,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38013801 \\var global_var: usize = 1;
38023802 \\fn get() usize { return global_var; }
38033803 \\
3804 \\export fn entry() usize { return @sizeOf(@typeOf(Foo)); }
3804 \\export fn entry() usize { return @sizeOf(@TypeOf(Foo)); }
38053805 , &[_][]const u8{
38063806 "tmp.zig:5:25: error: unable to evaluate constant expression",
38073807 "tmp.zig:2:12: note: referenced here",
......@@ -3813,7 +3813,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38133813 \\};
38143814 \\const x = Foo {.field = 1} + Foo {.field = 2};
38153815 \\
3816 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
3816 \\export fn entry() usize { return @sizeOf(@TypeOf(x)); }
38173817 , &[_][]const u8{
38183818 "tmp.zig:4:28: error: invalid operands to binary expression: 'Foo' and 'Foo'",
38193819 });
......@@ -3824,10 +3824,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38243824 \\const int_x = @as(u32, 1) / @as(u32, 0);
38253825 \\const float_x = @as(f32, 1.0) / @as(f32, 0.0);
38263826 \\
3827 \\export fn entry1() usize { return @sizeOf(@typeOf(lit_int_x)); }
3828 \\export fn entry2() usize { return @sizeOf(@typeOf(lit_float_x)); }
3829 \\export fn entry3() usize { return @sizeOf(@typeOf(int_x)); }
3830 \\export fn entry4() usize { return @sizeOf(@typeOf(float_x)); }
3827 \\export fn entry1() usize { return @sizeOf(@TypeOf(lit_int_x)); }
3828 \\export fn entry2() usize { return @sizeOf(@TypeOf(lit_float_x)); }
3829 \\export fn entry3() usize { return @sizeOf(@TypeOf(int_x)); }
3830 \\export fn entry4() usize { return @sizeOf(@TypeOf(float_x)); }
38313831 , &[_][]const u8{
38323832 "tmp.zig:1:21: error: division by zero",
38333833 "tmp.zig:2:25: error: division by zero",
......@@ -3839,7 +3839,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38393839 \\const foo = "a
38403840 \\b";
38413841 \\
3842 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
3842 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
38433843 , &[_][]const u8{
38443844 "tmp.zig:1:15: error: newline not allowed in string literal",
38453845 });
......@@ -3848,7 +3848,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38483848 \\fn foo() void {}
38493849 \\const invalid = foo > foo;
38503850 \\
3851 \\export fn entry() usize { return @sizeOf(@typeOf(invalid)); }
3851 \\export fn entry() usize { return @sizeOf(@TypeOf(invalid)); }
38523852 , &[_][]const u8{
38533853 "tmp.zig:2:21: error: operator not allowed for type 'fn() void'",
38543854 });
......@@ -3859,7 +3859,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38593859 \\ return foo(a, b);
38603860 \\}
38613861 \\
3862 \\export fn entry() usize { return @sizeOf(@typeOf(test1)); }
3862 \\export fn entry() usize { return @sizeOf(@TypeOf(test1)); }
38633863 , &[_][]const u8{
38643864 "tmp.zig:3:16: error: unable to evaluate constant expression",
38653865 });
......@@ -3867,7 +3867,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38673867 cases.add("assign null to non-optional pointer",
38683868 \\const a: *u8 = null;
38693869 \\
3870 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
3870 \\export fn entry() usize { return @sizeOf(@TypeOf(a)); }
38713871 , &[_][]const u8{
38723872 "tmp.zig:1:16: error: expected type '*u8', found '(null)'",
38733873 });
......@@ -3887,7 +3887,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38873887 \\ return 1 / x;
38883888 \\}
38893889 \\
3890 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
3890 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
38913891 , &[_][]const u8{
38923892 "tmp.zig:3:14: error: division by zero",
38933893 "tmp.zig:1:14: note: referenced here",
......@@ -3896,7 +3896,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
38963896 cases.add("branch on undefined value",
38973897 \\const x = if (undefined) true else false;
38983898 \\
3899 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
3899 \\export fn entry() usize { return @sizeOf(@TypeOf(x)); }
39003900 , &[_][]const u8{
39013901 "tmp.zig:1:15: error: use of undefined value here causes undefined behavior",
39023902 });
......@@ -4276,7 +4276,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
42764276 \\ return fibbonaci(x - 1) + fibbonaci(x - 2);
42774277 \\}
42784278 \\
4279 \\export fn entry() usize { return @sizeOf(@typeOf(seventh_fib_number)); }
4279 \\export fn entry() usize { return @sizeOf(@TypeOf(seventh_fib_number)); }
42804280 , &[_][]const u8{
42814281 "tmp.zig:3:21: error: evaluation exceeded 1000 backwards branches",
42824282 "tmp.zig:1:37: note: referenced here",
......@@ -4286,7 +4286,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
42864286 cases.add("@embedFile with bogus file",
42874287 \\const resource = @embedFile("bogus.txt",);
42884288 \\
4289 \\export fn entry() usize { return @sizeOf(@typeOf(resource)); }
4289 \\export fn entry() usize { return @sizeOf(@TypeOf(resource)); }
42904290 , &[_][]const u8{
42914291 "tmp.zig:1:29: error: unable to find '",
42924292 "bogus.txt'",
......@@ -4299,7 +4299,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
42994299 \\const a = Foo {.x = get_it()};
43004300 \\extern fn get_it() i32;
43014301 \\
4302 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
4302 \\export fn entry() usize { return @sizeOf(@TypeOf(a)); }
43034303 , &[_][]const u8{
43044304 "tmp.zig:4:21: error: unable to evaluate constant expression",
43054305 });
......@@ -4315,7 +4315,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
43154315 \\}
43164316 \\var global_side_effect = false;
43174317 \\
4318 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
4318 \\export fn entry() usize { return @sizeOf(@TypeOf(a)); }
43194319 , &[_][]const u8{
43204320 "tmp.zig:6:26: error: unable to evaluate constant expression",
43214321 "tmp.zig:4:17: note: referenced here",
......@@ -4344,8 +4344,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
43444344 \\ return a.* == b.*;
43454345 \\}
43464346 \\
4347 \\export fn entry1() usize { return @sizeOf(@typeOf(bad_eql_1)); }
4348 \\export fn entry2() usize { return @sizeOf(@typeOf(bad_eql_2)); }
4347 \\export fn entry1() usize { return @sizeOf(@TypeOf(bad_eql_1)); }
4348 \\export fn entry2() usize { return @sizeOf(@TypeOf(bad_eql_2)); }
43494349 , &[_][]const u8{
43504350 "tmp.zig:2:14: error: operator not allowed for type '[]u8'",
43514351 "tmp.zig:9:16: error: operator not allowed for type 'EnumWithData'",
......@@ -4392,7 +4392,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
43924392 \\ return -x;
43934393 \\}
43944394 \\
4395 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
4395 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
43964396 , &[_][]const u8{
43974397 "tmp.zig:3:12: error: negation caused overflow",
43984398 "tmp.zig:1:14: note: referenced here",
......@@ -4404,7 +4404,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44044404 \\ return a + b;
44054405 \\}
44064406 \\
4407 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
4407 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
44084408 , &[_][]const u8{
44094409 "tmp.zig:3:14: error: operation caused overflow",
44104410 "tmp.zig:1:14: note: referenced here",
......@@ -4416,7 +4416,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44164416 \\ return a - b;
44174417 \\}
44184418 \\
4419 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
4419 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
44204420 , &[_][]const u8{
44214421 "tmp.zig:3:14: error: operation caused overflow",
44224422 "tmp.zig:1:14: note: referenced here",
......@@ -4428,7 +4428,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44284428 \\ return a * b;
44294429 \\}
44304430 \\
4431 \\export fn entry() usize { return @sizeOf(@typeOf(y)); }
4431 \\export fn entry() usize { return @sizeOf(@TypeOf(y)); }
44324432 , &[_][]const u8{
44334433 "tmp.zig:3:14: error: operation caused overflow",
44344434 "tmp.zig:1:14: note: referenced here",
......@@ -4440,7 +4440,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44404440 \\ return @truncate(i8, x);
44414441 \\}
44424442 \\
4443 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
4443 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
44444444 , &[_][]const u8{
44454445 "tmp.zig:3:26: error: expected signed integer type, found 'u32'",
44464446 });
......@@ -4480,7 +4480,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
44804480 \\fn f() i32 {
44814481 \\ return foo(1, 2);
44824482 \\}
4483 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
4483 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
44844484 , &[_][]const u8{
44854485 "tmp.zig:1:15: error: comptime parameter not allowed in function with calling convention 'ccc'",
44864486 });
......@@ -4524,7 +4524,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45244524 \\fn f(m: []const u8) void {
45254525 \\ m.copy(u8, self[0..], m);
45264526 \\}
4527 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
4527 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
45284528 , &[_][]const u8{
45294529 "tmp.zig:3:6: error: no member named 'copy' in '[]const u8'",
45304530 });
......@@ -4537,7 +4537,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45374537 \\
45384538 \\ foo.method(1, 2);
45394539 \\}
4540 \\export fn entry() usize { return @sizeOf(@typeOf(f)); }
4540 \\export fn entry() usize { return @sizeOf(@TypeOf(f)); }
45414541 , &[_][]const u8{
45424542 "tmp.zig:6:15: error: expected 2 arguments, found 3",
45434543 });
......@@ -4596,7 +4596,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45964596 \\ var jd = JsonNode {.kind = JsonType.JSONArray , .jobject = JsonOA.JSONArray {jll} };
45974597 \\}
45984598 \\
4599 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
4599 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
46004600 , &[_][]const u8{
46014601 "tmp.zig:5:16: error: use of undeclared identifier 'JsonList'",
46024602 });
......@@ -4655,7 +4655,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
46554655 \\const TINY_QUANTUM_SIZE = 1 << TINY_QUANTUM_SHIFT;
46564656 \\var block_aligned_stuff: usize = (4 + TINY_QUANTUM_SIZE) & ~(TINY_QUANTUM_SIZE - 1);
46574657 \\
4658 \\export fn entry() usize { return @sizeOf(@typeOf(block_aligned_stuff)); }
4658 \\export fn entry() usize { return @sizeOf(@TypeOf(block_aligned_stuff)); }
46594659 , &[_][]const u8{
46604660 "tmp.zig:3:60: error: unable to perform binary not operation on type 'comptime_int'",
46614661 });
......@@ -4683,7 +4683,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
46834683 \\const zero: i32 = 0;
46844684 \\const a = zero{1};
46854685 \\
4686 \\export fn entry() usize { return @sizeOf(@typeOf(a)); }
4686 \\export fn entry() usize { return @sizeOf(@TypeOf(a)); }
46874687 , &[_][]const u8{
46884688 "tmp.zig:2:11: error: expected type 'type', found 'i32'",
46894689 });
......@@ -4715,7 +4715,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
47154715 \\ return 0;
47164716 \\}
47174717 \\
4718 \\export fn entry() usize { return @sizeOf(@typeOf(testTrickyDefer)); }
4718 \\export fn entry() usize { return @sizeOf(@TypeOf(testTrickyDefer)); }
47194719 , &[_][]const u8{
47204720 "tmp.zig:4:11: error: cannot return from defer expression",
47214721 });
......@@ -4730,7 +4730,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
47304730
47314731 cases.add("global variable alignment non power of 2",
47324732 \\const some_data: [100]u8 align(3) = undefined;
4733 \\export fn entry() usize { return @sizeOf(@typeOf(some_data)); }
4733 \\export fn entry() usize { return @sizeOf(@TypeOf(some_data)); }
47344734 , &[_][]const u8{
47354735 "tmp.zig:1:32: error: alignment value 3 is not a power of 2",
47364736 });
......@@ -4772,7 +4772,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
47724772 \\ return x.*;
47734773 \\}
47744774 \\
4775 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
4775 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
47764776 , &[_][]const u8{
47774777 "tmp.zig:8:26: error: expected type '*const u3', found '*align(:3:1) const u3'",
47784778 });
......@@ -4875,7 +4875,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
48754875 \\ return out.*[0..1];
48764876 \\}
48774877 \\
4878 \\export fn entry() usize { return @sizeOf(@typeOf(pass)); }
4878 \\export fn entry() usize { return @sizeOf(@TypeOf(pass)); }
48794879 , &[_][]const u8{
48804880 "tmp.zig:4:10: error: attempt to dereference non-pointer type '[10]u8'",
48814881 });
......@@ -4890,7 +4890,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
48904890 \\ return true;
48914891 \\}
48924892 \\
4893 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
4893 \\export fn entry() usize { return @sizeOf(@TypeOf(foo)); }
48944894 , &[_][]const u8{
48954895 "tmp.zig:4:19: error: expected type '*[]const u8', found '*const []const u8'",
48964896 });
......@@ -5726,7 +5726,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
57265726
57275727 cases.add("@ArgType arg index out of bounds",
57285728 \\comptime {
5729 \\ _ = @ArgType(@typeOf(add), 2);
5729 \\ _ = @ArgType(@TypeOf(add), 2);
57305730 \\}
57315731 \\fn add(a: i32, b: i32) i32 { return a + b; }
57325732 , &[_][]const u8{
......@@ -6220,7 +6220,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
62206220 cases.add("getting return type of generic function",
62216221 \\fn generic(a: var) void {}
62226222 \\comptime {
6223 \\ _ = @typeOf(generic).ReturnType;
6223 \\ _ = @TypeOf(generic).ReturnType;
62246224 \\}
62256225 , &[_][]const u8{
62266226 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var)var' is generic",
......@@ -6229,7 +6229,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
62296229 cases.add("getting @ArgType of generic function",
62306230 \\fn generic(a: var) void {}
62316231 \\comptime {
6232 \\ _ = @ArgType(@typeOf(generic), 0);
6232 \\ _ = @ArgType(@TypeOf(generic), 0);
62336233 \\}
62346234 , &[_][]const u8{
62356235 "tmp.zig:3:36: error: @ArgType could not resolve the type of arg 0 because 'fn(var)var' is generic",
test/stage1/behavior/align.zig+21-21
......@@ -5,10 +5,10 @@ const builtin = @import("builtin");
55var foo: u8 align(4) = 100;
66
77test "global variable alignment" {
8 expect(@typeOf(&foo).alignment == 4);
9 expect(@typeOf(&foo) == *align(4) u8);
8 expect(@TypeOf(&foo).alignment == 4);
9 expect(@TypeOf(&foo) == *align(4) u8);
1010 const slice = @as(*[1]u8, &foo)[0..];
11 expect(@typeOf(slice) == []align(4) u8);
11 expect(@TypeOf(slice) == []align(4) u8);
1212}
1313
1414fn derp() align(@sizeOf(usize) * 2) i32 {
......@@ -19,8 +19,8 @@ fn noop4() align(4) void {}
1919
2020test "function alignment" {
2121 expect(derp() == 1234);
22 expect(@typeOf(noop1) == fn () align(1) void);
23 expect(@typeOf(noop4) == fn () align(4) void);
22 expect(@TypeOf(noop1) == fn () align(1) void);
23 expect(@TypeOf(noop4) == fn () align(4) void);
2424 noop1();
2525 noop4();
2626}
......@@ -31,7 +31,7 @@ var baz: packed struct {
3131} = undefined;
3232
3333test "packed struct alignment" {
34 expect(@typeOf(&baz.b) == *align(1) u32);
34 expect(@TypeOf(&baz.b) == *align(1) u32);
3535}
3636
3737const blah: packed struct {
......@@ -41,7 +41,7 @@ const blah: packed struct {
4141} = undefined;
4242
4343test "bit field alignment" {
44 expect(@typeOf(&blah.b) == *align(1:3:1) const u3);
44 expect(@TypeOf(&blah.b) == *align(1:3:1) const u3);
4545}
4646
4747test "default alignment allows unspecified in type syntax" {
......@@ -165,28 +165,28 @@ fn whyWouldYouEverDoThis(comptime align_bytes: u8) align(align_bytes) u8 {
165165test "@ptrCast preserves alignment of bigger source" {
166166 var x: u32 align(16) = 1234;
167167 const ptr = @ptrCast(*u8, &x);
168 expect(@typeOf(ptr) == *align(16) u8);
168 expect(@TypeOf(ptr) == *align(16) u8);
169169}
170170
171171test "runtime known array index has best alignment possible" {
172172 // take full advantage of over-alignment
173173 var array align(4) = [_]u8{ 1, 2, 3, 4 };
174 expect(@typeOf(&array[0]) == *align(4) u8);
175 expect(@typeOf(&array[1]) == *u8);
176 expect(@typeOf(&array[2]) == *align(2) u8);
177 expect(@typeOf(&array[3]) == *u8);
174 expect(@TypeOf(&array[0]) == *align(4) u8);
175 expect(@TypeOf(&array[1]) == *u8);
176 expect(@TypeOf(&array[2]) == *align(2) u8);
177 expect(@TypeOf(&array[3]) == *u8);
178178
179179 // because align is too small but we still figure out to use 2
180180 var bigger align(2) = [_]u64{ 1, 2, 3, 4 };
181 expect(@typeOf(&bigger[0]) == *align(2) u64);
182 expect(@typeOf(&bigger[1]) == *align(2) u64);
183 expect(@typeOf(&bigger[2]) == *align(2) u64);
184 expect(@typeOf(&bigger[3]) == *align(2) u64);
181 expect(@TypeOf(&bigger[0]) == *align(2) u64);
182 expect(@TypeOf(&bigger[1]) == *align(2) u64);
183 expect(@TypeOf(&bigger[2]) == *align(2) u64);
184 expect(@TypeOf(&bigger[3]) == *align(2) u64);
185185
186186 // because pointer is align 2 and u32 align % 2 == 0 we can assume align 2
187187 var smaller align(2) = [_]u32{ 1, 2, 3, 4 };
188 comptime expect(@typeOf(smaller[0..]) == []align(2) u32);
189 comptime expect(@typeOf(smaller[0..].ptr) == [*]align(2) u32);
188 comptime expect(@TypeOf(smaller[0..]) == []align(2) u32);
189 comptime expect(@TypeOf(smaller[0..].ptr) == [*]align(2) u32);
190190 testIndex(smaller[0..].ptr, 0, *align(2) u32);
191191 testIndex(smaller[0..].ptr, 1, *align(2) u32);
192192 testIndex(smaller[0..].ptr, 2, *align(2) u32);
......@@ -199,10 +199,10 @@ test "runtime known array index has best alignment possible" {
199199 testIndex2(array[0..].ptr, 3, *u8);
200200}
201201fn testIndex(smaller: [*]align(2) u32, index: usize, comptime T: type) void {
202 comptime expect(@typeOf(&smaller[index]) == T);
202 comptime expect(@TypeOf(&smaller[index]) == T);
203203}
204204fn testIndex2(ptr: [*]align(4) u8, index: usize, comptime T: type) void {
205 comptime expect(@typeOf(&ptr[index]) == T);
205 comptime expect(@TypeOf(&ptr[index]) == T);
206206}
207207
208208test "alignstack" {
......@@ -303,7 +303,7 @@ test "struct field explicit alignment" {
303303 var node: S.Node = undefined;
304304 node.massive_byte = 100;
305305 expect(node.massive_byte == 100);
306 comptime expect(@typeOf(&node.massive_byte) == *align(64) u8);
306 comptime expect(@TypeOf(&node.massive_byte) == *align(64) u8);
307307 expect(@ptrToInt(&node.massive_byte) % 64 == 0);
308308}
309309
test/stage1/behavior/array.zig+3-3
......@@ -30,7 +30,7 @@ test "void arrays" {
3030 var array: [4]void = undefined;
3131 array[0] = void{};
3232 array[1] = array[2];
33 expect(@sizeOf(@typeOf(array)) == 0);
33 expect(@sizeOf(@TypeOf(array)) == 0);
3434 expect(array.len == 4);
3535}
3636
......@@ -109,12 +109,12 @@ test "array literal with specified size" {
109109
110110test "array child property" {
111111 var x: [5]i32 = undefined;
112 expect(@typeOf(x).Child == i32);
112 expect(@TypeOf(x).Child == i32);
113113}
114114
115115test "array len property" {
116116 var x: [5]i32 = undefined;
117 expect(@typeOf(x).len == 5);
117 expect(@TypeOf(x).len == 5);
118118}
119119
120120test "array len field" {
test/stage1/behavior/async_fn.zig+12-12
......@@ -185,7 +185,7 @@ var a_promise: anyframe = undefined;
185185var global_result = false;
186186async fn testSuspendBlock() void {
187187 suspend {
188 comptime expect(@typeOf(@frame()) == *@Frame(testSuspendBlock));
188 comptime expect(@TypeOf(@frame()) == *@Frame(testSuspendBlock));
189189 a_promise = @frame();
190190 }
191191
......@@ -282,7 +282,7 @@ test "async fn pointer in a struct field" {
282282 var foo = Foo{ .bar = simpleAsyncFn2 };
283283 var bytes: [64]u8 align(16) = undefined;
284284 const f = @asyncCall(&bytes, {}, foo.bar, &data);
285 comptime expect(@typeOf(f) == anyframe->void);
285 comptime expect(@TypeOf(f) == anyframe->void);
286286 expect(data == 2);
287287 resume f;
288288 expect(data == 4);
......@@ -332,7 +332,7 @@ test "async fn with inferred error set" {
332332 fn doTheTest() void {
333333 var frame: [1]@Frame(middle) = undefined;
334334 var fn_ptr = middle;
335 var result: @typeOf(fn_ptr).ReturnType.ErrorSet!void = undefined;
335 var result: @TypeOf(fn_ptr).ReturnType.ErrorSet!void = undefined;
336336 _ = @asyncCall(@sliceToBytes(frame[0..]), &result, fn_ptr);
337337 resume global_frame;
338338 std.testing.expectError(error.Fail, result);
......@@ -952,7 +952,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
952952
953953 fn doTheTest() void {
954954 var frame: [1]@Frame(middle) = undefined;
955 var result: @typeOf(middle).ReturnType.ErrorSet!void = undefined;
955 var result: @TypeOf(middle).ReturnType.ErrorSet!void = undefined;
956956 _ = @asyncCall(@sliceToBytes(frame[0..]), &result, middle);
957957 resume global_frame;
958958 std.testing.expectError(error.Fail, result);
......@@ -1009,7 +1009,7 @@ test "@asyncCall using the result location inside the frame" {
10091009 var foo = Foo{ .bar = S.simple2 };
10101010 var bytes: [64]u8 align(16) = undefined;
10111011 const f = @asyncCall(&bytes, {}, foo.bar, &data);
1012 comptime expect(@typeOf(f) == anyframe->i32);
1012 comptime expect(@TypeOf(f) == anyframe->i32);
10131013 expect(data == 2);
10141014 resume f;
10151015 expect(data == 4);
......@@ -1017,18 +1017,18 @@ test "@asyncCall using the result location inside the frame" {
10171017 expect(data == 1234);
10181018}
10191019
1020test "@typeOf an async function call of generic fn with error union type" {
1020test "@TypeOf an async function call of generic fn with error union type" {
10211021 const S = struct {
10221022 fn func(comptime x: var) anyerror!i32 {
1023 const T = @typeOf(async func(x));
1024 comptime expect(T == @typeOf(@frame()).Child);
1023 const T = @TypeOf(async func(x));
1024 comptime expect(T == @TypeOf(@frame()).Child);
10251025 return undefined;
10261026 }
10271027 };
10281028 _ = async S.func(i32);
10291029}
10301030
1031test "using @typeOf on a generic function call" {
1031test "using @TypeOf on a generic function call" {
10321032 const S = struct {
10331033 var global_frame: anyframe = undefined;
10341034 var global_ok = false;
......@@ -1043,7 +1043,7 @@ test "using @typeOf on a generic function call" {
10431043 suspend {
10441044 global_frame = @frame();
10451045 }
1046 const F = @typeOf(async amain(x - 1));
1046 const F = @TypeOf(async amain(x - 1));
10471047 const frame = @intToPtr(*F, @ptrToInt(&buf));
10481048 return await @asyncCall(frame, {}, amain, x - 1);
10491049 }
......@@ -1068,7 +1068,7 @@ test "recursive call of await @asyncCall with struct return type" {
10681068 suspend {
10691069 global_frame = @frame();
10701070 }
1071 const F = @typeOf(async amain(x - 1));
1071 const F = @TypeOf(async amain(x - 1));
10721072 const frame = @intToPtr(*F, @ptrToInt(&buf));
10731073 return await @asyncCall(frame, {}, amain, x - 1);
10741074 }
......@@ -1080,7 +1080,7 @@ test "recursive call of await @asyncCall with struct return type" {
10801080 };
10811081 };
10821082 var res: S.Foo = undefined;
1083 var frame: @typeOf(async S.amain(@as(u32, 1))) = undefined;
1083 var frame: @TypeOf(async S.amain(@as(u32, 1))) = undefined;
10841084 _ = @asyncCall(&frame, &res, S.amain, @as(u32, 1));
10851085 resume S.global_frame;
10861086 expect(S.global_ok);
test/stage1/behavior/atomics.zig+2-2
......@@ -118,7 +118,7 @@ test "atomic load and rmw with enum" {
118118
119119 expect(@atomicLoad(Value, &x, .SeqCst) != .b);
120120
121 _ = @atomicRmw(Value, &x, .Xchg, .c, .SeqCst);
121 _ = @atomicRmw(Value, &x, .Xchg, .c, .SeqCst);
122122 expect(@atomicLoad(Value, &x, .SeqCst) == .c);
123123 expect(@atomicLoad(Value, &x, .SeqCst) != .a);
124124 expect(@atomicLoad(Value, &x, .SeqCst) != .b);
......@@ -143,4 +143,4 @@ fn testAtomicStore() void {
143143 expect(@atomicLoad(u32, &x, .SeqCst) == 1);
144144 @atomicStore(u32, &x, 12345678, .SeqCst);
145145 expect(@atomicLoad(u32, &x, .SeqCst) == 12345678);
146}
\ No newline at end of file
146}
test/stage1/behavior/bugs/1851.zig+1-1
......@@ -15,7 +15,7 @@ test "allocation and looping over 3-byte integer" {
1515 x[1] = 0xFFFFFF;
1616
1717 const bytes = @sliceToBytes(x);
18 expect(@typeOf(bytes) == []align(4) u8);
18 expect(@TypeOf(bytes) == []align(4) u8);
1919 expect(bytes.len == 8);
2020
2121 for (bytes) |*b| {
test/stage1/behavior/bugs/2114.zig+1-1
......@@ -3,7 +3,7 @@ const expect = std.testing.expect;
33const math = std.math;
44
55fn ctz(x: var) usize {
6 return @ctz(@typeOf(x), x);
6 return @ctz(@TypeOf(x), x);
77}
88
99test "fixed" {
test/stage1/behavior/bugs/3742.zig+1-1
......@@ -24,7 +24,7 @@ pub fn isCommand(comptime T: type) bool {
2424
2525pub const ArgSerializer = struct {
2626 pub fn serializeCommand(command: var) void {
27 const CmdT = @typeOf(command);
27 const CmdT = @TypeOf(command);
2828
2929 if (comptime isCommand(CmdT)) {
3030 // COMMENTING THE NEXT LINE REMOVES THE ERROR
test/stage1/behavior/bugs/655.zig+1-1
......@@ -3,7 +3,7 @@ const other_file = @import("655_other_file.zig");
33
44test "function with *const parameter with type dereferenced by namespace" {
55 const x: other_file.Integer = 1234;
6 comptime std.testing.expect(@typeOf(&x) == *const other_file.Integer);
6 comptime std.testing.expect(@TypeOf(&x) == *const other_file.Integer);
77 foo(&x);
88}
99
test/stage1/behavior/bugs/718.zig+1-1
......@@ -9,7 +9,7 @@ const Keys = struct {
99};
1010var keys: Keys = undefined;
1111test "zero keys with @memset" {
12 @memset(@ptrCast([*]u8, &keys), 0, @sizeOf(@typeOf(keys)));
12 @memset(@ptrCast([*]u8, &keys), 0, @sizeOf(@TypeOf(keys)));
1313 expect(!keys.up);
1414 expect(!keys.down);
1515 expect(!keys.left);
test/stage1/behavior/cast.zig+10-10
......@@ -226,14 +226,14 @@ fn testCastConstArrayRefToConstSlice() void {
226226 {
227227 const blah = "aoeu".*;
228228 const const_array_ref = &blah;
229 expect(@typeOf(const_array_ref) == *const [4:0]u8);
229 expect(@TypeOf(const_array_ref) == *const [4:0]u8);
230230 const slice: []const u8 = const_array_ref;
231231 expect(mem.eql(u8, slice, "aoeu"));
232232 }
233233 {
234234 const blah: [4]u8 = "aoeu".*;
235235 const const_array_ref = &blah;
236 expect(@typeOf(const_array_ref) == *const [4]u8);
236 expect(@TypeOf(const_array_ref) == *const [4]u8);
237237 const slice: []const u8 = const_array_ref;
238238 expect(mem.eql(u8, slice, "aoeu"));
239239 }
......@@ -353,29 +353,29 @@ test "cast *[1][*]const u8 to [*]const ?[*]const u8" {
353353
354354test "@intCast comptime_int" {
355355 const result = @intCast(i32, 1234);
356 expect(@typeOf(result) == i32);
356 expect(@TypeOf(result) == i32);
357357 expect(result == 1234);
358358}
359359
360360test "@floatCast comptime_int and comptime_float" {
361361 {
362362 const result = @floatCast(f16, 1234);
363 expect(@typeOf(result) == f16);
363 expect(@TypeOf(result) == f16);
364364 expect(result == 1234.0);
365365 }
366366 {
367367 const result = @floatCast(f16, 1234.0);
368 expect(@typeOf(result) == f16);
368 expect(@TypeOf(result) == f16);
369369 expect(result == 1234.0);
370370 }
371371 {
372372 const result = @floatCast(f32, 1234);
373 expect(@typeOf(result) == f32);
373 expect(@TypeOf(result) == f32);
374374 expect(result == 1234.0);
375375 }
376376 {
377377 const result = @floatCast(f32, 1234.0);
378 expect(@typeOf(result) == f32);
378 expect(@TypeOf(result) == f32);
379379 expect(result == 1234.0);
380380 }
381381}
......@@ -383,12 +383,12 @@ test "@floatCast comptime_int and comptime_float" {
383383test "comptime_int @intToFloat" {
384384 {
385385 const result = @intToFloat(f16, 1234);
386 expect(@typeOf(result) == f16);
386 expect(@TypeOf(result) == f16);
387387 expect(result == 1234.0);
388388 }
389389 {
390390 const result = @intToFloat(f32, 1234);
391 expect(@typeOf(result) == f32);
391 expect(@TypeOf(result) == f32);
392392 expect(result == 1234.0);
393393 }
394394}
......@@ -396,7 +396,7 @@ test "comptime_int @intToFloat" {
396396test "@bytesToSlice keeps pointer alignment" {
397397 var bytes = [_]u8{ 0x01, 0x02, 0x03, 0x04 };
398398 const numbers = @bytesToSlice(u32, bytes[0..]);
399 comptime expect(@typeOf(numbers) == []align(@alignOf(@typeOf(bytes))) u32);
399 comptime expect(@TypeOf(numbers) == []align(@alignOf(@TypeOf(bytes))) u32);
400400}
401401
402402test "@intCast i32 to u7" {
test/stage1/behavior/error.zig+3-3
......@@ -83,9 +83,9 @@ test "error union type " {
8383fn testErrorUnionType() void {
8484 const x: anyerror!i32 = 1234;
8585 if (x) |value| expect(value == 1234) else |_| unreachable;
86 expect(@typeId(@typeOf(x)) == builtin.TypeId.ErrorUnion);
87 expect(@typeId(@typeOf(x).ErrorSet) == builtin.TypeId.ErrorSet);
88 expect(@typeOf(x).ErrorSet == anyerror);
86 expect(@typeId(@TypeOf(x)) == builtin.TypeId.ErrorUnion);
87 expect(@typeId(@TypeOf(x).ErrorSet) == builtin.TypeId.ErrorSet);
88 expect(@TypeOf(x).ErrorSet == anyerror);
8989}
9090
9191test "error set type" {
test/stage1/behavior/eval.zig+2-2
......@@ -105,7 +105,7 @@ pub fn vec3(x: f32, y: f32, z: f32) Vec3 {
105105
106106test "constant expressions" {
107107 var array: [array_size]u8 = undefined;
108 expect(@sizeOf(@typeOf(array)) == 20);
108 expect(@sizeOf(@TypeOf(array)) == 20);
109109}
110110const array_size: u8 = 20;
111111
......@@ -598,7 +598,7 @@ test "pointer to type" {
598598 var T: type = i32;
599599 expect(T == i32);
600600 var ptr = &T;
601 expect(@typeOf(ptr) == *type);
601 expect(@TypeOf(ptr) == *type);
602602 ptr.* = f32;
603603 expect(T == f32);
604604 expect(*T == *f32);
test/stage1/behavior/fn.zig+4-4
......@@ -73,7 +73,7 @@ fn fnWithUnreachable() noreturn {
7373}
7474
7575test "function pointers" {
76 const fns = [_]@typeOf(fn1){
76 const fns = [_]@TypeOf(fn1){
7777 fn1,
7878 fn2,
7979 fn3,
......@@ -130,7 +130,7 @@ test "pass by non-copying value through var arg" {
130130}
131131
132132fn addPointCoordsVar(pt: var) i32 {
133 comptime expect(@typeOf(pt) == Point);
133 comptime expect(@TypeOf(pt) == Point);
134134 return pt.x + pt.y;
135135}
136136
......@@ -170,7 +170,7 @@ test "pass by non-copying value as method, at comptime" {
170170}
171171
172172fn outer(y: u32) fn (u32) u32 {
173 const Y = @typeOf(y);
173 const Y = @TypeOf(y);
174174 const st = struct {
175175 fn get(z: u32) u32 {
176176 return z + @sizeOf(Y);
......@@ -265,7 +265,7 @@ test "ability to give comptime types and non comptime types to same parameter" {
265265 }
266266
267267 fn foo(arg: var) i32 {
268 if (@typeInfo(@typeOf(arg)) == .Type and arg == i32) return 20;
268 if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20;
269269 return 9 + arg;
270270 }
271271 };
test/stage1/behavior/for.zig+2-2
......@@ -29,9 +29,9 @@ test "for loop with pointer elem var" {
2929 expect(mem.eql(u8, &target, "bcdefgh"));
3030
3131 for (source) |*c, i|
32 expect(@typeOf(c) == *const u8);
32 expect(@TypeOf(c) == *const u8);
3333 for (target) |*c, i|
34 expect(@typeOf(c) == *u8);
34 expect(@TypeOf(c) == *u8);
3535}
3636
3737fn mangleString(s: []u8) void {
test/stage1/behavior/generics.zig+1-1
......@@ -47,7 +47,7 @@ comptime {
4747 expect(max_f64(1.2, 3.4) == 3.4);
4848}
4949
50fn max_var(a: var, b: var) @typeOf(a + b) {
50fn max_var(a: var, b: var) @TypeOf(a + b) {
5151 return if (a > b) a else b;
5252}
5353
test/stage1/behavior/math.zig+3-3
......@@ -281,8 +281,8 @@ test "small int addition" {
281281 x += 1;
282282 expect(x == 3);
283283
284 var result: @typeOf(x) = 3;
285 expect(@addWithOverflow(@typeOf(x), x, 1, &result));
284 var result: @TypeOf(x) = 3;
285 expect(@addWithOverflow(@TypeOf(x), x, 1, &result));
286286
287287 expect(result == 0);
288288}
......@@ -586,7 +586,7 @@ test "@sqrt" {
586586
587587 const x = 14.0;
588588 const y = x * x;
589 const z = @sqrt(@typeOf(y), y);
589 const z = @sqrt(@TypeOf(y), y);
590590 comptime expect(z == x);
591591}
592592
test/stage1/behavior/misc.zig+10-10
......@@ -362,8 +362,8 @@ test "string concatenation" {
362362 const a = "OK" ++ " IT " ++ "WORKED";
363363 const b = "OK IT WORKED";
364364
365 comptime expect(@typeOf(a) == *const [12:0]u8);
366 comptime expect(@typeOf(b) == *const [12:0]u8);
365 comptime expect(@TypeOf(a) == *const [12:0]u8);
366 comptime expect(@TypeOf(b) == *const [12:0]u8);
367367
368368 const len = mem.len(u8, b);
369369 const len_with_null = len + 1;
......@@ -460,19 +460,19 @@ test "@typeId" {
460460 expect(@typeId(*f32) == Tid.Pointer);
461461 expect(@typeId([2]u8) == Tid.Array);
462462 expect(@typeId(AStruct) == Tid.Struct);
463 expect(@typeId(@typeOf(1)) == Tid.ComptimeInt);
464 expect(@typeId(@typeOf(1.0)) == Tid.ComptimeFloat);
465 expect(@typeId(@typeOf(undefined)) == Tid.Undefined);
466 expect(@typeId(@typeOf(null)) == Tid.Null);
463 expect(@typeId(@TypeOf(1)) == Tid.ComptimeInt);
464 expect(@typeId(@TypeOf(1.0)) == Tid.ComptimeFloat);
465 expect(@typeId(@TypeOf(undefined)) == Tid.Undefined);
466 expect(@typeId(@TypeOf(null)) == Tid.Null);
467467 expect(@typeId(?i32) == Tid.Optional);
468468 expect(@typeId(anyerror!i32) == Tid.ErrorUnion);
469469 expect(@typeId(anyerror) == Tid.ErrorSet);
470470 expect(@typeId(AnEnum) == Tid.Enum);
471 expect(@typeId(@typeOf(AUnionEnum.One)) == Tid.Enum);
471 expect(@typeId(@TypeOf(AUnionEnum.One)) == Tid.Enum);
472472 expect(@typeId(AUnionEnum) == Tid.Union);
473473 expect(@typeId(AUnion) == Tid.Union);
474474 expect(@typeId(fn () void) == Tid.Fn);
475 expect(@typeId(@typeOf(builtin)) == Tid.Type);
475 expect(@typeId(@TypeOf(builtin)) == Tid.Type);
476476 // TODO bound fn
477477 // TODO arg tuple
478478 // TODO opaque
......@@ -652,9 +652,9 @@ test "volatile load and store" {
652652
653653test "slice string literal has type []const u8" {
654654 comptime {
655 expect(@typeOf("aoeu"[0..]) == []const u8);
655 expect(@TypeOf("aoeu"[0..]) == []const u8);
656656 const array = [_]i32{ 1, 2, 3, 4 };
657 expect(@typeOf(array[0..]) == []const i32);
657 expect(@TypeOf(array[0..]) == []const i32);
658658 }
659659}
660660
test/stage1/behavior/pointers.zig+17-13
......@@ -93,10 +93,10 @@ test "peer type resolution with C pointers" {
9393 var x2 = if (t) ptr_many else ptr_c;
9494 var x3 = if (t) ptr_c else ptr_one;
9595 var x4 = if (t) ptr_c else ptr_many;
96 expect(@typeOf(x1) == [*c]u8);
97 expect(@typeOf(x2) == [*c]u8);
98 expect(@typeOf(x3) == [*c]u8);
99 expect(@typeOf(x4) == [*c]u8);
96 expect(@TypeOf(x1) == [*c]u8);
97 expect(@TypeOf(x2) == [*c]u8);
98 expect(@TypeOf(x3) == [*c]u8);
99 expect(@TypeOf(x4) == [*c]u8);
100100}
101101
102102test "implicit casting between C pointer and optional non-C pointer" {
......@@ -144,11 +144,11 @@ test "allowzero pointer and slice" {
144144 expect(opt_ptr != null);
145145 expect(@ptrToInt(ptr) == 0);
146146 var slice = ptr[0..10];
147 expect(@typeOf(slice) == []allowzero i32);
147 expect(@TypeOf(slice) == []allowzero i32);
148148 expect(@ptrToInt(&slice[5]) == 20);
149149
150 expect(@typeInfo(@typeOf(ptr)).Pointer.is_allowzero);
151 expect(@typeInfo(@typeOf(slice)).Pointer.is_allowzero);
150 expect(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);
151 expect(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);
152152}
153153
154154test "assign null directly to C pointer and test null equality" {
......@@ -204,7 +204,7 @@ test "assign null directly to C pointer and test null equality" {
204204test "null terminated pointer" {
205205 const S = struct {
206206 fn doTheTest() void {
207 var array_with_zero = [_:0]u8{'h', 'e', 'l', 'l', 'o'};
207 var array_with_zero = [_:0]u8{ 'h', 'e', 'l', 'l', 'o' };
208208 var zero_ptr: [*:0]const u8 = @ptrCast([*:0]const u8, &array_with_zero);
209209 var no_zero_ptr: [*]const u8 = zero_ptr;
210210 var zero_ptr_again = @ptrCast([*:0]const u8, no_zero_ptr);
......@@ -218,7 +218,7 @@ test "null terminated pointer" {
218218test "allow any sentinel" {
219219 const S = struct {
220220 fn doTheTest() void {
221 var array = [_:std.math.minInt(i32)]i32{1, 2, 3, 4};
221 var array = [_:std.math.minInt(i32)]i32{ 1, 2, 3, 4 };
222222 var ptr: [*:std.math.minInt(i32)]i32 = &array;
223223 expect(ptr[4] == std.math.minInt(i32));
224224 }
......@@ -229,10 +229,14 @@ test "allow any sentinel" {
229229
230230test "pointer sentinel with enums" {
231231 const S = struct {
232 const Number = enum{one, two, sentinel};
232 const Number = enum {
233 one,
234 two,
235 sentinel,
236 };
233237
234238 fn doTheTest() void {
235 var ptr: [*:.sentinel]Number = &[_:.sentinel]Number{.one, .two, .two, .one};
239 var ptr: [*:.sentinel]Number = &[_:.sentinel]Number{ .one, .two, .two, .one };
236240 expect(ptr[4] == .sentinel); // TODO this should be comptime expect, see #3731
237241 }
238242 };
......@@ -243,7 +247,7 @@ test "pointer sentinel with enums" {
243247test "pointer sentinel with optional element" {
244248 const S = struct {
245249 fn doTheTest() void {
246 var ptr: [*:null]?i32 = &[_:null]?i32{1, 2, 3, 4};
250 var ptr: [*:null]?i32 = &[_:null]?i32{ 1, 2, 3, 4 };
247251 expect(ptr[4] == null); // TODO this should be comptime expect, see #3731
248252 }
249253 };
......@@ -255,7 +259,7 @@ test "pointer sentinel with +inf" {
255259 const S = struct {
256260 fn doTheTest() void {
257261 const inf = std.math.inf_f32;
258 var ptr: [*:inf]f32 = &[_:inf]f32{1.1, 2.2, 3.3, 4.4};
262 var ptr: [*:inf]f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
259263 expect(ptr[4] == inf); // TODO this should be comptime expect, see #3731
260264 }
261265 };
test/stage1/behavior/ptrcast.zig+1-1
......@@ -55,7 +55,7 @@ test "comptime ptrcast keeps larger alignment" {
5555 comptime {
5656 const a: u32 = 1234;
5757 const p = @ptrCast([*]const u8, &a);
58 std.debug.assert(@typeOf(p) == [*]align(@alignOf(u32)) const u8);
58 std.debug.assert(@TypeOf(p) == [*]align(@alignOf(u32)) const u8);
5959 }
6060}
6161
test/stage1/behavior/reflection.zig+6-6
......@@ -13,12 +13,12 @@ test "reflection: array, pointer, optional, error union type child" {
1313
1414test "reflection: function return type, var args, and param types" {
1515 comptime {
16 expect(@typeOf(dummy).ReturnType == i32);
17 expect(!@typeOf(dummy).is_var_args);
18 expect(@typeOf(dummy).arg_count == 3);
19 expect(@ArgType(@typeOf(dummy), 0) == bool);
20 expect(@ArgType(@typeOf(dummy), 1) == i32);
21 expect(@ArgType(@typeOf(dummy), 2) == f32);
16 expect(@TypeOf(dummy).ReturnType == i32);
17 expect(!@TypeOf(dummy).is_var_args);
18 expect(@TypeOf(dummy).arg_count == 3);
19 expect(@ArgType(@TypeOf(dummy), 0) == bool);
20 expect(@ArgType(@TypeOf(dummy), 1) == i32);
21 expect(@ArgType(@TypeOf(dummy), 2) == f32);
2222 }
2323}
2424
test/stage1/behavior/sizeof_and_typeof.zig+10-10
......@@ -1,12 +1,12 @@
11const builtin = @import("builtin");
22const expect = @import("std").testing.expect;
33
4test "@sizeOf and @typeOf" {
5 const y: @typeOf(x) = 120;
6 expect(@sizeOf(@typeOf(y)) == 2);
4test "@sizeOf and @TypeOf" {
5 const y: @TypeOf(x) = 120;
6 expect(@sizeOf(@TypeOf(y)) == 2);
77}
88const x: u16 = 13;
9const z: @typeOf(x) = 19;
9const z: @TypeOf(x) = 19;
1010
1111const A = struct {
1212 a: u8,
......@@ -71,8 +71,8 @@ test "@bitOffsetOf" {
7171test "@sizeOf on compile-time types" {
7272 expect(@sizeOf(comptime_int) == 0);
7373 expect(@sizeOf(comptime_float) == 0);
74 expect(@sizeOf(@typeOf(.hi)) == 0);
75 expect(@sizeOf(@typeOf(type)) == 0);
74 expect(@sizeOf(@TypeOf(.hi)) == 0);
75 expect(@sizeOf(@TypeOf(type)) == 0);
7676}
7777
7878test "@sizeOf(T) == 0 doesn't force resolving struct size" {
......@@ -90,7 +90,7 @@ test "@sizeOf(T) == 0 doesn't force resolving struct size" {
9090 expect(@sizeOf(S.Bar) == 8);
9191}
9292
93test "@typeOf() has no runtime side effects" {
93test "@TypeOf() has no runtime side effects" {
9494 const S = struct {
9595 fn foo(comptime T: type, ptr: *T) T {
9696 ptr.* += 1;
......@@ -98,12 +98,12 @@ test "@typeOf() has no runtime side effects" {
9898 }
9999 };
100100 var data: i32 = 0;
101 const T = @typeOf(S.foo(i32, &data));
101 const T = @TypeOf(S.foo(i32, &data));
102102 comptime expect(T == i32);
103103 expect(data == 0);
104104}
105105
106test "branching logic inside @typeOf" {
106test "branching logic inside @TypeOf" {
107107 const S = struct {
108108 var data: i32 = 0;
109109 fn foo() anyerror!i32 {
......@@ -111,7 +111,7 @@ test "branching logic inside @typeOf" {
111111 return undefined;
112112 }
113113 };
114 const T = @typeOf(S.foo() catch undefined);
114 const T = @TypeOf(S.foo() catch undefined);
115115 comptime expect(T == i32);
116116 expect(S.data == 0);
117117}
test/stage1/behavior/switch.zig+2-2
......@@ -406,7 +406,7 @@ test "switch prongs with cases with identical payload types" {
406406 fn doTheSwitch1(u: Union) void {
407407 switch (u) {
408408 .A, .C => |e| {
409 expect(@typeOf(e) == usize);
409 expect(@TypeOf(e) == usize);
410410 expect(e == 8);
411411 },
412412 .B => |e| @panic("fail"),
......@@ -416,7 +416,7 @@ test "switch prongs with cases with identical payload types" {
416416 switch (u) {
417417 .A, .C => |e| @panic("fail"),
418418 .B => |e| {
419 expect(@typeOf(e) == isize);
419 expect(@TypeOf(e) == isize);
420420 expect(e == -8);
421421 },
422422 }
test/stage1/behavior/type.zig+2-2
......@@ -125,10 +125,10 @@ test "Type.ComptimeInt" {
125125 testTypes(&[_]type{comptime_int});
126126}
127127test "Type.Undefined" {
128 testTypes(&[_]type{@typeOf(undefined)});
128 testTypes(&[_]type{@TypeOf(undefined)});
129129}
130130test "Type.Null" {
131 testTypes(&[_]type{@typeOf(null)});
131 testTypes(&[_]type{@TypeOf(null)});
132132}
133133test "@Type create slice with null sentinel" {
134134 const Slice = @Type(builtin.TypeInfo{
test/stage1/behavior/type_info.zig+3-3
......@@ -201,7 +201,7 @@ fn testUnion() void {
201201 expect(typeinfo_info.Union.fields.len == 25);
202202 expect(typeinfo_info.Union.fields[4].enum_field != null);
203203 expect(typeinfo_info.Union.fields[4].enum_field.?.value == 4);
204 expect(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int));
204 expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));
205205 expect(typeinfo_info.Union.decls.len == 21);
206206
207207 const TestNoTagUnion = union {
......@@ -264,7 +264,7 @@ test "type info: function type info" {
264264}
265265
266266fn testFunction() void {
267 const fn_info = @typeInfo(@typeOf(foo));
267 const fn_info = @typeInfo(@TypeOf(foo));
268268 expect(@as(TypeId, fn_info) == TypeId.Fn);
269269 expect(fn_info.Fn.calling_convention == TypeInfo.CallingConvention.Unspecified);
270270 expect(fn_info.Fn.is_generic);
......@@ -273,7 +273,7 @@ fn testFunction() void {
273273 expect(fn_info.Fn.return_type == null);
274274
275275 const test_instance: TestStruct = undefined;
276 const bound_fn_info = @typeInfo(@typeOf(test_instance.foo));
276 const bound_fn_info = @typeInfo(@TypeOf(test_instance.foo));
277277 expect(@as(TypeId, bound_fn_info) == TypeId.BoundFn);
278278 expect(bound_fn_info.BoundFn.args[0].arg_type.? == *const TestStruct);
279279}
test/stage1/behavior/undefined.zig+1-1
......@@ -64,5 +64,5 @@ test "assign undefined to struct with method" {
6464
6565test "type name of undefined" {
6666 const x = undefined;
67 expect(mem.eql(u8, @typeName(@typeOf(x)), "(undefined)"));
67 expect(mem.eql(u8, @typeName(@TypeOf(x)), "(undefined)"));
6868}
test/stage1/behavior/vector.zig+1-1
......@@ -148,7 +148,7 @@ test "vector @splat" {
148148 fn doTheTest() void {
149149 var v: u32 = 5;
150150 var x = @splat(4, v);
151 expect(@typeOf(x) == @Vector(4, u32));
151 expect(@TypeOf(x) == @Vector(4, u32));
152152 var array_x: [4]u32 = x;
153153 expect(array_x[0] == 5);
154154 expect(array_x[1] == 5);
test/translate_c.zig+1-1
......@@ -1539,7 +1539,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
15391539 cases.add("macro pointer cast",
15401540 \\#define NRF_GPIO ((NRF_GPIO_Type *) NRF_GPIO_BASE)
15411541 , &[_][]const u8{
1542 \\pub const NRF_GPIO = if (@typeId(@typeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Pointer) @ptrCast([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else if (@typeId(@typeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Int) @intToPtr([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else @as([*c]NRF_GPIO_Type, NRF_GPIO_BASE);
1542 \\pub const NRF_GPIO = if (@typeId(@TypeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Pointer) @ptrCast([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else if (@typeId(@TypeOf(NRF_GPIO_BASE)) == @import("builtin").TypeId.Int) @intToPtr([*c]NRF_GPIO_Type, NRF_GPIO_BASE) else @as([*c]NRF_GPIO_Type, NRF_GPIO_BASE);
15431543 });
15441544
15451545 cases.add("if on non-bool",
tools/merge_anal_dumps.zig+1-1
......@@ -311,7 +311,7 @@ const Dump = struct {
311311 }
312312
313313 fn render(self: *Dump, stream: var) !void {
314 var jw = json.WriteStream(@typeOf(stream).Child, 10).init(stream);
314 var jw = json.WriteStream(@TypeOf(stream).Child, 10).init(stream);
315315 try jw.beginObject();
316316
317317 try jw.objectField("typeKinds");