From 30715560c829d5636734edf7eabff3ee4d170e5d Mon Sep 17 00:00:00 2001
From: Robin Voetter
@@ -2041,8 +2041,8 @@ const builtin = @import("builtin");
test "variable alignment" {
var x: i32 = 1234;
- const align_of_i32 = @alignOf(@typeOf(x));
- assert(@typeOf(&x) == *i32);
+ const align_of_i32 = @alignOf(@TypeOf(x));
+ assert(@TypeOf(&x) == *i32);
assert(*i32 == *align(align_of_i32) i32);
if (builtin.arch == builtin.Arch.x86_64) {
assert((*i32).alignment == 4);
@@ -2063,10 +2063,10 @@ const assert = @import("std").debug.assert;
var foo: u8 align(4) = 100;
test "global variable alignment" {
- assert(@typeOf(&foo).alignment == 4);
- assert(@typeOf(&foo) == *align(4) u8);
+ assert(@TypeOf(&foo).alignment == 4);
+ assert(@TypeOf(&foo) == *align(4) u8);
const slice = @as(*[1]u8, &foo)[0..];
- assert(@typeOf(slice) == []align(4) u8);
+ assert(@TypeOf(slice) == []align(4) u8);
}
fn derp() align(@sizeOf(usize) * 2) i32 { return 1234; }
@@ -2075,8 +2075,8 @@ fn noop4() align(4) void {}
test "function alignment" {
assert(derp() == 1234);
- assert(@typeOf(noop1) == fn() align(1) void);
- assert(@typeOf(noop4) == fn() align(4) void);
+ assert(@TypeOf(noop1) == fn() align(1) void);
+ assert(@TypeOf(noop4) == fn() align(4) void);
noop1();
noop4();
}
@@ -2162,8 +2162,8 @@ test "basic slices" {
// Using the address-of operator on a slice gives a pointer to a single
// item, while using the `ptr` field gives an unknown length pointer.
- assert(@typeOf(slice.ptr) == [*]i32);
- assert(@typeOf(&slice[0]) == *i32);
+ assert(@TypeOf(slice.ptr) == [*]i32);
+ assert(@TypeOf(&slice[0]) == *i32);
assert(@ptrToInt(slice.ptr) == @ptrToInt(&slice[0]));
// Slices have array bounds checking. If you try to access something out
@@ -2208,7 +2208,7 @@ test "slice pointer" {
slice[2] = 3;
assert(slice[2] == 3);
// The slice is mutable because we sliced a mutable pointer.
- assert(@typeOf(slice) == []u8);
+ assert(@TypeOf(slice) == []u8);
// You can also slice a slice:
const slice2 = slice[2..3];
@@ -3566,7 +3566,7 @@ test "for basics" {
// This is zero-indexed.
var sum2: i32 = 0;
for (items) |value, i| {
- assert(@typeOf(i) == usize);
+ assert(@TypeOf(i) == usize);
sum2 += @intCast(i32, i);
}
assert(sum2 == 10);
@@ -3909,7 +3909,7 @@ test "type of unreachable" {
// However this assertion will still fail because
// evaluating unreachable at compile-time is a compile error.
- assert(@typeOf(unreachable) == noreturn);
+ assert(@TypeOf(unreachable) == noreturn);
}
}
{#code_end#}
@@ -4018,7 +4018,7 @@ test "function" {
const assert = @import("std").debug.assert;
comptime {
- assert(@typeOf(foo) == fn()void);
+ assert(@TypeOf(foo) == fn()void);
assert(@sizeOf(fn()void) == @sizeOf(?fn()void));
}
@@ -4062,35 +4062,35 @@ test "pass struct to function" {
- Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.
+
+ Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.
In this case the parameter types will be inferred when the function is called.
- Use {#link|@typeOf#} and {#link|@typeInfo#} to get information about the inferred type.
+ Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type.
- Asserts that {#syntax#}@sizeOf(@typeOf(value)) == @sizeOf(DestType){#endsyntax#}. + Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
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
{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
-{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}
+{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}
{#see_also|Compile Variables|cmpxchgWeak#} {#header_close#} {#header_open|@cmpxchgWeak#} @@ -7073,7 +7073,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("builtin").AtomicOrder{#endsyntax#}.
-{#syntax#}@typeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}
+{#syntax#}@TypeOf(ptr).alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}
{#see_also|Compile Variables|cmpxchgStrong#} {#header_close#} @@ -8020,7 +8020,7 @@ test "@setRuntimeSafety" { {#header_close#} {#header_open|@splat#} -{#syntax#}@splat(comptime len: u32, scalar: var) @Vector(len, @typeOf(scalar)){#endsyntax#}
+ {#syntax#}@splat(comptime len: u32, scalar: var) @Vector(len, @TypeOf(scalar)){#endsyntax#}
Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value {#syntax#}scalar{#endsyntax#}: @@ -8032,7 +8032,7 @@ const assert = std.debug.assert; test "vector @splat" { const scalar: u32 = 5; const result = @splat(4, scalar); - comptime assert(@typeOf(result) == @Vector(4, u32)); + comptime assert(@TypeOf(result) == @Vector(4, u32)); assert(std.mem.eql(u32, &@as([4]u32, result), &[_]u32{ 5, 5, 5, 5 })); } {#code_end#} @@ -8250,8 +8250,8 @@ test "integer truncation" {
For these types it is a @@ -8516,20 +8516,20 @@ pub const TypeInfo = union(TypeId) { {#header_close#} - {#header_open|@typeOf#} -
{#syntax#}@typeOf(expression) type{#endsyntax#}
+ {#header_open|@TypeOf#}
+ {#syntax#}@TypeOf(expression) type{#endsyntax#}
This function returns a compile-time constant, which is the type of the expression passed as an argument. The expression is evaluated.
-{#syntax#}@typeOf{#endsyntax#} guarantees no run-time side-effects within the expression:
+{#syntax#}@TypeOf{#endsyntax#} guarantees no run-time side-effects within the expression:
{#code_begin|test#} const std = @import("std"); const assert = std.debug.assert; test "no runtime side effects" { var data: i32 = 0; - const T = @typeOf(foo(i32, &data)); + const T = @TypeOf(foo(i32, &data)); comptime assert(T == i32); assert(data == 0); }