authorgravatar for robin@voetter.nlRobin Voetter <robin@voetter.nl> 2019-12-09 21:59:42+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-10 11:09:41-05:00
log30715560c829d5636734edf7eabff3ee4d170e5d
tree6b4fd0751e80a9c4128756d59d3c0bfecd230498
parent8c096707b784b3f7f8e1f8381e07d37724263083
signature Commit is signed but in an unrecognized format.

Rename @typeOf to @TypeOf in the language reference


1 files changed, 52 insertions(+), 52 deletions(-)

doc/langref.html.in+52-52
...@@ -307,7 +307,7 @@ pub fn main() void {...@@ -307,7 +307,7 @@ pub fn main() void {
307 assert(optional_value == null);307 assert(optional_value == null);
308308
309 warn("\noptional 1\ntype: {}\nvalue: {}\n", .{309 warn("\noptional 1\ntype: {}\nvalue: {}\n", .{
310 @typeName(@typeOf(optional_value)),310 @typeName(@TypeOf(optional_value)),
311 optional_value,311 optional_value,
312 });312 });
313313
...@@ -315,7 +315,7 @@ pub fn main() void {...@@ -315,7 +315,7 @@ pub fn main() void {
315 assert(optional_value != null);315 assert(optional_value != null);
316316
317 warn("\noptional 2\ntype: {}\nvalue: {}\n", .{317 warn("\noptional 2\ntype: {}\nvalue: {}\n", .{
318 @typeName(@typeOf(optional_value)),318 @typeName(@TypeOf(optional_value)),
319 optional_value,319 optional_value,
320 });320 });
321321
...@@ -323,14 +323,14 @@ pub fn main() void {...@@ -323,14 +323,14 @@ pub fn main() void {
323 var number_or_error: anyerror!i32 = error.ArgNotFound;323 var number_or_error: anyerror!i32 = error.ArgNotFound;
324324
325 warn("\nerror union 1\ntype: {}\nvalue: {}\n", .{325 warn("\nerror union 1\ntype: {}\nvalue: {}\n", .{
326 @typeName(@typeOf(number_or_error)),326 @typeName(@TypeOf(number_or_error)),
327 number_or_error,327 number_or_error,
328 });328 });
329329
330 number_or_error = 1234;330 number_or_error = 1234;
331331
332 warn("\nerror union 2\ntype: {}\nvalue: {}\n", .{332 warn("\nerror union 2\ntype: {}\nvalue: {}\n", .{
333 @typeName(@typeOf(number_or_error)),333 @typeName(@TypeOf(number_or_error)),
334 number_or_error,334 number_or_error,
335 });335 });
336}336}
...@@ -572,7 +572,7 @@ const mem = @import("std").mem;...@@ -572,7 +572,7 @@ const mem = @import("std").mem;
572572
573test "string literals" {573test "string literals" {
574 const bytes = "hello";574 const bytes = "hello";
575 assert(@typeOf(bytes) == *const [5:0]u8);575 assert(@TypeOf(bytes) == *const [5:0]u8);
576 assert(bytes.len == 5);576 assert(bytes.len == 5);
577 assert(bytes[1] == 'e');577 assert(bytes[1] == 'e');
578 assert(bytes[5] == 0);578 assert(bytes[5] == 0);
...@@ -1802,7 +1802,7 @@ const assert = std.debug.assert;...@@ -1802,7 +1802,7 @@ const assert = std.debug.assert;
1802test "null terminated array" {1802test "null terminated array" {
1803 const array = [_:0]u8 {1, 2, 3, 4};1803 const array = [_:0]u8 {1, 2, 3, 4};
18041804
1805 assert(@typeOf(array) == [4:0]u8);1805 assert(@TypeOf(array) == [4:0]u8);
1806 assert(array.len == 4);1806 assert(array.len == 4);
1807 assert(array[4] == 0);1807 assert(array[4] == 0);
1808}1808}
...@@ -1885,12 +1885,12 @@ test "address of syntax" {...@@ -1885,12 +1885,12 @@ test "address of syntax" {
1885 assert(x_ptr.* == 1234);1885 assert(x_ptr.* == 1234);
18861886
1887 // When you get the address of a const variable, you get a const pointer to a single item.1887 // 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
1890 // If you want to mutate the value, you'd need an address of a mutable variable:1890 // If you want to mutate the value, you'd need an address of a mutable variable:
1891 var y: i32 = 5678;1891 var y: i32 = 5678;
1892 const y_ptr = &y;1892 const y_ptr = &y;
1893 assert(@typeOf(y_ptr) == *i32);1893 assert(@TypeOf(y_ptr) == *i32);
1894 y_ptr.* += 1;1894 y_ptr.* += 1;
1895 assert(y_ptr.* == 5679);1895 assert(y_ptr.* == 5679);
1896}1896}
...@@ -1901,7 +1901,7 @@ test "pointer array access" {...@@ -1901,7 +1901,7 @@ test "pointer array access" {
1901 // does not support pointer arithmetic.1901 // does not support pointer arithmetic.
1902 var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };1902 var array = [_]u8{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
1903 const ptr = &array[2];1903 const ptr = &array[2];
1904 assert(@typeOf(ptr) == *u8);1904 assert(@TypeOf(ptr) == *u8);
19051905
1906 assert(array[2] == 3);1906 assert(array[2] == 3);
1907 ptr.* += 1;1907 ptr.* += 1;
...@@ -1953,7 +1953,7 @@ const assert = @import("std").debug.assert;...@@ -1953,7 +1953,7 @@ const assert = @import("std").debug.assert;
1953test "@ptrToInt and @intToPtr" {1953test "@ptrToInt and @intToPtr" {
1954 const ptr = @intToPtr(*i32, 0xdeadbeef);1954 const ptr = @intToPtr(*i32, 0xdeadbeef);
1955 const addr = @ptrToInt(ptr);1955 const addr = @ptrToInt(ptr);
1956 assert(@typeOf(addr) == usize);1956 assert(@TypeOf(addr) == usize);
1957 assert(addr == 0xdeadbeef);1957 assert(addr == 0xdeadbeef);
1958}1958}
1959 {#code_end#}1959 {#code_end#}
...@@ -1968,7 +1968,7 @@ test "comptime @intToPtr" {...@@ -1968,7 +1968,7 @@ test "comptime @intToPtr" {
1968 // ptr is never dereferenced.1968 // ptr is never dereferenced.
1969 const ptr = @intToPtr(*i32, 0xdeadbeef);1969 const ptr = @intToPtr(*i32, 0xdeadbeef);
1970 const addr = @ptrToInt(ptr);1970 const addr = @ptrToInt(ptr);
1971 assert(@typeOf(addr) == usize);1971 assert(@TypeOf(addr) == usize);
1972 assert(addr == 0xdeadbeef);1972 assert(addr == 0xdeadbeef);
1973 }1973 }
1974}1974}
...@@ -1984,7 +1984,7 @@ const assert = @import("std").debug.assert;...@@ -1984,7 +1984,7 @@ const assert = @import("std").debug.assert;
19841984
1985test "volatile" {1985test "volatile" {
1986 const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);1986 const mmio_ptr = @intToPtr(*volatile u8, 0x12345678);
1987 assert(@typeOf(mmio_ptr) == *volatile u8);1987 assert(@TypeOf(mmio_ptr) == *volatile u8);
1988}1988}
1989 {#code_end#}1989 {#code_end#}
1990 <p>1990 <p>
...@@ -2041,8 +2041,8 @@ const builtin = @import("builtin");...@@ -2041,8 +2041,8 @@ const builtin = @import("builtin");
20412041
2042test "variable alignment" {2042test "variable alignment" {
2043 var x: i32 = 1234;2043 var x: i32 = 1234;
2044 const align_of_i32 = @alignOf(@typeOf(x));2044 const align_of_i32 = @alignOf(@TypeOf(x));
2045 assert(@typeOf(&x) == *i32);2045 assert(@TypeOf(&x) == *i32);
2046 assert(*i32 == *align(align_of_i32) i32);2046 assert(*i32 == *align(align_of_i32) i32);
2047 if (builtin.arch == builtin.Arch.x86_64) {2047 if (builtin.arch == builtin.Arch.x86_64) {
2048 assert((*i32).alignment == 4);2048 assert((*i32).alignment == 4);
...@@ -2063,10 +2063,10 @@ const assert = @import("std").debug.assert;...@@ -2063,10 +2063,10 @@ const assert = @import("std").debug.assert;
2063var foo: u8 align(4) = 100;2063var foo: u8 align(4) = 100;
20642064
2065test "global variable alignment" {2065test "global variable alignment" {
2066 assert(@typeOf(&foo).alignment == 4);2066 assert(@TypeOf(&foo).alignment == 4);
2067 assert(@typeOf(&foo) == *align(4) u8);2067 assert(@TypeOf(&foo) == *align(4) u8);
2068 const slice = @as(*[1]u8, &foo)[0..];2068 const slice = @as(*[1]u8, &foo)[0..];
2069 assert(@typeOf(slice) == []align(4) u8);2069 assert(@TypeOf(slice) == []align(4) u8);
2070}2070}
20712071
2072fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; }2072fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; }
...@@ -2075,8 +2075,8 @@ fn noop4() align(4) void {}...@@ -2075,8 +2075,8 @@ fn noop4() align(4) void {}
20752075
2076test "function alignment" {2076test "function alignment" {
2077 assert(derp() == 1234);2077 assert(derp() == 1234);
2078 assert(@typeOf(noop1) == fn() align(1) void);2078 assert(@TypeOf(noop1) == fn() align(1) void);
2079 assert(@typeOf(noop4) == fn() align(4) void);2079 assert(@TypeOf(noop4) == fn() align(4) void);
2080 noop1();2080 noop1();
2081 noop4();2081 noop4();
2082}2082}
...@@ -2162,8 +2162,8 @@ test "basic slices" {...@@ -2162,8 +2162,8 @@ test "basic slices" {
21622162
2163 // Using the address-of operator on a slice gives a pointer to a single2163 // Using the address-of operator on a slice gives a pointer to a single
2164 // item, while using the `ptr` field gives an unknown length pointer.2164 // item, while using the `ptr` field gives an unknown length pointer.
2165 assert(@typeOf(slice.ptr) == [*]i32);2165 assert(@TypeOf(slice.ptr) == [*]i32);
2166 assert(@typeOf(&slice[0]) == *i32);2166 assert(@TypeOf(&slice[0]) == *i32);
2167 assert(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));2167 assert(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));
21682168
2169 // Slices have array bounds checking. If you try to access something out2169 // Slices have array bounds checking. If you try to access something out
...@@ -2208,7 +2208,7 @@ test "slice pointer" {...@@ -2208,7 +2208,7 @@ test "slice pointer" {
2208 slice[2] = 3;2208 slice[2] = 3;
2209 assert(slice[2] == 3);2209 assert(slice[2] == 3);
2210 // The slice is mutable because we sliced a mutable pointer.2210 // The slice is mutable because we sliced a mutable pointer.
2211 assert(@typeOf(slice) == []u8);2211 assert(@TypeOf(slice) == []u8);
22122212
2213 // You can also slice a slice:2213 // You can also slice a slice:
2214 const slice2 = slice[2..3];2214 const slice2 = slice[2..3];
...@@ -3566,7 +3566,7 @@ test "for basics" {...@@ -3566,7 +3566,7 @@ test "for basics" {
3566 // This is zero-indexed.3566 // This is zero-indexed.
3567 var sum2: i32 = 0;3567 var sum2: i32 = 0;
3568 for (items) |value, i| {3568 for (items) |value, i| {
3569 assert(@typeOf(i) == usize);3569 assert(@TypeOf(i) == usize);
3570 sum2 += @intCast(i32, i);3570 sum2 += @intCast(i32, i);
3571 }3571 }
3572 assert(sum2 == 10);3572 assert(sum2 == 10);
...@@ -3909,7 +3909,7 @@ test "type of unreachable" {...@@ -3909,7 +3909,7 @@ test "type of unreachable" {
3909 // However this assertion will still fail because3909 // However this assertion will still fail because
3910 // evaluating unreachable at compile-time is a compile error.3910 // evaluating unreachable at compile-time is a compile error.
39113911
3912 assert(@typeOf(unreachable) == noreturn);3912 assert(@TypeOf(unreachable) == noreturn);
3913 }3913 }
3914}3914}
3915 {#code_end#}3915 {#code_end#}
...@@ -4018,7 +4018,7 @@ test "function" {...@@ -4018,7 +4018,7 @@ test "function" {
4018const assert = @import("std").debug.assert;4018const assert = @import("std").debug.assert;
40194019
4020comptime {4020comptime {
4021 assert(@typeOf(foo) == fn()void);4021 assert(@TypeOf(foo) == fn()void);
4022 assert(@sizeOf(fn()void) == @sizeOf(?fn()void));4022 assert(@sizeOf(fn()void) == @sizeOf(?fn()void));
4023}4023}
40244024
...@@ -4062,35 +4062,35 @@ test "pass struct to function" {...@@ -4062,35 +4062,35 @@ test "pass struct to function" {
4062 </p>4062 </p>
4063 {#header_close#}4063 {#header_close#}
4064 {#header_open|Function Parameter Type Inference#}4064 {#header_open|Function Parameter Type Inference#}
4065 <p> 4065 <p>
4066 Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type. 4066 Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.
4067 In this case the parameter types will be inferred when the function is called.4067 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.
4069 </p>4069 </p>
4070 {#code_begin|test#}4070 {#code_begin|test#}
4071const assert = @import("std").debug.assert;4071const assert = @import("std").debug.assert;
40724072
4073fn addFortyTwo(x: var) @typeOf(x) {4073fn addFortyTwo(x: var) @TypeOf(x) {
4074 return x + 42;4074 return x + 42;
4075}4075}
40764076
4077test "fn type inference" {4077test "fn type inference" {
4078 assert(addFortyTwo(1) == 43);4078 assert(addFortyTwo(1) == 43);
4079 assert(@typeOf(addFortyTwo(1)) == comptime_int);4079 assert(@TypeOf(addFortyTwo(1)) == comptime_int);
4080 var y: i64 = 2;4080 var y: i64 = 2;
4081 assert(addFortyTwo(y) == 44);4081 assert(addFortyTwo(y) == 44);
4082 assert(@typeOf(addFortyTwo(y)) == i64);4082 assert(@TypeOf(addFortyTwo(y)) == i64);
4083}4083}
4084 {#code_end#}4084 {#code_end#}
4085 4085
4086 {#header_close#}4086 {#header_close#}
4087 {#header_open|Function Reflection#}4087 {#header_open|Function Reflection#}
4088 {#code_begin|test#}4088 {#code_begin|test#}
4089const assert = @import("std").debug.assert;4089const assert = @import("std").debug.assert;
40904090
4091test "fn reflection" {4091test "fn reflection" {
4092 assert(@typeOf(assert).ReturnType == void);4092 assert(@TypeOf(assert).ReturnType == void);
4093 assert(@typeOf(assert).is_var_args == false);4093 assert(@TypeOf(assert).is_var_args == false);
4094}4094}
4095 {#code_end#}4095 {#code_end#}
4096 {#header_close#}4096 {#header_close#}
...@@ -4390,10 +4390,10 @@ test "error union" {...@@ -4390,10 +4390,10 @@ test "error union" {
4390 foo = error.SomeError;4390 foo = error.SomeError;
43914391
4392 // Use compile-time reflection to access the payload type of an error union:4392 // 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
4395 // Use compile-time reflection to access the error set type of an error union:4395 // 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);
4397}4397}
4398 {#code_end#}4398 {#code_end#}
4399 {#header_open|Merging Error Sets#}4399 {#header_open|Merging Error Sets#}
...@@ -4770,7 +4770,7 @@ test "optional type" {...@@ -4770,7 +4770,7 @@ test "optional type" {
4770 foo = 1234;4770 foo = 1234;
47714771
4772 // Use compile-time reflection to access the child type of the optional:4772 // 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);
4774}4774}
4775 {#code_end#}4775 {#code_end#}
4776 {#header_close#}4776 {#header_close#}
...@@ -5154,7 +5154,7 @@ test "peer resolve int widening" {...@@ -5154,7 +5154,7 @@ test "peer resolve int widening" {
5154 var b: i16 = 34;5154 var b: i16 = 34;
5155 var c = a + b;5155 var c = a + b;
5156 assert(c == 46);5156 assert(c == 46);
5157 assert(@typeOf(c) == i16);5157 assert(@TypeOf(c) == i16);
5158}5158}
51595159
5160test "peer resolve arrays of different size to const slice" {5160test "peer resolve arrays of different size to const slice" {
...@@ -5949,7 +5949,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {...@@ -5949,7 +5949,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
5949 </p>5949 </p>
5950 {#code_begin|syntax#}5950 {#code_begin|syntax#}
5951pub fn printValue(self: *OutStream, value: var) !void {5951pub fn printValue(self: *OutStream, value: var) !void {
5952 const T = @typeOf(value);5952 const T = @TypeOf(value);
5953 if (@isInteger(T)) {5953 if (@isInteger(T)) {
5954 return self.printInt(T, value);5954 return self.printInt(T, value);
5955 } else if (@isFloat(T)) {5955 } else if (@isFloat(T)) {
...@@ -6265,7 +6265,7 @@ test "async function suspend with block" {...@@ -6265,7 +6265,7 @@ test "async function suspend with block" {
62656265
6266fn testSuspendBlock() void {6266fn testSuspendBlock() void {
6267 suspend {6267 suspend {
6268 comptime assert(@typeOf(@frame()) == *@Frame(testSuspendBlock));6268 comptime assert(@TypeOf(@frame()) == *@Frame(testSuspendBlock));
6269 the_frame = @frame();6269 the_frame = @frame();
6270 }6270 }
6271 result = true;6271 result = true;
...@@ -6332,7 +6332,7 @@ test "async and await" {...@@ -6332,7 +6332,7 @@ test "async and await" {
63326332
6333fn amain() void {6333fn amain() void {
6334 var frame = async func();6334 var frame = async func();
6335 comptime assert(@typeOf(frame) == @Frame(func));6335 comptime assert(@TypeOf(frame) == @Frame(func));
63366336
6337 const ptr: anyframe->void = &frame;6337 const ptr: anyframe->void = &frame;
6338 const any_ptr: anyframe = ptr;6338 const any_ptr: anyframe = ptr;
...@@ -6740,7 +6740,7 @@ async fn func(y: *i32) void {...@@ -6740,7 +6740,7 @@ async fn func(y: *i32) void {
6740 Converts a value of one type to another type.6740 Converts a value of one type to another type.
6741 </p>6741 </p>
6742 <p>6742 <p>
6743 Asserts that {#syntax#}@sizeOf(@typeOf(value)) == @sizeOf(DestType){#endsyntax#}.6743 Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
6744 </p>6744 </p>
6745 <p>6745 <p>
6746 Asserts that {#syntax#}@typeId(DestType) != @import("builtin").TypeId.Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.6746 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...@@ -7045,7 +7045,7 @@ fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_v
7045 <p>7045 <p>
7046 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.7046 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
7047 </p>7047 </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>
7049 {#see_also|Compile Variables|cmpxchgWeak#}7049 {#see_also|Compile Variables|cmpxchgWeak#}
7050 {#header_close#}7050 {#header_close#}
7051 {#header_open|@cmpxchgWeak#}7051 {#header_open|@cmpxchgWeak#}
...@@ -7073,7 +7073,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -7073,7 +7073,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
7073 <p>7073 <p>
7074 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.7074 {#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
7075 </p>7075 </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>
7077 {#see_also|Compile Variables|cmpxchgStrong#}7077 {#see_also|Compile Variables|cmpxchgStrong#}
7078 {#header_close#}7078 {#header_close#}
70797079
...@@ -8020,7 +8020,7 @@ test "@setRuntimeSafety" {...@@ -8020,7 +8020,7 @@ test "@setRuntimeSafety" {
8020 {#header_close#}8020 {#header_close#}
80218021
8022 {#header_open|@splat#}8022 {#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>
8024 <p>8024 <p>
8025 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value8025 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value
8026 {#syntax#}scalar{#endsyntax#}:8026 {#syntax#}scalar{#endsyntax#}:
...@@ -8032,7 +8032,7 @@ const assert = std.debug.assert;...@@ -8032,7 +8032,7 @@ const assert = std.debug.assert;
8032test "vector @splat" {8032test "vector @splat" {
8033 const scalar: u32 = 5;8033 const scalar: u32 = 5;
8034 const result = @splat(4, scalar);8034 const result = @splat(4, scalar);
8035 comptime assert(@typeOf(result) == @Vector(4, u32));8035 comptime assert(@TypeOf(result) == @Vector(4, u32));
8036 assert(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));8036 assert(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 }));
8037}8037}
8038 {#code_end#}8038 {#code_end#}
...@@ -8250,8 +8250,8 @@ test "integer truncation" {...@@ -8250,8 +8250,8 @@ test "integer truncation" {
8250 <li>{#link|Pointers#}</li>8250 <li>{#link|Pointers#}</li>
8251 <li>{#syntax#}comptime_int{#endsyntax#}</li>8251 <li>{#syntax#}comptime_int{#endsyntax#}</li>
8252 <li>{#syntax#}comptime_float{#endsyntax#}</li>8252 <li>{#syntax#}comptime_float{#endsyntax#}</li>
8253 <li>{#syntax#}@typeOf(undefined){#endsyntax#}</li>8253 <li>{#syntax#}@TypeOf(undefined){#endsyntax#}</li>
8254 <li>{#syntax#}@typeOf(null){#endsyntax#}</li>8254 <li>{#syntax#}@TypeOf(null){#endsyntax#}</li>
8255 </ul>8255 </ul>
8256 <p>8256 <p>
8257 For these types it is a8257 For these types it is a
...@@ -8516,20 +8516,20 @@ pub const TypeInfo = union(TypeId) {...@@ -8516,20 +8516,20 @@ pub const TypeInfo = union(TypeId) {
85168516
8517 {#header_close#}8517 {#header_close#}
85188518
8519 {#header_open|@typeOf#}8519 {#header_open|@TypeOf#}
8520 <pre>{#syntax#}@typeOf(expression) type{#endsyntax#}</pre>8520 <pre>{#syntax#}@TypeOf(expression) type{#endsyntax#}</pre>
8521 <p>8521 <p>
8522 This function returns a compile-time constant, which is the type of the8522 This function returns a compile-time constant, which is the type of the
8523 expression passed as an argument. The expression is evaluated.8523 expression passed as an argument. The expression is evaluated.
8524 </p>8524 </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>
8526 {#code_begin|test#}8526 {#code_begin|test#}
8527const std = @import("std");8527const std = @import("std");
8528const assert = std.debug.assert;8528const assert = std.debug.assert;
85298529
8530test "no runtime side effects" {8530test "no runtime side effects" {
8531 var data: i32 = 0;8531 var data: i32 = 0;
8532 const T = @typeOf(foo(i32, &data));8532 const T = @TypeOf(foo(i32, &data));
8533 comptime assert(T == i32);8533 comptime assert(T == i32);
8534 assert(data == 0);8534 assert(data == 0);
8535}8535}