authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-08-28 10:49:31-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-08-28 10:49:31-07:00
log31fef6f1103ea64a899729adea13b0ab9b66cb46
tree31c13b06483af84cd0977be8de00d3539e3e3c4d
parent9a12905a2da045b0948f612583b526bca3a1b2f0
parentaaa7e739831f39151a37c7beb08660f0fb6ae0ed
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21225 from mlugg/std-builtin-type

std: update `std.builtin.Type` fields to follow naming conventions

336 files changed, 4119 insertions(+), 4118 deletions(-)

doc/langref.html.in+12-12
...@@ -4299,7 +4299,7 @@ comptime {...@@ -4299,7 +4299,7 @@ comptime {
4299 Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.4299 Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
4300 </p>4300 </p>
4301 <p>4301 <p>
4302 Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.4302 Asserts that {#syntax#}@typeInfo(DestType) != .pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
4303 </p>4303 </p>
4304 <p>4304 <p>
4305 Can be used for these things for example:4305 Can be used for these things for example:
...@@ -4517,7 +4517,7 @@ comptime {...@@ -4517,7 +4517,7 @@ comptime {
4517 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,4517 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
4518 an integer or an enum.4518 an integer or an enum.
4519 </p>4519 </p>
4520 <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>4520 <p>{#syntax#}@typeInfo(@TypeOf(ptr)).pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
4521 <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p>4521 <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p>
4522 {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak#}4522 {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak#}
4523 {#header_close#}4523 {#header_close#}
...@@ -4549,7 +4549,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -4549,7 +4549,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
4549 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,4549 {#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
4550 an integer or an enum.4550 an integer or an enum.
4551 </p>4551 </p>
4552 <p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>4552 <p>{#syntax#}@typeInfo(@TypeOf(ptr)).pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
4553 <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p>4553 <p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p>
4554 {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgStrong#}4554 {#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgStrong#}
4555 {#header_close#}4555 {#header_close#}
...@@ -4672,7 +4672,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -4672,7 +4672,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
4672 <p>4672 <p>
4673 Floored division. Rounds toward negative infinity. For unsigned integers it is4673 Floored division. Rounds toward negative infinity. For unsigned integers it is
4674 the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and4674 the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
4675 {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.4675 {#syntax#}!(@typeInfo(T) == .int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
4676 </p>4676 </p>
4677 <ul>4677 <ul>
4678 <li>{#syntax#}@divFloor(-5, 3) == -2{#endsyntax#}</li>4678 <li>{#syntax#}@divFloor(-5, 3) == -2{#endsyntax#}</li>
...@@ -4686,7 +4686,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -4686,7 +4686,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
4686 <p>4686 <p>
4687 Truncated division. Rounds toward zero. For unsigned integers it is4687 Truncated division. Rounds toward zero. For unsigned integers it is
4688 the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and4688 the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
4689 {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.4689 {#syntax#}!(@typeInfo(T) == .int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
4690 </p>4690 </p>
4691 <ul>4691 <ul>
4692 <li>{#syntax#}@divTrunc(-5, 3) == -1{#endsyntax#}</li>4692 <li>{#syntax#}@divTrunc(-5, 3) == -1{#endsyntax#}</li>
...@@ -5320,8 +5320,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5320,8 +5320,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5320 any bits that disagree with the resultant sign bit are shifted out.5320 any bits that disagree with the resultant sign bit are shifted out.
5321 </p>5321 </p>
5322 <p>5322 <p>
5323 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits.5323 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).int.bits){#endsyntax#} bits.
5324 This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior.5324 This is because {#syntax#}shift_amt >= @typeInfo(T).int.bits{#endsyntax#} is undefined behavior.
5325 </p>5325 </p>
5326 <p>5326 <p>
5327 {#syntax#}comptime_int{#endsyntax#} is modeled as an integer with an infinite number of bits,5327 {#syntax#}comptime_int{#endsyntax#} is modeled as an integer with an infinite number of bits,
...@@ -5337,8 +5337,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5337,8 +5337,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5337 Performs {#syntax#}a << b{#endsyntax#} and returns a tuple with the result and a possible overflow bit.5337 Performs {#syntax#}a << b{#endsyntax#} and returns a tuple with the result and a possible overflow bit.
5338 </p>5338 </p>
5339 <p>5339 <p>
5340 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(@TypeOf(a)).Int.bits){#endsyntax#} bits.5340 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(@TypeOf(a)).int.bits){#endsyntax#} bits.
5341 This is because {#syntax#}shift_amt >= @typeInfo(@TypeOf(a)).Int.bits{#endsyntax#} is undefined behavior.5341 This is because {#syntax#}shift_amt >= @typeInfo(@TypeOf(a)).int.bits{#endsyntax#} is undefined behavior.
5342 </p>5342 </p>
5343 {#see_also|@shlExact|@shrExact#}5343 {#see_also|@shlExact|@shrExact#}
5344 {#header_close#}5344 {#header_close#}
...@@ -5350,8 +5350,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5350,8 +5350,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5350 that the shift will not shift any 1 bits out.5350 that the shift will not shift any 1 bits out.
5351 </p>5351 </p>
5352 <p>5352 <p>
5353 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits.5353 The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).int.bits){#endsyntax#} bits.
5354 This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior.5354 This is because {#syntax#}shift_amt >= @typeInfo(T).int.bits{#endsyntax#} is undefined behavior.
5355 </p>5355 </p>
5356 {#see_also|@shlExact|@shlWithOverflow#}5356 {#see_also|@shlExact|@shlWithOverflow#}
5357 {#header_close#}5357 {#header_close#}
...@@ -5405,7 +5405,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val...@@ -5405,7 +5405,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
5405 This size may contain padding bytes. If there were two consecutive T in memory, the padding would be the offset5405 This size may contain padding bytes. If there were two consecutive T in memory, the padding would be the offset
5406 in bytes between element at index 0 and the element at index 1. For {#link|integer|Integers#},5406 in bytes between element at index 0 and the element at index 1. For {#link|integer|Integers#},
5407 consider whether you want to use {#syntax#}@sizeOf(T){#endsyntax#} or5407 consider whether you want to use {#syntax#}@sizeOf(T){#endsyntax#} or
5408 {#syntax#}@typeInfo(T).Int.bits{#endsyntax#}.5408 {#syntax#}@typeInfo(T).int.bits{#endsyntax#}.
5409 </p>5409 </p>
5410 <p>5410 <p>
5411 This function measures the size at runtime. For types that are disallowed at runtime, such as5411 This function measures the size at runtime. For types that are disallowed at runtime, such as
doc/langref/inline_prong_range.zig+2-2
...@@ -1,7 +1,7 @@...@@ -1,7 +1,7 @@
1fn isFieldOptional(comptime T: type, field_index: usize) !bool {1fn isFieldOptional(comptime T: type, field_index: usize) !bool {
2 const fields = @typeInfo(T).Struct.fields;2 const fields = @typeInfo(T).@"struct".fields;
3 return switch (field_index) {3 return switch (field_index) {
4 inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional,4 inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .optional,
5 else => return error.IndexOutOfBounds,5 else => return error.IndexOutOfBounds,
6 };6 };
7}7}
doc/langref/poc_printValue_fn.zig+3-3
...@@ -1,13 +1,13 @@...@@ -1,13 +1,13 @@
1const Writer = struct {1const Writer = struct {
2 pub fn printValue(self: *Writer, value: anytype) !void {2 pub fn printValue(self: *Writer, value: anytype) !void {
3 switch (@typeInfo(@TypeOf(value))) {3 switch (@typeInfo(@TypeOf(value))) {
4 .Int => {4 .int => {
5 return self.writeInt(value);5 return self.writeInt(value);
6 },6 },
7 .Float => {7 .float => {
8 return self.writeFloat(value);8 return self.writeFloat(value);
9 },9 },
10 .Pointer => {10 .pointer => {
11 return self.write(value);11 return self.write(value);
12 },12 },
13 else => {13 else => {
doc/langref/test_enums.zig+3-3
...@@ -95,13 +95,13 @@ const Small = enum {...@@ -95,13 +95,13 @@ const Small = enum {
95 four,95 four,
96};96};
97test "std.meta.Tag" {97test "std.meta.Tag" {
98 try expect(@typeInfo(Small).Enum.tag_type == u2);98 try expect(@typeInfo(Small).@"enum".tag_type == u2);
99}99}
100100
101// @typeInfo tells us the field count and the fields names:101// @typeInfo tells us the field count and the fields names:
102test "@typeInfo" {102test "@typeInfo" {
103 try expect(@typeInfo(Small).Enum.fields.len == 4);103 try expect(@typeInfo(Small).@"enum".fields.len == 4);
104 try expect(mem.eql(u8, @typeInfo(Small).Enum.fields[1].name, "two"));104 try expect(mem.eql(u8, @typeInfo(Small).@"enum".fields[1].name, "two"));
105}105}
106106
107// @tagName gives a [:0]const u8 representation of an enum value:107// @tagName gives a [:0]const u8 representation of an enum value:
doc/langref/test_error_union.zig+2-2
...@@ -10,10 +10,10 @@ test "error union" {...@@ -10,10 +10,10 @@ test "error union" {
10 foo = error.SomeError;10 foo = error.SomeError;
1111
12 // Use compile-time reflection to access the payload type of an error union:12 // Use compile-time reflection to access the payload type of an error union:
13 try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.payload == i32);13 try comptime expect(@typeInfo(@TypeOf(foo)).error_union.payload == i32);
1414
15 // Use compile-time reflection to access the error set type of an error union:15 // Use compile-time reflection to access the error set type of an error union:
16 try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.error_set == anyerror);16 try comptime expect(@typeInfo(@TypeOf(foo)).error_union.error_set == anyerror);
17}17}
1818
19// test19// test
doc/langref/test_fn_reflection.zig+3-3
...@@ -3,10 +3,10 @@ const math = std.math;...@@ -3,10 +3,10 @@ const math = std.math;
3const testing = std.testing;3const testing = std.testing;
44
5test "fn reflection" {5test "fn reflection" {
6 try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.params[0].type.? == bool);6 try testing.expect(@typeInfo(@TypeOf(testing.expect)).@"fn".params[0].type.? == bool);
7 try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir);7 try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).@"fn".return_type.? == testing.TmpDir);
88
9 try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic);9 try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).@"fn".is_generic);
10}10}
1111
12// test12// test
doc/langref/test_inline_else.zig+2-2
...@@ -17,8 +17,8 @@ const AnySlice = union(enum) {...@@ -17,8 +17,8 @@ const AnySlice = union(enum) {
17};17};
1818
19fn withFor(any: AnySlice) usize {19fn withFor(any: AnySlice) usize {
20 const Tag = @typeInfo(AnySlice).Union.tag_type.?;20 const Tag = @typeInfo(AnySlice).@"union".tag_type.?;
21 inline for (@typeInfo(Tag).Enum.fields) |field| {21 inline for (@typeInfo(Tag).@"enum".fields) |field| {
22 // With `inline for` the function gets generated as22 // With `inline for` the function gets generated as
23 // a series of `if` statements relying on the optimizer23 // a series of `if` statements relying on the optimizer
24 // to convert it to a switch.24 // to convert it to a switch.
doc/langref/test_inline_switch.zig+2-2
...@@ -3,11 +3,11 @@ const expect = std.testing.expect;...@@ -3,11 +3,11 @@ const expect = std.testing.expect;
3const expectError = std.testing.expectError;3const expectError = std.testing.expectError;
44
5fn isFieldOptional(comptime T: type, field_index: usize) !bool {5fn isFieldOptional(comptime T: type, field_index: usize) !bool {
6 const fields = @typeInfo(T).Struct.fields;6 const fields = @typeInfo(T).@"struct".fields;
7 return switch (field_index) {7 return switch (field_index) {
8 // This prong is analyzed twice with `idx` being a8 // This prong is analyzed twice with `idx` being a
9 // comptime-known value each time.9 // comptime-known value each time.
10 inline 0, 1 => |idx| @typeInfo(fields[idx].type) == .Optional,10 inline 0, 1 => |idx| @typeInfo(fields[idx].type) == .optional,
11 else => return error.IndexOutOfBounds,11 else => return error.IndexOutOfBounds,
12 };12 };
13}13}
doc/langref/test_optional_type.zig+1-1
...@@ -8,7 +8,7 @@ test "optional type" {...@@ -8,7 +8,7 @@ test "optional type" {
8 foo = 1234;8 foo = 1234;
99
10 // Use compile-time reflection to access the child type of the optional:10 // Use compile-time reflection to access the child type of the optional:
11 try comptime expect(@typeInfo(@TypeOf(foo)).Optional.child == i32);11 try comptime expect(@typeInfo(@TypeOf(foo)).optional.child == i32);
12}12}
1313
14// test14// test
doc/langref/test_pointer_casting.zig+1-1
...@@ -17,7 +17,7 @@ test "pointer casting" {...@@ -17,7 +17,7 @@ test "pointer casting" {
1717
18test "pointer child type" {18test "pointer child type" {
19 // pointer types have a `child` field which tells you the type they point to.19 // pointer types have a `child` field which tells you the type they point to.
20 try expect(@typeInfo(*u32).Pointer.child == u32);20 try expect(@typeInfo(*u32).pointer.child == u32);
21}21}
2222
23// test23// test
doc/langref/test_variable_alignment.zig+1-1
...@@ -8,7 +8,7 @@ test "variable alignment" {...@@ -8,7 +8,7 @@ test "variable alignment" {
8 try expect(@TypeOf(&x) == *i32);8 try expect(@TypeOf(&x) == *i32);
9 try expect(*i32 == *align(align_of_i32) i32);9 try expect(*i32 == *align(align_of_i32) i32);
10 if (builtin.target.cpu.arch == .x86_64) {10 if (builtin.target.cpu.arch == .x86_64) {
11 try expect(@typeInfo(*i32).Pointer.alignment == 4);11 try expect(@typeInfo(*i32).pointer.alignment == 4);
12 }12 }
13}13}
1414
doc/langref/test_variable_func_alignment.zig+1-1
...@@ -3,7 +3,7 @@ const expect = @import("std").testing.expect;...@@ -3,7 +3,7 @@ const expect = @import("std").testing.expect;
3var foo: u8 align(4) = 100;3var foo: u8 align(4) = 100;
44
5test "global variable alignment" {5test "global variable alignment" {
6 try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);6 try expect(@typeInfo(@TypeOf(&foo)).pointer.alignment == 4);
7 try expect(@TypeOf(&foo) == *align(4) u8);7 try expect(@TypeOf(&foo) == *align(4) u8);
8 const as_pointer_to_array: *align(4) [1]u8 = &foo;8 const as_pointer_to_array: *align(4) [1]u8 = &foo;
9 const as_slice: []align(4) u8 = as_pointer_to_array;9 const as_slice: []align(4) u8 = as_pointer_to_array;
doc/langref/test_variadic_function.zig+1-1
...@@ -5,7 +5,7 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;...@@ -5,7 +5,7 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
55
6test "variadic function" {6test "variadic function" {
7 try testing.expect(printf("Hello, world!\n") == 14);7 try testing.expect(printf("Hello, world!\n") == 14);
8 try testing.expect(@typeInfo(@TypeOf(printf)).Fn.is_var_args);8 try testing.expect(@typeInfo(@TypeOf(printf)).@"fn".is_var_args);
9}9}
1010
11// test11// test
lib/compiler/aro/aro/Attribute.zig+14-14
...@@ -67,7 +67,7 @@ pub fn requiredArgCount(attr: Tag) u32 {...@@ -67,7 +67,7 @@ pub fn requiredArgCount(attr: Tag) u32 {
67 comptime {67 comptime {
68 const fields = std.meta.fields(@field(attributes, @tagName(tag)));68 const fields = std.meta.fields(@field(attributes, @tagName(tag)));
69 for (fields) |arg_field| {69 for (fields) |arg_field| {
70 if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .Optional) needed += 1;70 if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .optional) needed += 1;
71 }71 }
72 }72 }
73 return needed;73 return needed;
...@@ -93,7 +93,7 @@ pub fn maxArgCount(attr: Tag) u32 {...@@ -93,7 +93,7 @@ pub fn maxArgCount(attr: Tag) u32 {
9393
94fn UnwrapOptional(comptime T: type) type {94fn UnwrapOptional(comptime T: type) type {
95 return switch (@typeInfo(T)) {95 return switch (@typeInfo(T)) {
96 .Optional => |optional| optional.child,96 .optional => |optional| optional.child,
97 else => T,97 else => T,
98 };98 };
99}99}
...@@ -110,7 +110,7 @@ pub const Formatting = struct {...@@ -110,7 +110,7 @@ pub const Formatting = struct {
110110
111 if (fields.len == 0) unreachable;111 if (fields.len == 0) unreachable;
112 const Unwrapped = UnwrapOptional(fields[0].type);112 const Unwrapped = UnwrapOptional(fields[0].type);
113 if (@typeInfo(Unwrapped) != .Enum) unreachable;113 if (@typeInfo(Unwrapped) != .@"enum") unreachable;
114114
115 return if (Unwrapped.opts.enum_kind == .identifier) "'" else "\"";115 return if (Unwrapped.opts.enum_kind == .identifier) "'" else "\"";
116 },116 },
...@@ -127,9 +127,9 @@ pub const Formatting = struct {...@@ -127,9 +127,9 @@ pub const Formatting = struct {
127127
128 if (fields.len == 0) unreachable;128 if (fields.len == 0) unreachable;
129 const Unwrapped = UnwrapOptional(fields[0].type);129 const Unwrapped = UnwrapOptional(fields[0].type);
130 if (@typeInfo(Unwrapped) != .Enum) unreachable;130 if (@typeInfo(Unwrapped) != .@"enum") unreachable;
131131
132 const enum_fields = @typeInfo(Unwrapped).Enum.fields;132 const enum_fields = @typeInfo(Unwrapped).@"enum".fields;
133 @setEvalBranchQuota(3000);133 @setEvalBranchQuota(3000);
134 const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag)));134 const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag)));
135 comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote;135 comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote;
...@@ -152,7 +152,7 @@ pub fn wantsIdentEnum(attr: Tag) bool {...@@ -152,7 +152,7 @@ pub fn wantsIdentEnum(attr: Tag) bool {
152152
153 if (fields.len == 0) return false;153 if (fields.len == 0) return false;
154 const Unwrapped = UnwrapOptional(fields[0].type);154 const Unwrapped = UnwrapOptional(fields[0].type);
155 if (@typeInfo(Unwrapped) != .Enum) return false;155 if (@typeInfo(Unwrapped) != .@"enum") return false;
156156
157 return Unwrapped.opts.enum_kind == .identifier;157 return Unwrapped.opts.enum_kind == .identifier;
158 },158 },
...@@ -165,7 +165,7 @@ pub fn diagnoseIdent(attr: Tag, arguments: *Arguments, ident: []const u8) ?Diagn...@@ -165,7 +165,7 @@ pub fn diagnoseIdent(attr: Tag, arguments: *Arguments, ident: []const u8) ?Diagn
165 const fields = std.meta.fields(@field(attributes, @tagName(tag)));165 const fields = std.meta.fields(@field(attributes, @tagName(tag)));
166 if (fields.len == 0) unreachable;166 if (fields.len == 0) unreachable;
167 const Unwrapped = UnwrapOptional(fields[0].type);167 const Unwrapped = UnwrapOptional(fields[0].type);
168 if (@typeInfo(Unwrapped) != .Enum) unreachable;168 if (@typeInfo(Unwrapped) != .@"enum") unreachable;
169 if (std.meta.stringToEnum(Unwrapped, normalize(ident))) |enum_val| {169 if (std.meta.stringToEnum(Unwrapped, normalize(ident))) |enum_val| {
170 @field(@field(arguments, @tagName(tag)), fields[0].name) = enum_val;170 @field(@field(arguments, @tagName(tag)), fields[0].name) = enum_val;
171 return null;171 return null;
...@@ -239,7 +239,7 @@ fn diagnoseField(...@@ -239,7 +239,7 @@ fn diagnoseField(
239 const key = p.comp.interner.get(res.val.ref());239 const key = p.comp.interner.get(res.val.ref());
240 switch (key) {240 switch (key) {
241 .int => {241 .int => {
242 if (@typeInfo(Wanted) == .Int) {242 if (@typeInfo(Wanted) == .int) {
243 @field(@field(arguments, decl.name), field.name) = res.val.toInt(Wanted, p.comp) orelse return .{243 @field(@field(arguments, decl.name), field.name) = res.val.toInt(Wanted, p.comp) orelse return .{
244 .tag = .attribute_int_out_of_range,244 .tag = .attribute_int_out_of_range,
245 .extra = .{ .str = try res.str(p) },245 .extra = .{ .str = try res.str(p) },
...@@ -258,7 +258,7 @@ fn diagnoseField(...@@ -258,7 +258,7 @@ fn diagnoseField(
258 }258 }
259 @field(@field(arguments, decl.name), field.name) = try p.removeNull(res.val);259 @field(@field(arguments, decl.name), field.name) = try p.removeNull(res.val);
260 return null;260 return null;
261 } else if (@typeInfo(Wanted) == .Enum and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) {261 } else if (@typeInfo(Wanted) == .@"enum" and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) {
262 const str = bytes[0 .. bytes.len - 1];262 const str = bytes[0 .. bytes.len - 1];
263 if (std.meta.stringToEnum(Wanted, str)) |enum_val| {263 if (std.meta.stringToEnum(Wanted, str)) |enum_val| {
264 @field(@field(arguments, decl.name), field.name) = enum_val;264 @field(@field(arguments, decl.name), field.name) = enum_val;
...@@ -293,7 +293,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess...@@ -293,7 +293,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess
293 Alignment => .alignment,293 Alignment => .alignment,
294 CallingConvention => .identifier,294 CallingConvention => .identifier,
295 else => switch (@typeInfo(Expected)) {295 else => switch (@typeInfo(Expected)) {
296 .Enum => if (Expected.opts.enum_kind == .string) .string else .identifier,296 .@"enum" => if (Expected.opts.enum_kind == .string) .string else .identifier,
297 else => unreachable,297 else => unreachable,
298 },298 },
299 }, .actual = actual } },299 }, .actual = actual } },
...@@ -303,7 +303,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess...@@ -303,7 +303,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess
303pub fn diagnose(attr: Tag, arguments: *Arguments, arg_idx: u32, res: Parser.Result, node: Tree.Node, p: *Parser) !?Diagnostics.Message {303pub fn diagnose(attr: Tag, arguments: *Arguments, arg_idx: u32, res: Parser.Result, node: Tree.Node, p: *Parser) !?Diagnostics.Message {
304 switch (attr) {304 switch (attr) {
305 inline else => |tag| {305 inline else => |tag| {
306 const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)];306 const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)];
307 const max_arg_count = comptime maxArgCount(tag);307 const max_arg_count = comptime maxArgCount(tag);
308 if (arg_idx >= max_arg_count) return Diagnostics.Message{308 if (arg_idx >= max_arg_count) return Diagnostics.Message{
309 .tag = .attribute_too_many_args,309 .tag = .attribute_too_many_args,
...@@ -641,7 +641,7 @@ const attributes = struct {...@@ -641,7 +641,7 @@ const attributes = struct {
641pub const Tag = std.meta.DeclEnum(attributes);641pub const Tag = std.meta.DeclEnum(attributes);
642642
643pub const Arguments = blk: {643pub const Arguments = blk: {
644 const decls = @typeInfo(attributes).Struct.decls;644 const decls = @typeInfo(attributes).@"struct".decls;
645 var union_fields: [decls.len]ZigType.UnionField = undefined;645 var union_fields: [decls.len]ZigType.UnionField = undefined;
646 for (decls, &union_fields) |decl, *field| {646 for (decls, &union_fields) |decl, *field| {
647 field.* = .{647 field.* = .{
...@@ -652,7 +652,7 @@ pub const Arguments = blk: {...@@ -652,7 +652,7 @@ pub const Arguments = blk: {
652 }652 }
653653
654 break :blk @Type(.{654 break :blk @Type(.{
655 .Union = .{655 .@"union" = .{
656 .layout = .auto,656 .layout = .auto,
657 .tag_type = null,657 .tag_type = null,
658 .fields = &union_fields,658 .fields = &union_fields,
...@@ -662,7 +662,7 @@ pub const Arguments = blk: {...@@ -662,7 +662,7 @@ pub const Arguments = blk: {
662};662};
663663
664pub fn ArgumentsForTag(comptime tag: Tag) type {664pub fn ArgumentsForTag(comptime tag: Tag) type {
665 const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)];665 const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)];
666 return @field(attributes, decl.name);666 return @field(attributes, decl.name);
667}667}
668668
lib/compiler/aro/aro/Compilation.zig+2-2
...@@ -61,7 +61,7 @@ pub const Environment = struct {...@@ -61,7 +61,7 @@ pub const Environment = struct {
61 var env: Environment = .{};61 var env: Environment = .{};
62 errdefer env.deinit(allocator);62 errdefer env.deinit(allocator);
6363
64 inline for (@typeInfo(@TypeOf(env)).Struct.fields) |field| {64 inline for (@typeInfo(@TypeOf(env)).@"struct".fields) |field| {
65 std.debug.assert(@field(env, field.name) == null);65 std.debug.assert(@field(env, field.name) == null);
6666
67 var env_var_buf: [field.name.len]u8 = undefined;67 var env_var_buf: [field.name.len]u8 = undefined;
...@@ -78,7 +78,7 @@ pub const Environment = struct {...@@ -78,7 +78,7 @@ pub const Environment = struct {
7878
79 /// Use this only if environment slices were allocated with `allocator` (such as via `loadAll`)79 /// Use this only if environment slices were allocated with `allocator` (such as via `loadAll`)
80 pub fn deinit(self: *Environment, allocator: std.mem.Allocator) void {80 pub fn deinit(self: *Environment, allocator: std.mem.Allocator) void {
81 inline for (@typeInfo(@TypeOf(self.*)).Struct.fields) |field| {81 inline for (@typeInfo(@TypeOf(self.*)).@"struct".fields) |field| {
82 if (@field(self, field.name)) |slice| {82 if (@field(self, field.name)) |slice| {
83 allocator.free(slice);83 allocator.free(slice);
84 }84 }
lib/compiler/aro/aro/Tree.zig+2-2
...@@ -707,7 +707,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void {...@@ -707,7 +707,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void {
707 switch (attr.tag) {707 switch (attr.tag) {
708 inline else => |tag| {708 inline else => |tag| {
709 const args = @field(attr.args, @tagName(tag));709 const args = @field(attr.args, @tagName(tag));
710 const fields = @typeInfo(@TypeOf(args)).Struct.fields;710 const fields = @typeInfo(@TypeOf(args)).@"struct".fields;
711 if (fields.len == 0) {711 if (fields.len == 0) {
712 try writer.writeByte('\n');712 try writer.writeByte('\n');
713 return;713 return;
...@@ -724,7 +724,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void {...@@ -724,7 +724,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void {
724 Interner.Ref => try writer.print("\"{s}\"", .{tree.interner.get(@field(args, f.name)).bytes}),724 Interner.Ref => try writer.print("\"{s}\"", .{tree.interner.get(@field(args, f.name)).bytes}),
725 ?Interner.Ref => try writer.print("\"{?s}\"", .{if (@field(args, f.name)) |str| tree.interner.get(str).bytes else null}),725 ?Interner.Ref => try writer.print("\"{?s}\"", .{if (@field(args, f.name)) |str| tree.interner.get(str).bytes else null}),
726 else => switch (@typeInfo(f.type)) {726 else => switch (@typeInfo(f.type)) {
727 .Enum => try writer.writeAll(@tagName(@field(args, f.name))),727 .@"enum" => try writer.writeAll(@tagName(@field(args, f.name))),
728 else => try writer.print("{any}", .{@field(args, f.name)}),728 else => try writer.print("{any}", .{@field(args, f.name)}),
729 },729 },
730 }730 }
lib/compiler/aro/aro/Value.zig+1-1
...@@ -24,7 +24,7 @@ pub fn intern(comp: *Compilation, k: Interner.Key) !Value {...@@ -24,7 +24,7 @@ pub fn intern(comp: *Compilation, k: Interner.Key) !Value {
2424
25pub fn int(i: anytype, comp: *Compilation) !Value {25pub fn int(i: anytype, comp: *Compilation) !Value {
26 const info = @typeInfo(@TypeOf(i));26 const info = @typeInfo(@TypeOf(i));
27 if (info == .ComptimeInt or info.Int.signedness == .unsigned) {27 if (info == .comptime_int or info.int.signedness == .unsigned) {
28 return intern(comp, .{ .int = .{ .u64 = i } });28 return intern(comp, .{ .int = .{ .u64 = i } });
29 } else {29 } else {
30 return intern(comp, .{ .int = .{ .i64 = i } });30 return intern(comp, .{ .int = .{ .i64 = i } });
lib/compiler/aro/backend/Interner.zig+4-4
...@@ -505,7 +505,7 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref {...@@ -505,7 +505,7 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref {
505 });505 });
506 },506 },
507 .record_ty => |elems| {507 .record_ty => |elems| {
508 try i.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.Record).Struct.fields.len +508 try i.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.Record).@"struct".fields.len +
509 elems.len);509 elems.len);
510 i.items.appendAssumeCapacity(.{510 i.items.appendAssumeCapacity(.{
511 .tag = .record_ty,511 .tag = .record_ty,
...@@ -527,14 +527,14 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref {...@@ -527,14 +527,14 @@ pub fn put(i: *Interner, gpa: Allocator, key: Key) !Ref {
527}527}
528528
529fn addExtra(i: *Interner, gpa: Allocator, extra: anytype) Allocator.Error!u32 {529fn addExtra(i: *Interner, gpa: Allocator, extra: anytype) Allocator.Error!u32 {
530 const fields = @typeInfo(@TypeOf(extra)).Struct.fields;530 const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
531 try i.extra.ensureUnusedCapacity(gpa, fields.len);531 try i.extra.ensureUnusedCapacity(gpa, fields.len);
532 return i.addExtraAssumeCapacity(extra);532 return i.addExtraAssumeCapacity(extra);
533}533}
534534
535fn addExtraAssumeCapacity(i: *Interner, extra: anytype) u32 {535fn addExtraAssumeCapacity(i: *Interner, extra: anytype) u32 {
536 const result = @as(u32, @intCast(i.extra.items.len));536 const result = @as(u32, @intCast(i.extra.items.len));
537 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {537 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| {
538 i.extra.appendAssumeCapacity(switch (field.type) {538 i.extra.appendAssumeCapacity(switch (field.type) {
539 Ref => @intFromEnum(@field(extra, field.name)),539 Ref => @intFromEnum(@field(extra, field.name)),
540 u32 => @field(extra, field.name),540 u32 => @field(extra, field.name),
...@@ -631,7 +631,7 @@ fn extraData(i: *const Interner, comptime T: type, index: usize) T {...@@ -631,7 +631,7 @@ fn extraData(i: *const Interner, comptime T: type, index: usize) T {
631631
632fn extraDataTrail(i: *const Interner, comptime T: type, index: usize) struct { data: T, end: u32 } {632fn extraDataTrail(i: *const Interner, comptime T: type, index: usize) struct { data: T, end: u32 } {
633 var result: T = undefined;633 var result: T = undefined;
634 const fields = @typeInfo(T).Struct.fields;634 const fields = @typeInfo(T).@"struct".fields;
635 inline for (fields, 0..) |field, field_i| {635 inline for (fields, 0..) |field, field_i| {
636 const int32 = i.extra.items[field_i + index];636 const int32 = i.extra.items[field_i + index];
637 @field(result, field.name) = switch (field.type) {637 @field(result, field.name) = switch (field.type) {
lib/compiler/aro_translate_c.zig+1-1
...@@ -168,7 +168,7 @@ pub fn translate(...@@ -168,7 +168,7 @@ pub fn translate(
168 context.pattern_list.deinit(gpa);168 context.pattern_list.deinit(gpa);
169 }169 }
170170
171 inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| {171 inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| {
172 const builtin_fn = try ZigTag.pub_var_simple.create(arena, .{172 const builtin_fn = try ZigTag.pub_var_simple.create(arena, .{
173 .name = decl.name,173 .name = decl.name,
174 .init = try ZigTag.import_c_builtin.create(arena, decl.name),174 .init = try ZigTag.import_c_builtin.create(arena, decl.name),
lib/compiler/resinator/bmp.zig+1-1
...@@ -224,7 +224,7 @@ pub const Compression = enum(u32) {...@@ -224,7 +224,7 @@ pub const Compression = enum(u32) {
224};224};
225225
226fn structFieldsLittleToNative(comptime T: type, x: *T) void {226fn structFieldsLittleToNative(comptime T: type, x: *T) void {
227 inline for (@typeInfo(T).Struct.fields) |field| {227 inline for (@typeInfo(T).@"struct".fields) |field| {
228 @field(x, field.name) = std.mem.littleToNative(field.type, @field(x, field.name));228 @field(x, field.name) = std.mem.littleToNative(field.type, @field(x, field.name));
229 }229 }
230}230}
lib/compiler/resinator/code_pages.zig+1-1
...@@ -259,7 +259,7 @@ pub const CodePage = enum(u16) {...@@ -259,7 +259,7 @@ pub const CodePage = enum(u16) {
259 pub fn getByIdentifier(identifier: u16) !CodePage {259 pub fn getByIdentifier(identifier: u16) !CodePage {
260 // There's probably a more efficient way to do this (e.g. ComptimeHashMap?) but260 // There's probably a more efficient way to do this (e.g. ComptimeHashMap?) but
261 // this should be fine, especially since this function likely won't be called much.261 // this should be fine, especially since this function likely won't be called much.
262 inline for (@typeInfo(CodePage).Enum.fields) |enumField| {262 inline for (@typeInfo(CodePage).@"enum".fields) |enumField| {
263 if (identifier == enumField.value) {263 if (identifier == enumField.value) {
264 return @field(CodePage, enumField.name);264 return @field(CodePage, enumField.name);
265 }265 }
lib/compiler/resinator/errors.zig+1-1
...@@ -250,7 +250,7 @@ pub const ErrorDetails = struct {...@@ -250,7 +250,7 @@ pub const ErrorDetails = struct {
250 });250 });
251251
252 pub fn writeCommaSeparated(self: ExpectedTypes, writer: anytype) !void {252 pub fn writeCommaSeparated(self: ExpectedTypes, writer: anytype) !void {
253 const struct_info = @typeInfo(ExpectedTypes).Struct;253 const struct_info = @typeInfo(ExpectedTypes).@"struct";
254 const num_real_fields = struct_info.fields.len - 1;254 const num_real_fields = struct_info.fields.len - 1;
255 const num_padding_bits = @bitSizeOf(ExpectedTypes) - num_real_fields;255 const num_padding_bits = @bitSizeOf(ExpectedTypes) - num_real_fields;
256 const mask = std.math.maxInt(struct_info.backing_integer.?) >> num_padding_bits;256 const mask = std.math.maxInt(struct_info.backing_integer.?) >> num_padding_bits;
lib/compiler/resinator/ico.zig+1-1
...@@ -14,7 +14,7 @@ pub fn read(allocator: std.mem.Allocator, reader: anytype, max_size: u64) ReadEr...@@ -14,7 +14,7 @@ pub fn read(allocator: std.mem.Allocator, reader: anytype, max_size: u64) ReadEr
14 // Some Reader implementations have an empty ReadError error set which would14 // Some Reader implementations have an empty ReadError error set which would
15 // cause 'unreachable else' if we tried to use an else in the switch, so we15 // cause 'unreachable else' if we tried to use an else in the switch, so we
16 // need to detect this case and not try to translate to ReadError16 // need to detect this case and not try to translate to ReadError
17 const empty_reader_errorset = @typeInfo(@TypeOf(reader).Error).ErrorSet == null or @typeInfo(@TypeOf(reader).Error).ErrorSet.?.len == 0;17 const empty_reader_errorset = @typeInfo(@TypeOf(reader).Error).error_set == null or @typeInfo(@TypeOf(reader).Error).error_set.?.len == 0;
18 if (empty_reader_errorset) {18 if (empty_reader_errorset) {
19 return readAnyError(allocator, reader, max_size) catch |err| switch (err) {19 return readAnyError(allocator, reader, max_size) catch |err| switch (err) {
20 error.EndOfStream => error.UnexpectedEOF,20 error.EndOfStream => error.UnexpectedEOF,
lib/compiler/resinator/lang.zig+1-1
...@@ -87,7 +87,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId {...@@ -87,7 +87,7 @@ pub fn tagToId(tag: []const u8) error{InvalidLanguageTag}!?LanguageId {
87 if (parsed.multiple_suffixes) return null;87 if (parsed.multiple_suffixes) return null;
88 const longest_known_tag = comptime blk: {88 const longest_known_tag = comptime blk: {
89 var len = 0;89 var len = 0;
90 for (@typeInfo(LanguageId).Enum.fields) |field| {90 for (@typeInfo(LanguageId).@"enum".fields) |field| {
91 if (field.name.len > len) len = field.name.len;91 if (field.name.len > len) len = field.name.len;
92 }92 }
93 break :blk len;93 break :blk len;
lib/compiler/test_runner.zig+1-1
...@@ -265,7 +265,7 @@ fn mainTerminal() void {...@@ -265,7 +265,7 @@ fn mainTerminal() void {
265265
266pub fn log(266pub fn log(
267 comptime message_level: std.log.Level,267 comptime message_level: std.log.Level,
268 comptime scope: @Type(.EnumLiteral),268 comptime scope: @Type(.enum_literal),
269 comptime format: []const u8,269 comptime format: []const u8,
270 args: anytype,270 args: anytype,
271) void {271) void {
lib/compiler_rt/addf3.zig+1-1
...@@ -7,7 +7,7 @@ const normalize = common.normalize;...@@ -7,7 +7,7 @@ const normalize = common.normalize;
7///7///
8/// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc8/// https://github.com/llvm/llvm-project/blob/02d85149a05cb1f6dc49f0ba7a2ceca53718ae17/compiler-rt/lib/builtins/fp_add_impl.inc
9pub inline fn addf3(comptime T: type, a: T, b: T) T {9pub inline fn addf3(comptime T: type, a: T, b: T) T {
10 const bits = @typeInfo(T).Float.bits;10 const bits = @typeInfo(T).float.bits;
11 const Z = std.meta.Int(.unsigned, bits);11 const Z = std.meta.Int(.unsigned, bits);
1212
13 const typeWidth = bits;13 const typeWidth = bits;
lib/compiler_rt/ceil.zig+1-1
...@@ -130,7 +130,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 {...@@ -130,7 +130,7 @@ pub fn ceilq(x: f128) callconv(.C) f128 {
130}130}
131131
132pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble {132pub fn ceill(x: c_longdouble) callconv(.C) c_longdouble {
133 switch (@typeInfo(c_longdouble).Float.bits) {133 switch (@typeInfo(c_longdouble).float.bits) {
134 16 => return __ceilh(x),134 16 => return __ceilh(x),
135 32 => return ceilf(x),135 32 => return ceilf(x),
136 64 => return ceil(x),136 64 => return ceil(x),
lib/compiler_rt/common.zig+5-5
...@@ -219,8 +219,8 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {...@@ -219,8 +219,8 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
219 }219 }
220}220}
221221
222pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {222pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).float.bits)) i32 {
223 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);223 const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
224 const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);224 const integerBit = @as(Z, 1) << std.math.floatFractionalBits(T);
225225
226 const shift = @clz(significand.*) - @clz(integerBit);226 const shift = @clz(significand.*) - @clz(integerBit);
...@@ -230,8 +230,8 @@ pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeIn...@@ -230,8 +230,8 @@ pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeIn
230230
231pub inline fn fneg(a: anytype) @TypeOf(a) {231pub inline fn fneg(a: anytype) @TypeOf(a) {
232 const F = @TypeOf(a);232 const F = @TypeOf(a);
233 const bits = @typeInfo(F).Float.bits;233 const bits = @typeInfo(F).float.bits;
234 const U = @Type(.{ .Int = .{234 const U = @Type(.{ .int = .{
235 .signedness = .unsigned,235 .signedness = .unsigned,
236 .bits = bits,236 .bits = bits,
237 } });237 } });
...@@ -244,7 +244,7 @@ pub inline fn fneg(a: anytype) @TypeOf(a) {...@@ -244,7 +244,7 @@ pub inline fn fneg(a: anytype) @TypeOf(a) {
244/// signed or unsigned integers.244/// signed or unsigned integers.
245pub fn HalveInt(comptime T: type, comptime signed_half: bool) type {245pub fn HalveInt(comptime T: type, comptime signed_half: bool) type {
246 return extern union {246 return extern union {
247 pub const bits = @divExact(@typeInfo(T).Int.bits, 2);247 pub const bits = @divExact(@typeInfo(T).int.bits, 2);
248 pub const HalfTU = std.meta.Int(.unsigned, bits);248 pub const HalfTU = std.meta.Int(.unsigned, bits);
249 pub const HalfTS = std.meta.Int(.signed, bits);249 pub const HalfTS = std.meta.Int(.signed, bits);
250 pub const HalfT = if (signed_half) HalfTS else HalfTU;250 pub const HalfT = if (signed_half) HalfTS else HalfTU;
lib/compiler_rt/comparef.zig+2-2
...@@ -17,7 +17,7 @@ pub const GE = enum(i32) {...@@ -17,7 +17,7 @@ pub const GE = enum(i32) {
17};17};
1818
19pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT {19pub inline fn cmpf2(comptime T: type, comptime RT: type, a: T, b: T) RT {
20 const bits = @typeInfo(T).Float.bits;20 const bits = @typeInfo(T).float.bits;
21 const srep_t = std.meta.Int(.signed, bits);21 const srep_t = std.meta.Int(.signed, bits);
22 const rep_t = std.meta.Int(.unsigned, bits);22 const rep_t = std.meta.Int(.unsigned, bits);
2323
...@@ -109,7 +109,7 @@ test "cmp_f80" {...@@ -109,7 +109,7 @@ test "cmp_f80" {
109}109}
110110
111pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {111pub inline fn unordcmp(comptime T: type, a: T, b: T) i32 {
112 const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);112 const rep_t = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
113113
114 const significandBits = std.math.floatMantissaBits(T);114 const significandBits = std.math.floatMantissaBits(T);
115 const exponentBits = std.math.floatExponentBits(T);115 const exponentBits = std.math.floatExponentBits(T);
lib/compiler_rt/cos.zig+1-1
...@@ -124,7 +124,7 @@ pub fn cosq(a: f128) callconv(.C) f128 {...@@ -124,7 +124,7 @@ pub fn cosq(a: f128) callconv(.C) f128 {
124}124}
125125
126pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble {126pub fn cosl(x: c_longdouble) callconv(.C) c_longdouble {
127 switch (@typeInfo(c_longdouble).Float.bits) {127 switch (@typeInfo(c_longdouble).float.bits) {
128 16 => return __cosh(x),128 16 => return __cosh(x),
129 32 => return cosf(x),129 32 => return cosf(x),
130 64 => return cos(x),130 64 => return cos(x),
lib/compiler_rt/count0bits.zig+1-1
...@@ -203,7 +203,7 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 {...@@ -203,7 +203,7 @@ pub fn __ctzti2(a: i128) callconv(.C) i32 {
203}203}
204204
205inline fn ffsXi2(comptime T: type, a: T) i32 {205inline fn ffsXi2(comptime T: type, a: T) i32 {
206 var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a);206 var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a);
207 var n: T = 1;207 var n: T = 1;
208 // adapted from Number of trailing zeroes (see ctzXi2)208 // adapted from Number of trailing zeroes (see ctzXi2)
209 var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));209 var mask: @TypeOf(x) = std.math.maxInt(@TypeOf(x));
lib/compiler_rt/exp.zig+1-1
...@@ -201,7 +201,7 @@ pub fn expq(a: f128) callconv(.C) f128 {...@@ -201,7 +201,7 @@ pub fn expq(a: f128) callconv(.C) f128 {
201}201}
202202
203pub fn expl(x: c_longdouble) callconv(.C) c_longdouble {203pub fn expl(x: c_longdouble) callconv(.C) c_longdouble {
204 switch (@typeInfo(c_longdouble).Float.bits) {204 switch (@typeInfo(c_longdouble).float.bits) {
205 16 => return __exph(x),205 16 => return __exph(x),
206 32 => return expf(x),206 32 => return expf(x),
207 64 => return exp(x),207 64 => return exp(x),
lib/compiler_rt/exp2.zig+1-1
...@@ -168,7 +168,7 @@ pub fn exp2q(x: f128) callconv(.C) f128 {...@@ -168,7 +168,7 @@ pub fn exp2q(x: f128) callconv(.C) f128 {
168}168}
169169
170pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble {170pub fn exp2l(x: c_longdouble) callconv(.C) c_longdouble {
171 switch (@typeInfo(c_longdouble).Float.bits) {171 switch (@typeInfo(c_longdouble).float.bits) {
172 16 => return __exp2h(x),172 16 => return __exp2h(x),
173 32 => return exp2f(x),173 32 => return exp2f(x),
174 64 => return exp2(x),174 64 => return exp2(x),
lib/compiler_rt/extendf.zig+5-5
...@@ -3,10 +3,10 @@ const std = @import("std");...@@ -3,10 +3,10 @@ const std = @import("std");
3pub inline fn extendf(3pub inline fn extendf(
4 comptime dst_t: type,4 comptime dst_t: type,
5 comptime src_t: type,5 comptime src_t: type,
6 a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits),6 a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits),
7) dst_t {7) dst_t {
8 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits);8 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits);
9 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);9 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits);
10 const srcSigBits = std.math.floatMantissaBits(src_t);10 const srcSigBits = std.math.floatMantissaBits(src_t);
11 const dstSigBits = std.math.floatMantissaBits(dst_t);11 const dstSigBits = std.math.floatMantissaBits(dst_t);
1212
...@@ -70,8 +70,8 @@ pub inline fn extendf(...@@ -70,8 +70,8 @@ pub inline fn extendf(
70 return @bitCast(result);70 return @bitCast(result);
71}71}
7272
73pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits)) f80 {73pub inline fn extend_f80(comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).float.bits)) f80 {
74 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits);74 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits);
75 const src_sig_bits = std.math.floatMantissaBits(src_t);75 const src_sig_bits = std.math.floatMantissaBits(src_t);
76 const dst_int_bit = 0x8000000000000000;76 const dst_int_bit = 0x8000000000000000;
77 const dst_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit77 const dst_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit
lib/compiler_rt/fabs.zig+2-2
...@@ -38,7 +38,7 @@ pub fn fabsq(a: f128) callconv(.C) f128 {...@@ -38,7 +38,7 @@ pub fn fabsq(a: f128) callconv(.C) f128 {
38}38}
3939
40pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble {40pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble {
41 switch (@typeInfo(c_longdouble).Float.bits) {41 switch (@typeInfo(c_longdouble).float.bits) {
42 16 => return __fabsh(x),42 16 => return __fabsh(x),
43 32 => return fabsf(x),43 32 => return fabsf(x),
44 64 => return fabs(x),44 64 => return fabs(x),
...@@ -50,7 +50,7 @@ pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble {...@@ -50,7 +50,7 @@ pub fn fabsl(x: c_longdouble) callconv(.C) c_longdouble {
5050
51inline fn generic_fabs(x: anytype) @TypeOf(x) {51inline fn generic_fabs(x: anytype) @TypeOf(x) {
52 const T = @TypeOf(x);52 const T = @TypeOf(x);
53 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);53 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
54 const float_bits: TBits = @bitCast(x);54 const float_bits: TBits = @bitCast(x);
55 const remove_sign = ~@as(TBits, 0) >> 1;55 const remove_sign = ~@as(TBits, 0) >> 1;
56 return @bitCast(float_bits & remove_sign);56 return @bitCast(float_bits & remove_sign);
lib/compiler_rt/float_from_int.zig+1-1
...@@ -18,7 +18,7 @@ pub fn floatFromInt(comptime T: type, x: anytype) T {...@@ -18,7 +18,7 @@ pub fn floatFromInt(comptime T: type, x: anytype) T {
18 const max_exp = exp_bias;18 const max_exp = exp_bias;
1919
20 // Sign20 // Sign
21 const abs_val = if (@TypeOf(x) == comptime_int or @typeInfo(@TypeOf(x)).Int.signedness == .signed) @abs(x) else x;21 const abs_val = if (@TypeOf(x) == comptime_int or @typeInfo(@TypeOf(x)).int.signedness == .signed) @abs(x) else x;
22 const sign_bit = if (x < 0) @as(uT, 1) << (float_bits - 1) else 0;22 const sign_bit = if (x < 0) @as(uT, 1) << (float_bits - 1) else 0;
23 var result: uT = sign_bit;23 var result: uT = sign_bit;
2424
lib/compiler_rt/floor.zig+1-1
...@@ -160,7 +160,7 @@ pub fn floorq(x: f128) callconv(.C) f128 {...@@ -160,7 +160,7 @@ pub fn floorq(x: f128) callconv(.C) f128 {
160}160}
161161
162pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble {162pub fn floorl(x: c_longdouble) callconv(.C) c_longdouble {
163 switch (@typeInfo(c_longdouble).Float.bits) {163 switch (@typeInfo(c_longdouble).float.bits) {
164 16 => return __floorh(x),164 16 => return __floorh(x),
165 32 => return floorf(x),165 32 => return floorf(x),
166 64 => return floor(x),166 64 => return floor(x),
lib/compiler_rt/fma.zig+1-1
...@@ -151,7 +151,7 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 {...@@ -151,7 +151,7 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.C) f128 {
151}151}
152152
153pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble {153pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.C) c_longdouble {
154 switch (@typeInfo(c_longdouble).Float.bits) {154 switch (@typeInfo(c_longdouble).float.bits) {
155 16 => return __fmah(x, y, z),155 16 => return __fmah(x, y, z),
156 32 => return fmaf(x, y, z),156 32 => return fmaf(x, y, z),
157 64 => return fma(x, y, z),157 64 => return fma(x, y, z),
lib/compiler_rt/fmax.zig+1-1
...@@ -39,7 +39,7 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 {...@@ -39,7 +39,7 @@ pub fn fmaxq(x: f128, y: f128) callconv(.C) f128 {
39}39}
4040
41pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {41pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {
42 switch (@typeInfo(c_longdouble).Float.bits) {42 switch (@typeInfo(c_longdouble).float.bits) {
43 16 => return __fmaxh(x, y),43 16 => return __fmaxh(x, y),
44 32 => return fmaxf(x, y),44 32 => return fmaxf(x, y),
45 64 => return fmax(x, y),45 64 => return fmax(x, y),
lib/compiler_rt/fmin.zig+1-1
...@@ -39,7 +39,7 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 {...@@ -39,7 +39,7 @@ pub fn fminq(x: f128, y: f128) callconv(.C) f128 {
39}39}
4040
41pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {41pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble {
42 switch (@typeInfo(c_longdouble).Float.bits) {42 switch (@typeInfo(c_longdouble).float.bits) {
43 16 => return __fminh(x, y),43 16 => return __fminh(x, y),
44 32 => return fminf(x, y),44 32 => return fminf(x, y),
45 64 => return fmin(x, y),45 64 => return fmin(x, y),
lib/compiler_rt/fmod.zig+2-2
...@@ -251,7 +251,7 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 {...@@ -251,7 +251,7 @@ pub fn fmodq(a: f128, b: f128) callconv(.C) f128 {
251}251}
252252
253pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble {253pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble {
254 switch (@typeInfo(c_longdouble).Float.bits) {254 switch (@typeInfo(c_longdouble).float.bits) {
255 16 => return __fmodh(a, b),255 16 => return __fmodh(a, b),
256 32 => return fmodf(a, b),256 32 => return fmodf(a, b),
257 64 => return fmod(a, b),257 64 => return fmod(a, b),
...@@ -262,7 +262,7 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble {...@@ -262,7 +262,7 @@ pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.C) c_longdouble {
262}262}
263263
264inline fn generic_fmod(comptime T: type, x: T, y: T) T {264inline fn generic_fmod(comptime T: type, x: T, y: T) T {
265 const bits = @typeInfo(T).Float.bits;265 const bits = @typeInfo(T).float.bits;
266 const uint = std.meta.Int(.unsigned, bits);266 const uint = std.meta.Int(.unsigned, bits);
267 comptime assert(T == f32 or T == f64);267 comptime assert(T == f32 or T == f64);
268 const digits = if (T == f32) 23 else 52;268 const digits = if (T == f32) 23 else 52;
lib/compiler_rt/int_from_float.zig+4-4
...@@ -4,8 +4,8 @@ const Log2Int = math.Log2Int;...@@ -4,8 +4,8 @@ const Log2Int = math.Log2Int;
44
5pub inline fn intFromFloat(comptime I: type, a: anytype) I {5pub inline fn intFromFloat(comptime I: type, a: anytype) I {
6 const F = @TypeOf(a);6 const F = @TypeOf(a);
7 const float_bits = @typeInfo(F).Float.bits;7 const float_bits = @typeInfo(F).float.bits;
8 const int_bits = @typeInfo(I).Int.bits;8 const int_bits = @typeInfo(I).int.bits;
9 const rep_t = Int(.unsigned, float_bits);9 const rep_t = Int(.unsigned, float_bits);
10 const sig_bits = math.floatMantissaBits(F);10 const sig_bits = math.floatMantissaBits(F);
11 const exp_bits = math.floatExponentBits(F);11 const exp_bits = math.floatExponentBits(F);
...@@ -26,7 +26,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I {...@@ -26,7 +26,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I {
26 if (exponent < 0) return 0;26 if (exponent < 0) return 0;
2727
28 // If the value is too large for the integer type, saturate.28 // If the value is too large for the integer type, saturate.
29 switch (@typeInfo(I).Int.signedness) {29 switch (@typeInfo(I).int.signedness) {
30 .unsigned => {30 .unsigned => {
31 if (negative) return 0;31 if (negative) return 0;
32 if (@as(c_uint, @intCast(exponent)) >= @min(int_bits, max_exp)) return math.maxInt(I);32 if (@as(c_uint, @intCast(exponent)) >= @min(int_bits, max_exp)) return math.maxInt(I);
...@@ -45,7 +45,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I {...@@ -45,7 +45,7 @@ pub inline fn intFromFloat(comptime I: type, a: anytype) I {
45 result = @as(I, @intCast(significand)) << @intCast(exponent - fractional_bits);45 result = @as(I, @intCast(significand)) << @intCast(exponent - fractional_bits);
46 }46 }
4747
48 if ((@typeInfo(I).Int.signedness == .signed) and negative)48 if ((@typeInfo(I).int.signedness == .signed) and negative)
49 return ~result +% 1;49 return ~result +% 1;
50 return result;50 return result;
51}51}
lib/compiler_rt/log.zig+1-1
...@@ -149,7 +149,7 @@ pub fn logq(a: f128) callconv(.C) f128 {...@@ -149,7 +149,7 @@ pub fn logq(a: f128) callconv(.C) f128 {
149}149}
150150
151pub fn logl(x: c_longdouble) callconv(.C) c_longdouble {151pub fn logl(x: c_longdouble) callconv(.C) c_longdouble {
152 switch (@typeInfo(c_longdouble).Float.bits) {152 switch (@typeInfo(c_longdouble).float.bits) {
153 16 => return __logh(x),153 16 => return __logh(x),
154 32 => return logf(x),154 32 => return logf(x),
155 64 => return log(x),155 64 => return log(x),
lib/compiler_rt/log10.zig+1-1
...@@ -177,7 +177,7 @@ pub fn log10q(a: f128) callconv(.C) f128 {...@@ -177,7 +177,7 @@ pub fn log10q(a: f128) callconv(.C) f128 {
177}177}
178178
179pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble {179pub fn log10l(x: c_longdouble) callconv(.C) c_longdouble {
180 switch (@typeInfo(c_longdouble).Float.bits) {180 switch (@typeInfo(c_longdouble).float.bits) {
181 16 => return __log10h(x),181 16 => return __log10h(x),
182 32 => return log10f(x),182 32 => return log10f(x),
183 64 => return log10(x),183 64 => return log10(x),
lib/compiler_rt/log2.zig+1-1
...@@ -169,7 +169,7 @@ pub fn log2q(a: f128) callconv(.C) f128 {...@@ -169,7 +169,7 @@ pub fn log2q(a: f128) callconv(.C) f128 {
169}169}
170170
171pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble {171pub fn log2l(x: c_longdouble) callconv(.C) c_longdouble {
172 switch (@typeInfo(c_longdouble).Float.bits) {172 switch (@typeInfo(c_longdouble).float.bits) {
173 16 => return __log2h(x),173 16 => return __log2h(x),
174 32 => return log2f(x),174 32 => return log2f(x),
175 64 => return log2(x),175 64 => return log2(x),
lib/compiler_rt/mulf3.zig+3-3
...@@ -7,7 +7,7 @@ const common = @import("./common.zig");...@@ -7,7 +7,7 @@ const common = @import("./common.zig");
7/// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/fp_mul_impl.inc7/// https://github.com/llvm/llvm-project/blob/2ffb1b0413efa9a24eb3c49e710e36f92e2cb50b/compiler-rt/lib/builtins/fp_mul_impl.inc
8pub inline fn mulf3(comptime T: type, a: T, b: T) T {8pub inline fn mulf3(comptime T: type, a: T, b: T) T {
9 @setRuntimeSafety(builtin.is_test);9 @setRuntimeSafety(builtin.is_test);
10 const typeWidth = @typeInfo(T).Float.bits;10 const typeWidth = @typeInfo(T).float.bits;
11 const significandBits = math.floatMantissaBits(T);11 const significandBits = math.floatMantissaBits(T);
12 const fractionalBits = math.floatFractionalBits(T);12 const fractionalBits = math.floatFractionalBits(T);
13 const exponentBits = math.floatExponentBits(T);13 const exponentBits = math.floatExponentBits(T);
...@@ -16,7 +16,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {...@@ -16,7 +16,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
1616
17 // ZSignificand is large enough to contain the significand, including an explicit integer bit17 // ZSignificand is large enough to contain the significand, including an explicit integer bit
18 const ZSignificand = PowerOfTwoSignificandZ(T);18 const ZSignificand = PowerOfTwoSignificandZ(T);
19 const ZSignificandBits = @typeInfo(ZSignificand).Int.bits;19 const ZSignificandBits = @typeInfo(ZSignificand).int.bits;
2020
21 const roundBit = (1 << (ZSignificandBits - 1));21 const roundBit = (1 << (ZSignificandBits - 1));
22 const signBit = (@as(Z, 1) << (significandBits + exponentBits));22 const signBit = (@as(Z, 1) << (significandBits + exponentBits));
...@@ -164,7 +164,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {...@@ -164,7 +164,7 @@ pub inline fn mulf3(comptime T: type, a: T, b: T) T {
164/// This is analogous to an shr version of `@shlWithOverflow`164/// This is analogous to an shr version of `@shlWithOverflow`
165fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {165fn wideShrWithTruncation(comptime Z: type, hi: *Z, lo: *Z, count: u32) bool {
166 @setRuntimeSafety(builtin.is_test);166 @setRuntimeSafety(builtin.is_test);
167 const typeWidth = @typeInfo(Z).Int.bits;167 const typeWidth = @typeInfo(Z).int.bits;
168 var inexact = false;168 var inexact = false;
169 if (count < typeWidth) {169 if (count < typeWidth) {
170 inexact = (lo.* << @intCast(typeWidth -% count)) != 0;170 inexact = (lo.* << @intCast(typeWidth -% count)) != 0;
lib/compiler_rt/parity.zig+1-1
...@@ -26,7 +26,7 @@ pub fn __parityti2(a: i128) callconv(.C) i32 {...@@ -26,7 +26,7 @@ pub fn __parityti2(a: i128) callconv(.C) i32 {
26}26}
2727
28inline fn parityXi2(comptime T: type, a: T) i32 {28inline fn parityXi2(comptime T: type, a: T) i32 {
29 var x: std.meta.Int(.unsigned, @typeInfo(T).Int.bits) = @bitCast(a);29 var x: std.meta.Int(.unsigned, @typeInfo(T).int.bits) = @bitCast(a);
30 // Bit Twiddling Hacks: Compute parity in parallel30 // Bit Twiddling Hacks: Compute parity in parallel
31 comptime var shift: u8 = @bitSizeOf(T) / 2;31 comptime var shift: u8 = @bitSizeOf(T) / 2;
32 inline while (shift > 2) {32 inline while (shift > 2) {
lib/compiler_rt/round.zig+1-1
...@@ -142,7 +142,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 {...@@ -142,7 +142,7 @@ pub fn roundq(x_: f128) callconv(.C) f128 {
142}142}
143143
144pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble {144pub fn roundl(x: c_longdouble) callconv(.C) c_longdouble {
145 switch (@typeInfo(c_longdouble).Float.bits) {145 switch (@typeInfo(c_longdouble).float.bits) {
146 16 => return __roundh(x),146 16 => return __roundh(x),
147 32 => return roundf(x),147 32 => return roundf(x),
148 64 => return round(x),148 64 => return round(x),
lib/compiler_rt/sin.zig+1-1
...@@ -130,7 +130,7 @@ pub fn sinq(x: f128) callconv(.C) f128 {...@@ -130,7 +130,7 @@ pub fn sinq(x: f128) callconv(.C) f128 {
130}130}
131131
132pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble {132pub fn sinl(x: c_longdouble) callconv(.C) c_longdouble {
133 switch (@typeInfo(c_longdouble).Float.bits) {133 switch (@typeInfo(c_longdouble).float.bits) {
134 16 => return __sinh(x),134 16 => return __sinh(x),
135 32 => return sinf(x),135 32 => return sinf(x),
136 64 => return sin(x),136 64 => return sin(x),
lib/compiler_rt/sincos.zig+2-2
...@@ -198,7 +198,7 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void {...@@ -198,7 +198,7 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.C) void {
198}198}
199199
200pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void {200pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.C) void {
201 switch (@typeInfo(c_longdouble).Float.bits) {201 switch (@typeInfo(c_longdouble).float.bits) {
202 16 => return __sincosh(x, r_sin, r_cos),202 16 => return __sincosh(x, r_sin, r_cos),
203 32 => return sincosf(x, r_sin, r_cos),203 32 => return sincosf(x, r_sin, r_cos),
204 64 => return sincos(x, r_sin, r_cos),204 64 => return sincos(x, r_sin, r_cos),
...@@ -216,7 +216,7 @@ pub const rem_pio2_generic = @compileError("TODO");...@@ -216,7 +216,7 @@ pub const rem_pio2_generic = @compileError("TODO");
216/// * trig.cos_generic ported from __cosl.c216/// * trig.cos_generic ported from __cosl.c
217inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void {217inline fn sincos_generic(comptime F: type, x: F, r_sin: *F, r_cos: *F) void {
218 const sc1pio4: F = 1.0 * math.pi / 4.0;218 const sc1pio4: F = 1.0 * math.pi / 4.0;
219 const bits = @typeInfo(F).Float.bits;219 const bits = @typeInfo(F).float.bits;
220 const I = std.meta.Int(.unsigned, bits);220 const I = std.meta.Int(.unsigned, bits);
221 const ix = @as(I, @bitCast(x)) & (math.maxInt(I) >> 1);221 const ix = @as(I, @bitCast(x)) & (math.maxInt(I) >> 1);
222 const se: u16 = @truncate(ix >> (bits - 16));222 const se: u16 = @truncate(ix >> (bits - 16));
lib/compiler_rt/sqrt.zig+1-1
...@@ -243,7 +243,7 @@ pub fn sqrtq(x: f128) callconv(.C) f128 {...@@ -243,7 +243,7 @@ pub fn sqrtq(x: f128) callconv(.C) f128 {
243}243}
244244
245pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble {245pub fn sqrtl(x: c_longdouble) callconv(.C) c_longdouble {
246 switch (@typeInfo(c_longdouble).Float.bits) {246 switch (@typeInfo(c_longdouble).float.bits) {
247 16 => return __sqrth(x),247 16 => return __sqrth(x),
248 32 => return sqrtf(x),248 32 => return sqrtf(x),
249 64 => return sqrt(x),249 64 => return sqrt(x),
lib/compiler_rt/tan.zig+1-1
...@@ -116,7 +116,7 @@ pub fn tanq(x: f128) callconv(.C) f128 {...@@ -116,7 +116,7 @@ pub fn tanq(x: f128) callconv(.C) f128 {
116}116}
117117
118pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble {118pub fn tanl(x: c_longdouble) callconv(.C) c_longdouble {
119 switch (@typeInfo(c_longdouble).Float.bits) {119 switch (@typeInfo(c_longdouble).float.bits) {
120 16 => return __tanh(x),120 16 => return __tanh(x),
121 32 => return tanf(x),121 32 => return tanf(x),
122 64 => return tan(x),122 64 => return tan(x),
lib/compiler_rt/trunc.zig+1-1
...@@ -100,7 +100,7 @@ pub fn truncq(x: f128) callconv(.C) f128 {...@@ -100,7 +100,7 @@ pub fn truncq(x: f128) callconv(.C) f128 {
100}100}
101101
102pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble {102pub fn truncl(x: c_longdouble) callconv(.C) c_longdouble {
103 switch (@typeInfo(c_longdouble).Float.bits) {103 switch (@typeInfo(c_longdouble).float.bits) {
104 16 => return __trunch(x),104 16 => return __trunch(x),
105 32 => return truncf(x),105 32 => return truncf(x),
106 64 => return trunc(x),106 64 => return trunc(x),
lib/compiler_rt/truncf.zig+6-6
...@@ -1,14 +1,14 @@...@@ -1,14 +1,14 @@
1const std = @import("std");1const std = @import("std");
22
3pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {3pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
4 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits);4 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).float.bits);
5 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);5 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits);
6 const srcSigBits = std.math.floatMantissaBits(src_t);6 const srcSigBits = std.math.floatMantissaBits(src_t);
7 const dstSigBits = std.math.floatMantissaBits(dst_t);7 const dstSigBits = std.math.floatMantissaBits(dst_t);
88
9 // Various constants whose values follow from the type parameters.9 // Various constants whose values follow from the type parameters.
10 // Any reasonable optimizer will fold and propagate all of these.10 // Any reasonable optimizer will fold and propagate all of these.
11 const srcBits = @typeInfo(src_t).Float.bits;11 const srcBits = @typeInfo(src_t).float.bits;
12 const srcExpBits = srcBits - srcSigBits - 1;12 const srcExpBits = srcBits - srcSigBits - 1;
13 const srcInfExp = (1 << srcExpBits) - 1;13 const srcInfExp = (1 << srcExpBits) - 1;
14 const srcExpBias = srcInfExp >> 1;14 const srcExpBias = srcInfExp >> 1;
...@@ -23,7 +23,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t...@@ -23,7 +23,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
23 const srcQNaN = 1 << (srcSigBits - 1);23 const srcQNaN = 1 << (srcSigBits - 1);
24 const srcNaNCode = srcQNaN - 1;24 const srcNaNCode = srcQNaN - 1;
2525
26 const dstBits = @typeInfo(dst_t).Float.bits;26 const dstBits = @typeInfo(dst_t).float.bits;
27 const dstExpBits = dstBits - dstSigBits - 1;27 const dstExpBits = dstBits - dstSigBits - 1;
28 const dstInfExp = (1 << dstExpBits) - 1;28 const dstInfExp = (1 << dstExpBits) - 1;
29 const dstExpBias = dstInfExp >> 1;29 const dstExpBias = dstInfExp >> 1;
...@@ -100,7 +100,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t...@@ -100,7 +100,7 @@ pub inline fn truncf(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t
100}100}
101101
102pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {102pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
103 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);103 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).float.bits);
104 const src_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit104 const src_sig_bits = std.math.floatMantissaBits(f80) - 1; // -1 for the integer bit
105 const dst_sig_bits = std.math.floatMantissaBits(dst_t);105 const dst_sig_bits = std.math.floatMantissaBits(dst_t);
106106
...@@ -109,7 +109,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {...@@ -109,7 +109,7 @@ pub inline fn trunc_f80(comptime dst_t: type, a: f80) dst_t {
109 const round_mask = (1 << (src_sig_bits - dst_sig_bits)) - 1;109 const round_mask = (1 << (src_sig_bits - dst_sig_bits)) - 1;
110 const halfway = 1 << (src_sig_bits - dst_sig_bits - 1);110 const halfway = 1 << (src_sig_bits - dst_sig_bits - 1);
111111
112 const dst_bits = @typeInfo(dst_t).Float.bits;112 const dst_bits = @typeInfo(dst_t).float.bits;
113 const dst_exp_bits = dst_bits - dst_sig_bits - 1;113 const dst_exp_bits = dst_bits - dst_sig_bits - 1;
114 const dst_inf_exp = (1 << dst_exp_bits) - 1;114 const dst_inf_exp = (1 << dst_exp_bits) - 1;
115 const dst_exp_bias = dst_inf_exp >> 1;115 const dst_exp_bias = dst_inf_exp >> 1;
lib/compiler_rt/trunctfxf2.zig+1-1
...@@ -14,7 +14,7 @@ pub fn __trunctfxf2(a: f128) callconv(.C) f80 {...@@ -14,7 +14,7 @@ pub fn __trunctfxf2(a: f128) callconv(.C) f80 {
1414
15 // Various constants whose values follow from the type parameters.15 // Various constants whose values follow from the type parameters.
16 // Any reasonable optimizer will fold and propagate all of these.16 // Any reasonable optimizer will fold and propagate all of these.
17 const src_bits = @typeInfo(f128).Float.bits;17 const src_bits = @typeInfo(f128).float.bits;
18 const src_exp_bits = src_bits - src_sig_bits - 1;18 const src_exp_bits = src_bits - src_sig_bits - 1;
19 const src_inf_exp = 0x7FFF;19 const src_inf_exp = 0x7FFF;
2020
lib/docs/wasm/Walk.zig+1-1
...@@ -36,7 +36,7 @@ pub const Category = union(enum(u8)) {...@@ -36,7 +36,7 @@ pub const Category = union(enum(u8)) {
36 /// A function that returns a type.36 /// A function that returns a type.
37 type_function: Ast.Node.Index,37 type_function: Ast.Node.Index,
3838
39 pub const Tag = @typeInfo(Category).Union.tag_type.?;39 pub const Tag = @typeInfo(Category).@"union".tag_type.?;
40};40};
4141
42pub const File = struct {42pub const File = struct {
lib/docs/wasm/markdown/Document.zig+1-1
...@@ -170,7 +170,7 @@ pub fn ExtraData(comptime T: type) type {...@@ -170,7 +170,7 @@ pub fn ExtraData(comptime T: type) type {
170}170}
171171
172pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T) {172pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T) {
173 const fields = @typeInfo(T).Struct.fields;173 const fields = @typeInfo(T).@"struct".fields;
174 var i: usize = @intFromEnum(index);174 var i: usize = @intFromEnum(index);
175 var result: T = undefined;175 var result: T = undefined;
176 inline for (fields) |field| {176 inline for (fields) |field| {
lib/docs/wasm/markdown/Parser.zig+1-1
...@@ -1564,7 +1564,7 @@ fn parseInlines(p: *Parser, content: []const u8) !ExtraIndex {...@@ -1564,7 +1564,7 @@ fn parseInlines(p: *Parser, content: []const u8) !ExtraIndex {
1564}1564}
15651565
1566pub fn extraData(p: Parser, comptime T: type, index: ExtraIndex) ExtraData(T) {1566pub fn extraData(p: Parser, comptime T: type, index: ExtraIndex) ExtraData(T) {
1567 const fields = @typeInfo(T).Struct.fields;1567 const fields = @typeInfo(T).@"struct".fields;
1568 var i: usize = @intFromEnum(index);1568 var i: usize = @intFromEnum(index);
1569 var result: T = undefined;1569 var result: T = undefined;
1570 inline for (fields) |field| {1570 inline for (fields) |field| {
lib/fuzzer.zig+2-2
...@@ -13,7 +13,7 @@ var log_file: ?std.fs.File = null;...@@ -13,7 +13,7 @@ var log_file: ?std.fs.File = null;
1313
14fn logOverride(14fn logOverride(
15 comptime level: std.log.Level,15 comptime level: std.log.Level,
16 comptime scope: @TypeOf(.EnumLiteral),16 comptime scope: @Type(.enum_literal),
17 comptime format: []const u8,17 comptime format: []const u8,
18 args: anytype,18 args: anytype,
19) void {19) void {
...@@ -178,7 +178,7 @@ const Fuzzer = struct {...@@ -178,7 +178,7 @@ const Fuzzer = struct {
178 addr: usize,178 addr: usize,
179 flags: packed struct(usize) {179 flags: packed struct(usize) {
180 entry: bool,180 entry: bool,
181 _: @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(usize) - 1 } }),181 _: @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(usize) - 1 } }),
182 },182 },
183 };183 };
184184
lib/std/Build.zig+23-23
...@@ -408,7 +408,7 @@ fn createChildOnly(...@@ -408,7 +408,7 @@ fn createChildOnly(
408408
409fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOptionsMap {409fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOptionsMap {
410 var user_input_options = UserInputOptionsMap.init(allocator);410 var user_input_options = UserInputOptionsMap.init(allocator);
411 inline for (@typeInfo(@TypeOf(args)).Struct.fields) |field| {411 inline for (@typeInfo(@TypeOf(args)).@"struct".fields) |field| {
412 const v = @field(args, field.name);412 const v = @field(args, field.name);
413 const T = @TypeOf(v);413 const T = @TypeOf(v);
414 switch (T) {414 switch (T) {
...@@ -454,28 +454,28 @@ fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOption...@@ -454,28 +454,28 @@ fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOption
454 }) catch @panic("OOM");454 }) catch @panic("OOM");
455 },455 },
456 else => switch (@typeInfo(T)) {456 else => switch (@typeInfo(T)) {
457 .Bool => {457 .bool => {
458 user_input_options.put(field.name, .{458 user_input_options.put(field.name, .{
459 .name = field.name,459 .name = field.name,
460 .value = .{ .scalar = if (v) "true" else "false" },460 .value = .{ .scalar = if (v) "true" else "false" },
461 .used = false,461 .used = false,
462 }) catch @panic("OOM");462 }) catch @panic("OOM");
463 },463 },
464 .Enum, .EnumLiteral => {464 .@"enum", .enum_literal => {
465 user_input_options.put(field.name, .{465 user_input_options.put(field.name, .{
466 .name = field.name,466 .name = field.name,
467 .value = .{ .scalar = @tagName(v) },467 .value = .{ .scalar = @tagName(v) },
468 .used = false,468 .used = false,
469 }) catch @panic("OOM");469 }) catch @panic("OOM");
470 },470 },
471 .ComptimeInt, .Int => {471 .comptime_int, .int => {
472 user_input_options.put(field.name, .{472 user_input_options.put(field.name, .{
473 .name = field.name,473 .name = field.name,
474 .value = .{ .scalar = std.fmt.allocPrint(allocator, "{d}", .{v}) catch @panic("OOM") },474 .value = .{ .scalar = std.fmt.allocPrint(allocator, "{d}", .{v}) catch @panic("OOM") },
475 .used = false,475 .used = false,
476 }) catch @panic("OOM");476 }) catch @panic("OOM");
477 },477 },
478 .ComptimeFloat, .Float => {478 .comptime_float, .float => {
479 user_input_options.put(field.name, .{479 user_input_options.put(field.name, .{
480 .name = field.name,480 .name = field.name,
481 .value = .{ .scalar = std.fmt.allocPrint(allocator, "{e}", .{v}) catch @panic("OOM") },481 .value = .{ .scalar = std.fmt.allocPrint(allocator, "{e}", .{v}) catch @panic("OOM") },
...@@ -1111,7 +1111,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw...@@ -1111,7 +1111,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
1111 const description = b.dupe(description_raw);1111 const description = b.dupe(description_raw);
1112 const type_id = comptime typeToEnum(T);1112 const type_id = comptime typeToEnum(T);
1113 const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: {1113 const enum_options = if (type_id == .@"enum" or type_id == .enum_list) blk: {
1114 const EnumType = if (type_id == .enum_list) @typeInfo(T).Pointer.child else T;1114 const EnumType = if (type_id == .enum_list) @typeInfo(T).pointer.child else T;
1115 const fields = comptime std.meta.fields(EnumType);1115 const fields = comptime std.meta.fields(EnumType);
1116 var options = ArrayList([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM");1116 var options = ArrayList([]const u8).initCapacity(b.allocator, fields.len) catch @panic("OOM");
11171117
...@@ -1265,7 +1265,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw...@@ -1265,7 +1265,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
1265 return null;1265 return null;
1266 },1266 },
1267 .scalar => |s| {1267 .scalar => |s| {
1268 const Child = @typeInfo(T).Pointer.child;1268 const Child = @typeInfo(T).pointer.child;
1269 const value = std.meta.stringToEnum(Child, s) orelse {1269 const value = std.meta.stringToEnum(Child, s) orelse {
1270 log.err("Expected -D{s} to be of type {s}.", .{ name, @typeName(Child) });1270 log.err("Expected -D{s} to be of type {s}.", .{ name, @typeName(Child) });
1271 b.markInvalidUserInput();1271 b.markInvalidUserInput();
...@@ -1274,7 +1274,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw...@@ -1274,7 +1274,7 @@ pub fn option(b: *Build, comptime T: type, name_raw: []const u8, description_raw
1274 return b.allocator.dupe(Child, &[_]Child{value}) catch @panic("OOM");1274 return b.allocator.dupe(Child, &[_]Child{value}) catch @panic("OOM");
1275 },1275 },
1276 .list => |lst| {1276 .list => |lst| {
1277 const Child = @typeInfo(T).Pointer.child;1277 const Child = @typeInfo(T).pointer.child;
1278 var new_list = b.allocator.alloc(Child, lst.items.len) catch @panic("OOM");1278 var new_list = b.allocator.alloc(Child, lst.items.len) catch @panic("OOM");
1279 for (lst.items, 0..) |str, i| {1279 for (lst.items, 0..) |str, i| {
1280 const value = std.meta.stringToEnum(Child, str) orelse {1280 const value = std.meta.stringToEnum(Child, str) orelse {
...@@ -1542,15 +1542,15 @@ fn typeToEnum(comptime T: type) TypeId {...@@ -1542,15 +1542,15 @@ fn typeToEnum(comptime T: type) TypeId {
1542 return switch (T) {1542 return switch (T) {
1543 std.zig.BuildId => .build_id,1543 std.zig.BuildId => .build_id,
1544 else => return switch (@typeInfo(T)) {1544 else => return switch (@typeInfo(T)) {
1545 .Int => .int,1545 .int => .int,
1546 .Float => .float,1546 .float => .float,
1547 .Bool => .bool,1547 .bool => .bool,
1548 .Enum => .@"enum",1548 .@"enum" => .@"enum",
1549 .Pointer => |pointer| switch (pointer.child) {1549 .pointer => |pointer| switch (pointer.child) {
1550 u8 => .string,1550 u8 => .string,
1551 []const u8 => .list,1551 []const u8 => .list,
1552 else => switch (@typeInfo(pointer.child)) {1552 else => switch (@typeInfo(pointer.child)) {
1553 .Enum => .enum_list,1553 .@"enum" => .enum_list,
1554 else => @compileError("Unsupported type: " ++ @typeName(T)),1554 else => @compileError("Unsupported type: " ++ @typeName(T)),
1555 },1555 },
1556 },1556 },
...@@ -1726,7 +1726,7 @@ pub fn fmt(b: *Build, comptime format: []const u8, args: anytype) []u8 {...@@ -1726,7 +1726,7 @@ pub fn fmt(b: *Build, comptime format: []const u8, args: anytype) []u8 {
1726}1726}
17271727
1728fn supportedWindowsProgramExtension(ext: []const u8) bool {1728fn supportedWindowsProgramExtension(ext: []const u8) bool {
1729 inline for (@typeInfo(std.process.Child.WindowsExtension).Enum.fields) |field| {1729 inline for (@typeInfo(std.process.Child.WindowsExtension).@"enum".fields) |field| {
1730 if (std.ascii.eqlIgnoreCase(ext, "." ++ field.name)) return true;1730 if (std.ascii.eqlIgnoreCase(ext, "." ++ field.name)) return true;
1731 }1731 }
1732 return false;1732 return false;
...@@ -1925,7 +1925,7 @@ inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, c...@@ -1925,7 +1925,7 @@ inline fn findImportPkgHashOrFatal(b: *Build, comptime asking_build_zig: type, c
1925 const build_runner = @import("root");1925 const build_runner = @import("root");
1926 const deps = build_runner.dependencies;1926 const deps = build_runner.dependencies;
19271927
1928 const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).Struct.decls) |decl| {1928 const b_pkg_hash, const b_pkg_deps = comptime for (@typeInfo(deps.packages).@"struct".decls) |decl| {
1929 const pkg_hash = decl.name;1929 const pkg_hash = decl.name;
1930 const pkg = @field(deps.packages, pkg_hash);1930 const pkg = @field(deps.packages, pkg_hash);
1931 if (@hasDecl(pkg, "build_zig") and pkg.build_zig == asking_build_zig) break .{ pkg_hash, pkg.deps };1931 if (@hasDecl(pkg, "build_zig") and pkg.build_zig == asking_build_zig) break .{ pkg_hash, pkg.deps };
...@@ -1963,7 +1963,7 @@ pub fn lazyDependency(b: *Build, name: []const u8, args: anytype) ?*Dependency {...@@ -1963,7 +1963,7 @@ pub fn lazyDependency(b: *Build, name: []const u8, args: anytype) ?*Dependency {
1963 const deps = build_runner.dependencies;1963 const deps = build_runner.dependencies;
1964 const pkg_hash = findPkgHashOrFatal(b, name);1964 const pkg_hash = findPkgHashOrFatal(b, name);
19651965
1966 inline for (@typeInfo(deps.packages).Struct.decls) |decl| {1966 inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
1967 if (mem.eql(u8, decl.name, pkg_hash)) {1967 if (mem.eql(u8, decl.name, pkg_hash)) {
1968 const pkg = @field(deps.packages, decl.name);1968 const pkg = @field(deps.packages, decl.name);
1969 const available = !@hasDecl(pkg, "available") or pkg.available;1969 const available = !@hasDecl(pkg, "available") or pkg.available;
...@@ -1983,7 +1983,7 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency {...@@ -1983,7 +1983,7 @@ pub fn dependency(b: *Build, name: []const u8, args: anytype) *Dependency {
1983 const deps = build_runner.dependencies;1983 const deps = build_runner.dependencies;
1984 const pkg_hash = findPkgHashOrFatal(b, name);1984 const pkg_hash = findPkgHashOrFatal(b, name);
19851985
1986 inline for (@typeInfo(deps.packages).Struct.decls) |decl| {1986 inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
1987 if (mem.eql(u8, decl.name, pkg_hash)) {1987 if (mem.eql(u8, decl.name, pkg_hash)) {
1988 const pkg = @field(deps.packages, decl.name);1988 const pkg = @field(deps.packages, decl.name);
1989 if (@hasDecl(pkg, "available")) {1989 if (@hasDecl(pkg, "available")) {
...@@ -2013,7 +2013,7 @@ pub inline fn lazyImport(...@@ -2013,7 +2013,7 @@ pub inline fn lazyImport(
2013 const deps = build_runner.dependencies;2013 const deps = build_runner.dependencies;
2014 const pkg_hash = findImportPkgHashOrFatal(b, asking_build_zig, dep_name);2014 const pkg_hash = findImportPkgHashOrFatal(b, asking_build_zig, dep_name);
20152015
2016 inline for (@typeInfo(deps.packages).Struct.decls) |decl| {2016 inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
2017 if (comptime mem.eql(u8, decl.name, pkg_hash)) {2017 if (comptime mem.eql(u8, decl.name, pkg_hash)) {
2018 const pkg = @field(deps.packages, decl.name);2018 const pkg = @field(deps.packages, decl.name);
2019 const available = !@hasDecl(pkg, "available") or pkg.available;2019 const available = !@hasDecl(pkg, "available") or pkg.available;
...@@ -2042,7 +2042,7 @@ pub fn dependencyFromBuildZig(...@@ -2042,7 +2042,7 @@ pub fn dependencyFromBuildZig(
2042 const deps = build_runner.dependencies;2042 const deps = build_runner.dependencies;
20432043
2044 find_dep: {2044 find_dep: {
2045 const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).Struct.decls) |decl| {2045 const pkg, const pkg_hash = inline for (@typeInfo(deps.packages).@"struct".decls) |decl| {
2046 const pkg_hash = decl.name;2046 const pkg_hash = decl.name;
2047 const pkg = @field(deps.packages, pkg_hash);2047 const pkg = @field(deps.packages, pkg_hash);
2048 if (@hasDecl(pkg, "build_zig") and pkg.build_zig == build_zig) break .{ pkg, pkg_hash };2048 if (@hasDecl(pkg, "build_zig") and pkg.build_zig == build_zig) break .{ pkg, pkg_hash };
...@@ -2150,9 +2150,9 @@ fn dependencyInner(...@@ -2150,9 +2150,9 @@ fn dependencyInner(
2150}2150}
21512151
2152pub fn runBuild(b: *Build, build_zig: anytype) anyerror!void {2152pub fn runBuild(b: *Build, build_zig: anytype) anyerror!void {
2153 switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).Fn.return_type.?)) {2153 switch (@typeInfo(@typeInfo(@TypeOf(build_zig.build)).@"fn".return_type.?)) {
2154 .Void => build_zig.build(b),2154 .void => build_zig.build(b),
2155 .ErrorUnion => try build_zig.build(b),2155 .error_union => try build_zig.build(b),
2156 else => @compileError("expected return type of build to be 'void' or '!void'"),2156 else => @compileError("expected return type of build to be 'void' or '!void'"),
2157 }2157 }
2158}2158}
lib/std/Build/Cache.zig+3-3
...@@ -222,7 +222,7 @@ pub const HashHelper = struct {...@@ -222,7 +222,7 @@ pub const HashHelper = struct {
222 .hexstring => |hex_string| hh.addBytes(hex_string.toSlice()),222 .hexstring => |hex_string| hh.addBytes(hex_string.toSlice()),
223 },223 },
224 else => switch (@typeInfo(@TypeOf(x))) {224 else => switch (@typeInfo(@TypeOf(x))) {
225 .Bool, .Int, .Enum, .Array => hh.addBytes(mem.asBytes(&x)),225 .bool, .int, .@"enum", .array => hh.addBytes(mem.asBytes(&x)),
226 else => @compileError("unable to hash type " ++ @typeName(@TypeOf(x))),226 else => @compileError("unable to hash type " ++ @typeName(@TypeOf(x))),
227 },227 },
228 }228 }
...@@ -1014,7 +1014,7 @@ pub const Manifest = struct {...@@ -1014,7 +1014,7 @@ pub const Manifest = struct {
1014 }1014 }
10151015
1016 pub fn populateFileSystemInputs(man: *Manifest, buf: *std.ArrayListUnmanaged(u8)) Allocator.Error!void {1016 pub fn populateFileSystemInputs(man: *Manifest, buf: *std.ArrayListUnmanaged(u8)) Allocator.Error!void {
1017 assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len);1017 assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len);
1018 buf.clearRetainingCapacity();1018 buf.clearRetainingCapacity();
1019 const gpa = man.cache.gpa;1019 const gpa = man.cache.gpa;
1020 const files = man.files.keys();1020 const files = man.files.keys();
...@@ -1032,7 +1032,7 @@ pub const Manifest = struct {...@@ -1032,7 +1032,7 @@ pub const Manifest = struct {
10321032
1033 pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void {1033 pub fn populateOtherManifest(man: *Manifest, other: *Manifest, prefix_map: [4]u8) Allocator.Error!void {
1034 const gpa = other.cache.gpa;1034 const gpa = other.cache.gpa;
1035 assert(@typeInfo(std.zig.Server.Message.PathPrefix).Enum.fields.len == man.cache.prefixes_len);1035 assert(@typeInfo(std.zig.Server.Message.PathPrefix).@"enum".fields.len == man.cache.prefixes_len);
1036 assert(man.cache.prefixes_len == 4);1036 assert(man.cache.prefixes_len == 4);
1037 for (man.files.keys()) |file| {1037 for (man.files.keys()) |file| {
1038 const prefixed_path: PrefixedPath = .{1038 const prefixed_path: PrefixedPath = .{
lib/std/Build/Cache/Path.zig+2-2
...@@ -189,8 +189,8 @@ pub const TableAdapter = struct {...@@ -189,8 +189,8 @@ pub const TableAdapter = struct {
189 pub fn hash(self: TableAdapter, a: Cache.Path) u32 {189 pub fn hash(self: TableAdapter, a: Cache.Path) u32 {
190 _ = self;190 _ = self;
191 const seed = switch (@typeInfo(@TypeOf(a.root_dir.handle.fd))) {191 const seed = switch (@typeInfo(@TypeOf(a.root_dir.handle.fd))) {
192 .Pointer => @intFromPtr(a.root_dir.handle.fd),192 .pointer => @intFromPtr(a.root_dir.handle.fd),
193 .Int => @as(u32, @bitCast(a.root_dir.handle.fd)),193 .int => @as(u32, @bitCast(a.root_dir.handle.fd)),
194 else => @compileError("unimplemented hash function"),194 else => @compileError("unimplemented hash function"),
195 };195 };
196 return @truncate(Hash.hash(seed, a.sub_path));196 return @truncate(Hash.hash(seed, a.sub_path));
lib/std/Build/Step/ConfigHeader.zig+11-11
...@@ -109,47 +109,47 @@ pub fn getOutput(config_header: *ConfigHeader) std.Build.LazyPath {...@@ -109,47 +109,47 @@ pub fn getOutput(config_header: *ConfigHeader) std.Build.LazyPath {
109}109}
110110
111fn addValuesInner(config_header: *ConfigHeader, values: anytype) !void {111fn addValuesInner(config_header: *ConfigHeader, values: anytype) !void {
112 inline for (@typeInfo(@TypeOf(values)).Struct.fields) |field| {112 inline for (@typeInfo(@TypeOf(values)).@"struct".fields) |field| {
113 try putValue(config_header, field.name, field.type, @field(values, field.name));113 try putValue(config_header, field.name, field.type, @field(values, field.name));
114 }114 }
115}115}
116116
117fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: type, v: T) !void {117fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: type, v: T) !void {
118 switch (@typeInfo(T)) {118 switch (@typeInfo(T)) {
119 .Null => {119 .null => {
120 try config_header.values.put(field_name, .undef);120 try config_header.values.put(field_name, .undef);
121 },121 },
122 .Void => {122 .void => {
123 try config_header.values.put(field_name, .defined);123 try config_header.values.put(field_name, .defined);
124 },124 },
125 .Bool => {125 .bool => {
126 try config_header.values.put(field_name, .{ .boolean = v });126 try config_header.values.put(field_name, .{ .boolean = v });
127 },127 },
128 .Int => {128 .int => {
129 try config_header.values.put(field_name, .{ .int = v });129 try config_header.values.put(field_name, .{ .int = v });
130 },130 },
131 .ComptimeInt => {131 .comptime_int => {
132 try config_header.values.put(field_name, .{ .int = v });132 try config_header.values.put(field_name, .{ .int = v });
133 },133 },
134 .EnumLiteral => {134 .enum_literal => {
135 try config_header.values.put(field_name, .{ .ident = @tagName(v) });135 try config_header.values.put(field_name, .{ .ident = @tagName(v) });
136 },136 },
137 .Optional => {137 .optional => {
138 if (v) |x| {138 if (v) |x| {
139 return putValue(config_header, field_name, @TypeOf(x), x);139 return putValue(config_header, field_name, @TypeOf(x), x);
140 } else {140 } else {
141 try config_header.values.put(field_name, .undef);141 try config_header.values.put(field_name, .undef);
142 }142 }
143 },143 },
144 .Pointer => |ptr| {144 .pointer => |ptr| {
145 switch (@typeInfo(ptr.child)) {145 switch (@typeInfo(ptr.child)) {
146 .Array => |array| {146 .array => |array| {
147 if (ptr.size == .One and array.child == u8) {147 if (ptr.size == .One and array.child == u8) {
148 try config_header.values.put(field_name, .{ .string = v });148 try config_header.values.put(field_name, .{ .string = v });
149 return;149 return;
150 }150 }
151 },151 },
152 .Int => {152 .int => {
153 if (ptr.size == .Slice and ptr.child == u8) {153 if (ptr.size == .Slice and ptr.child == u8) {
154 try config_header.values.put(field_name, .{ .string = v });154 try config_header.values.put(field_name, .{ .string = v });
155 return;155 return;
lib/std/Build/Step/Options.zig+17-17
...@@ -151,7 +151,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -151,7 +151,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
151 }151 }
152152
153 switch (@typeInfo(T)) {153 switch (@typeInfo(T)) {
154 .Array => {154 .array => {
155 if (name) |some| {155 if (name) |some| {
156 try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });156 try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });
157 }157 }
...@@ -171,7 +171,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -171,7 +171,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
171 }171 }
172 return;172 return;
173 },173 },
174 .Pointer => |p| {174 .pointer => |p| {
175 if (p.size != .Slice) {175 if (p.size != .Slice) {
176 @compileError("Non-slice pointers are not yet supported in build options");176 @compileError("Non-slice pointers are not yet supported in build options");
177 }177 }
...@@ -195,7 +195,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -195,7 +195,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
195 }195 }
196 return;196 return;
197 },197 },
198 .Optional => {198 .optional => {
199 if (name) |some| {199 if (name) |some| {
200 try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });200 try out.print("pub const {}: {s} = ", .{ std.zig.fmtId(some), @typeName(T) });
201 }201 }
...@@ -216,12 +216,12 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -216,12 +216,12 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
216 }216 }
217 return;217 return;
218 },218 },
219 .Void,219 .void,
220 .Bool,220 .bool,
221 .Int,221 .int,
222 .ComptimeInt,222 .comptime_int,
223 .Float,223 .float,
224 .Null,224 .null,
225 => {225 => {
226 if (name) |some| {226 if (name) |some| {
227 try out.print("pub const {}: {s} = {any};\n", .{ std.zig.fmtId(some), @typeName(T), value });227 try out.print("pub const {}: {s} = {any};\n", .{ std.zig.fmtId(some), @typeName(T), value });
...@@ -230,7 +230,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -230,7 +230,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
230 }230 }
231 return;231 return;
232 },232 },
233 .Enum => |info| {233 .@"enum" => |info| {
234 try printEnum(options, out, T, info, indent);234 try printEnum(options, out, T, info, indent);
235235
236 if (name) |some| {236 if (name) |some| {
...@@ -242,7 +242,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -242,7 +242,7 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
242 }242 }
243 return;243 return;
244 },244 },
245 .Struct => |info| {245 .@"struct" => |info| {
246 try printStruct(options, out, T, info, indent);246 try printStruct(options, out, T, info, indent);
247247
248 if (name) |some| {248 if (name) |some| {
...@@ -260,10 +260,10 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent...@@ -260,10 +260,10 @@ fn printType(options: *Options, out: anytype, comptime T: type, value: T, indent
260260
261fn printUserDefinedType(options: *Options, out: anytype, comptime T: type, indent: u8) !void {261fn printUserDefinedType(options: *Options, out: anytype, comptime T: type, indent: u8) !void {
262 switch (@typeInfo(T)) {262 switch (@typeInfo(T)) {
263 .Enum => |info| {263 .@"enum" => |info| {
264 return try printEnum(options, out, T, info, indent);264 return try printEnum(options, out, T, info, indent);
265 },265 },
266 .Struct => |info| {266 .@"struct" => |info| {
267 return try printStruct(options, out, T, info, indent);267 return try printStruct(options, out, T, info, indent);
268 },268 },
269 else => {},269 else => {},
...@@ -323,8 +323,8 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val:...@@ -323,8 +323,8 @@ fn printStruct(options: *Options, out: anytype, comptime T: type, comptime val:
323323
324 try out.writeAll(" = ");324 try out.writeAll(" = ");
325 switch (@typeInfo(@TypeOf(default_value))) {325 switch (@typeInfo(@TypeOf(default_value))) {
326 .Enum => try out.print(".{s},\n", .{@tagName(default_value)}),326 .@"enum" => try out.print(".{s},\n", .{@tagName(default_value)}),
327 .Struct => |info| {327 .@"struct" => |info| {
328 try printStructValue(options, out, info, default_value, indent + 4);328 try printStructValue(options, out, info, default_value, indent + 4);
329 },329 },
330 else => try printType(options, out, @TypeOf(default_value), default_value, indent, null),330 else => try printType(options, out, @TypeOf(default_value), default_value, indent, null),
...@@ -359,8 +359,8 @@ fn printStructValue(options: *Options, out: anytype, comptime struct_val: std.bu...@@ -359,8 +359,8 @@ fn printStructValue(options: *Options, out: anytype, comptime struct_val: std.bu
359359
360 const field_name = @field(val, field.name);360 const field_name = @field(val, field.name);
361 switch (@typeInfo(@TypeOf(field_name))) {361 switch (@typeInfo(@TypeOf(field_name))) {
362 .Enum => try out.print(".{s},\n", .{@tagName(field_name)}),362 .@"enum" => try out.print(".{s},\n", .{@tagName(field_name)}),
363 .Struct => |struct_info| {363 .@"struct" => |struct_info| {
364 try printStructValue(options, out, struct_info, field_name, indent + 4);364 try printStructValue(options, out, struct_info, field_name, indent + 4);
365 },365 },
366 else => try printType(options, out, @TypeOf(field_name), field_name, indent, null),366 else => try printType(options, out, @TypeOf(field_name), field_name, indent, null),
lib/std/Build/Step/Run.zig+1-1
...@@ -614,7 +614,7 @@ fn checksContainStderr(checks: []const StdIo.Check) bool {...@@ -614,7 +614,7 @@ fn checksContainStderr(checks: []const StdIo.Check) bool {
614614
615const IndexedOutput = struct {615const IndexedOutput = struct {
616 index: usize,616 index: usize,
617 tag: @typeInfo(Arg).Union.tag_type.?,617 tag: @typeInfo(Arg).@"union".tag_type.?,
618 output: *Output,618 output: *Output,
619};619};
620fn make(step: *Step, options: Step.MakeOptions) !void {620fn make(step: *Step, options: Step.MakeOptions) !void {
lib/std/Progress.zig+9-9
...@@ -95,8 +95,8 @@ pub const Node = struct {...@@ -95,8 +95,8 @@ pub const Node = struct {
95 /// Not thread-safe.95 /// Not thread-safe.
96 fn getIpcFd(s: Storage) ?posix.fd_t {96 fn getIpcFd(s: Storage) ?posix.fd_t {
97 return if (s.estimated_total_count == std.math.maxInt(u32)) switch (@typeInfo(posix.fd_t)) {97 return if (s.estimated_total_count == std.math.maxInt(u32)) switch (@typeInfo(posix.fd_t)) {
98 .Int => @bitCast(s.completed_count),98 .int => @bitCast(s.completed_count),
99 .Pointer => @ptrFromInt(s.completed_count),99 .pointer => @ptrFromInt(s.completed_count),
100 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),100 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
101 } else null;101 } else null;
102 }102 }
...@@ -104,8 +104,8 @@ pub const Node = struct {...@@ -104,8 +104,8 @@ pub const Node = struct {
104 /// Thread-safe.104 /// Thread-safe.
105 fn setIpcFd(s: *Storage, fd: posix.fd_t) void {105 fn setIpcFd(s: *Storage, fd: posix.fd_t) void {
106 const integer: u32 = switch (@typeInfo(posix.fd_t)) {106 const integer: u32 = switch (@typeInfo(posix.fd_t)) {
107 .Int => @bitCast(fd),107 .int => @bitCast(fd),
108 .Pointer => @intFromPtr(fd),108 .pointer => @intFromPtr(fd),
109 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),109 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
110 };110 };
111 // `estimated_total_count` max int indicates the special state that111 // `estimated_total_count` max int indicates the special state that
...@@ -276,8 +276,8 @@ pub const Node = struct {...@@ -276,8 +276,8 @@ pub const Node = struct {
276 const storage = storageByIndex(index);276 const storage = storageByIndex(index);
277 const int = @atomicLoad(u32, &storage.completed_count, .monotonic);277 const int = @atomicLoad(u32, &storage.completed_count, .monotonic);
278 return switch (@typeInfo(posix.fd_t)) {278 return switch (@typeInfo(posix.fd_t)) {
279 .Int => @bitCast(int),279 .int => @bitCast(int),
280 .Pointer => @ptrFromInt(int),280 .pointer => @ptrFromInt(int),
281 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),281 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
282 };282 };
283 }283 }
...@@ -381,8 +381,8 @@ pub fn start(options: Options) Node {...@@ -381,8 +381,8 @@ pub fn start(options: Options) Node {
381 if (std.process.parseEnvVarInt("ZIG_PROGRESS", u31, 10)) |ipc_fd| {381 if (std.process.parseEnvVarInt("ZIG_PROGRESS", u31, 10)) |ipc_fd| {
382 global_progress.update_thread = std.Thread.spawn(.{}, ipcThreadRun, .{382 global_progress.update_thread = std.Thread.spawn(.{}, ipcThreadRun, .{
383 @as(posix.fd_t, switch (@typeInfo(posix.fd_t)) {383 @as(posix.fd_t, switch (@typeInfo(posix.fd_t)) {
384 .Int => ipc_fd,384 .int => ipc_fd,
385 .Pointer => @ptrFromInt(ipc_fd),385 .pointer => @ptrFromInt(ipc_fd),
386 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),386 else => @compileError("unsupported fd_t of " ++ @typeName(posix.fd_t)),
387 }),387 }),
388 }) catch |err| {388 }) catch |err| {
...@@ -633,7 +633,7 @@ const TreeSymbol = enum {...@@ -633,7 +633,7 @@ const TreeSymbol = enum {
633633
634 fn maxByteLen(symbol: TreeSymbol) usize {634 fn maxByteLen(symbol: TreeSymbol) usize {
635 var max: usize = 0;635 var max: usize = 0;
636 inline for (@typeInfo(Encoding).Enum.fields) |field| {636 inline for (@typeInfo(Encoding).@"enum".fields) |field| {
637 const len = symbol.bytes(@field(Encoding, field.name)).len;637 const len = symbol.bytes(@field(Encoding, field.name)).len;
638 max = @max(max, len);638 max = @max(max, len);
639 }639 }
lib/std/Random.zig+20-20
...@@ -34,9 +34,9 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,...@@ -34,9 +34,9 @@ fillFn: *const fn (ptr: *anyopaque, buf: []u8) void,
3434
35pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {35pub fn init(pointer: anytype, comptime fillFn: fn (ptr: @TypeOf(pointer), buf: []u8) void) Random {
36 const Ptr = @TypeOf(pointer);36 const Ptr = @TypeOf(pointer);
37 assert(@typeInfo(Ptr) == .Pointer); // Must be a pointer37 assert(@typeInfo(Ptr) == .pointer); // Must be a pointer
38 assert(@typeInfo(Ptr).Pointer.size == .One); // Must be a single-item pointer38 assert(@typeInfo(Ptr).pointer.size == .One); // Must be a single-item pointer
39 assert(@typeInfo(@typeInfo(Ptr).Pointer.child) == .Struct); // Must point to a struct39 assert(@typeInfo(@typeInfo(Ptr).pointer.child) == .@"struct"); // Must point to a struct
40 const gen = struct {40 const gen = struct {
41 fn fill(ptr: *anyopaque, buf: []u8) void {41 fn fill(ptr: *anyopaque, buf: []u8) void {
42 const self: Ptr = @ptrCast(@alignCast(ptr));42 const self: Ptr = @ptrCast(@alignCast(ptr));
...@@ -79,7 +79,7 @@ pub inline fn enumValue(r: Random, comptime EnumType: type) EnumType {...@@ -79,7 +79,7 @@ pub inline fn enumValue(r: Random, comptime EnumType: type) EnumType {
79/// See `uintLessThan`, which this function uses in most cases,79/// See `uintLessThan`, which this function uses in most cases,
80/// for commentary on the runtime of this function.80/// for commentary on the runtime of this function.
81pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: type) EnumType {81pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: type) EnumType {
82 comptime assert(@typeInfo(EnumType) == .Enum);82 comptime assert(@typeInfo(EnumType) == .@"enum");
8383
84 // We won't use int -> enum casting because enum elements can have84 // We won't use int -> enum casting because enum elements can have
85 // arbitrary values. Instead we'll randomly pick one of the type's values.85 // arbitrary values. Instead we'll randomly pick one of the type's values.
...@@ -100,7 +100,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty...@@ -100,7 +100,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty
100/// Returns a random int `i` such that `minInt(T) <= i <= maxInt(T)`.100/// Returns a random int `i` such that `minInt(T) <= i <= maxInt(T)`.
101/// `i` is evenly distributed.101/// `i` is evenly distributed.
102pub fn int(r: Random, comptime T: type) T {102pub fn int(r: Random, comptime T: type) T {
103 const bits = @typeInfo(T).Int.bits;103 const bits = @typeInfo(T).int.bits;
104 const UnsignedT = std.meta.Int(.unsigned, bits);104 const UnsignedT = std.meta.Int(.unsigned, bits);
105 const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable;105 const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable;
106 const ByteAlignedT = std.meta.Int(.unsigned, ceil_bytes * 8);106 const ByteAlignedT = std.meta.Int(.unsigned, ceil_bytes * 8);
...@@ -119,7 +119,7 @@ pub fn int(r: Random, comptime T: type) T {...@@ -119,7 +119,7 @@ pub fn int(r: Random, comptime T: type) T {
119/// Constant-time implementation off `uintLessThan`.119/// Constant-time implementation off `uintLessThan`.
120/// The results of this function may be biased.120/// The results of this function may be biased.
121pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T {121pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T {
122 comptime assert(@typeInfo(T).Int.signedness == .unsigned);122 comptime assert(@typeInfo(T).int.signedness == .unsigned);
123 assert(0 < less_than);123 assert(0 < less_than);
124 return limitRangeBiased(T, r.int(T), less_than);124 return limitRangeBiased(T, r.int(T), less_than);
125}125}
...@@ -133,8 +133,8 @@ pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T {...@@ -133,8 +133,8 @@ pub fn uintLessThanBiased(r: Random, comptime T: type, less_than: T) T {
133/// this function is guaranteed to return.133/// this function is guaranteed to return.
134/// If you need deterministic runtime bounds, use `uintLessThanBiased`.134/// If you need deterministic runtime bounds, use `uintLessThanBiased`.
135pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T {135pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T {
136 comptime assert(@typeInfo(T).Int.signedness == .unsigned);136 comptime assert(@typeInfo(T).int.signedness == .unsigned);
137 const bits = @typeInfo(T).Int.bits;137 const bits = @typeInfo(T).int.bits;
138 assert(0 < less_than);138 assert(0 < less_than);
139139
140 // adapted from:140 // adapted from:
...@@ -164,7 +164,7 @@ pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T {...@@ -164,7 +164,7 @@ pub fn uintLessThan(r: Random, comptime T: type, less_than: T) T {
164/// Constant-time implementation off `uintAtMost`.164/// Constant-time implementation off `uintAtMost`.
165/// The results of this function may be biased.165/// The results of this function may be biased.
166pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T {166pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T {
167 assert(@typeInfo(T).Int.signedness == .unsigned);167 assert(@typeInfo(T).int.signedness == .unsigned);
168 if (at_most == maxInt(T)) {168 if (at_most == maxInt(T)) {
169 // have the full range169 // have the full range
170 return r.int(T);170 return r.int(T);
...@@ -176,7 +176,7 @@ pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T {...@@ -176,7 +176,7 @@ pub fn uintAtMostBiased(r: Random, comptime T: type, at_most: T) T {
176/// See `uintLessThan`, which this function uses in most cases,176/// See `uintLessThan`, which this function uses in most cases,
177/// for commentary on the runtime of this function.177/// for commentary on the runtime of this function.
178pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T {178pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T {
179 assert(@typeInfo(T).Int.signedness == .unsigned);179 assert(@typeInfo(T).int.signedness == .unsigned);
180 if (at_most == maxInt(T)) {180 if (at_most == maxInt(T)) {
181 // have the full range181 // have the full range
182 return r.int(T);182 return r.int(T);
...@@ -188,7 +188,7 @@ pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T {...@@ -188,7 +188,7 @@ pub fn uintAtMost(r: Random, comptime T: type, at_most: T) T {
188/// The results of this function may be biased.188/// The results of this function may be biased.
189pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_than: T) T {189pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_than: T) T {
190 assert(at_least < less_than);190 assert(at_least < less_than);
191 const info = @typeInfo(T).Int;191 const info = @typeInfo(T).int;
192 if (info.signedness == .signed) {192 if (info.signedness == .signed) {
193 // Two's complement makes this math pretty easy.193 // Two's complement makes this math pretty easy.
194 const UnsignedT = std.meta.Int(.unsigned, info.bits);194 const UnsignedT = std.meta.Int(.unsigned, info.bits);
...@@ -207,7 +207,7 @@ pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_tha...@@ -207,7 +207,7 @@ pub fn intRangeLessThanBiased(r: Random, comptime T: type, at_least: T, less_tha
207/// for commentary on the runtime of this function.207/// for commentary on the runtime of this function.
208pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) T {208pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T) T {
209 assert(at_least < less_than);209 assert(at_least < less_than);
210 const info = @typeInfo(T).Int;210 const info = @typeInfo(T).int;
211 if (info.signedness == .signed) {211 if (info.signedness == .signed) {
212 // Two's complement makes this math pretty easy.212 // Two's complement makes this math pretty easy.
213 const UnsignedT = std.meta.Int(.unsigned, info.bits);213 const UnsignedT = std.meta.Int(.unsigned, info.bits);
...@@ -225,7 +225,7 @@ pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T)...@@ -225,7 +225,7 @@ pub fn intRangeLessThan(r: Random, comptime T: type, at_least: T, less_than: T)
225/// The results of this function may be biased.225/// The results of this function may be biased.
226pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T) T {226pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T) T {
227 assert(at_least <= at_most);227 assert(at_least <= at_most);
228 const info = @typeInfo(T).Int;228 const info = @typeInfo(T).int;
229 if (info.signedness == .signed) {229 if (info.signedness == .signed) {
230 // Two's complement makes this math pretty easy.230 // Two's complement makes this math pretty easy.
231 const UnsignedT = std.meta.Int(.unsigned, info.bits);231 const UnsignedT = std.meta.Int(.unsigned, info.bits);
...@@ -244,7 +244,7 @@ pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T...@@ -244,7 +244,7 @@ pub fn intRangeAtMostBiased(r: Random, comptime T: type, at_least: T, at_most: T
244/// for commentary on the runtime of this function.244/// for commentary on the runtime of this function.
245pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T {245pub fn intRangeAtMost(r: Random, comptime T: type, at_least: T, at_most: T) T {
246 assert(at_least <= at_most);246 assert(at_least <= at_most);
247 const info = @typeInfo(T).Int;247 const info = @typeInfo(T).int;
248 if (info.signedness == .signed) {248 if (info.signedness == .signed) {
249 // Two's complement makes this math pretty easy.249 // Two's complement makes this math pretty easy.
250 const UnsignedT = std.meta.Int(.unsigned, info.bits);250 const UnsignedT = std.meta.Int(.unsigned, info.bits);
...@@ -392,12 +392,12 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize...@@ -392,12 +392,12 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize
392 };392 };
393393
394 const point = switch (@typeInfo(T)) {394 const point = switch (@typeInfo(T)) {
395 .Int => |int_info| switch (int_info.signedness) {395 .int => |int_info| switch (int_info.signedness) {
396 .signed => r.intRangeLessThan(T, 0, sum),396 .signed => r.intRangeLessThan(T, 0, sum),
397 .unsigned => r.uintLessThan(T, sum),397 .unsigned => r.uintLessThan(T, sum),
398 },398 },
399 // take care that imprecision doesn't lead to a value slightly greater than sum399 // take care that imprecision doesn't lead to a value slightly greater than sum
400 .Float => @min(r.float(T) * sum, sum - std.math.floatEps(T)),400 .float => @min(r.float(T) * sum, sum - std.math.floatEps(T)),
401 else => @compileError("weightedIndex does not support proportions of type " ++401 else => @compileError("weightedIndex does not support proportions of type " ++
402 @typeName(T)),402 @typeName(T)),
403 };403 };
...@@ -415,8 +415,8 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize...@@ -415,8 +415,8 @@ pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize
415/// into an integer 0 <= result < less_than.415/// into an integer 0 <= result < less_than.
416/// This function introduces a minor bias.416/// This function introduces a minor bias.
417pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {417pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
418 comptime assert(@typeInfo(T).Int.signedness == .unsigned);418 comptime assert(@typeInfo(T).int.signedness == .unsigned);
419 const bits = @typeInfo(T).Int.bits;419 const bits = @typeInfo(T).int.bits;
420420
421 // adapted from:421 // adapted from:
422 // http://www.pcg-random.org/posts/bounded-rands.html422 // http://www.pcg-random.org/posts/bounded-rands.html
...@@ -427,9 +427,9 @@ pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {...@@ -427,9 +427,9 @@ pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
427427
428/// Returns the smallest of `Index` and `usize`.428/// Returns the smallest of `Index` and `usize`.
429fn MinArrayIndex(comptime Index: type) type {429fn MinArrayIndex(comptime Index: type) type {
430 const index_info = @typeInfo(Index).Int;430 const index_info = @typeInfo(Index).int;
431 assert(index_info.signedness == .unsigned);431 assert(index_info.signedness == .unsigned);
432 return if (index_info.bits >= @typeInfo(usize).Int.bits) usize else Index;432 return if (index_info.bits >= @typeInfo(usize).int.bits) usize else Index;
433}433}
434434
435test {435test {
lib/std/Target.zig+2-2
...@@ -154,7 +154,7 @@ pub const Os = struct {...@@ -154,7 +154,7 @@ pub const Os = struct {
154 };154 };
155 }155 }
156156
157 pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).Union.tag_type.? {157 pub inline fn getVersionRangeTag(tag: Tag) @typeInfo(TaggedVersionRange).@"union".tag_type.? {
158 return switch (tag) {158 return switch (tag) {
159 .freestanding,159 .freestanding,
160 .fuchsia,160 .fuchsia,
...@@ -1458,7 +1458,7 @@ pub const Cpu = struct {...@@ -1458,7 +1458,7 @@ pub const Cpu = struct {
14581458
1459 fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {1459 fn allCpusFromDecls(comptime cpus: type) []const *const Cpu.Model {
1460 @setEvalBranchQuota(2000);1460 @setEvalBranchQuota(2000);
1461 const decls = @typeInfo(cpus).Struct.decls;1461 const decls = @typeInfo(cpus).@"struct".decls;
1462 var array: [decls.len]*const Cpu.Model = undefined;1462 var array: [decls.len]*const Cpu.Model = undefined;
1463 for (decls, 0..) |decl, i| {1463 for (decls, 0..) |decl, i| {
1464 array[i] = &@field(cpus, decl.name);1464 array[i] = &@field(cpus, decl.name);
lib/std/Target/Query.zig+2-2
...@@ -53,7 +53,7 @@ pub const CpuModel = union(enum) {...@@ -53,7 +53,7 @@ pub const CpuModel = union(enum) {
53 explicit: *const Target.Cpu.Model,53 explicit: *const Target.Cpu.Model,
5454
55 pub fn eql(a: CpuModel, b: CpuModel) bool {55 pub fn eql(a: CpuModel, b: CpuModel) bool {
56 const Tag = @typeInfo(CpuModel).Union.tag_type.?;56 const Tag = @typeInfo(CpuModel).@"union".tag_type.?;
57 const a_tag: Tag = a;57 const a_tag: Tag = a;
58 const b_tag: Tag = b;58 const b_tag: Tag = b;
59 if (a_tag != b_tag) return false;59 if (a_tag != b_tag) return false;
...@@ -70,7 +70,7 @@ pub const OsVersion = union(enum) {...@@ -70,7 +70,7 @@ pub const OsVersion = union(enum) {
70 windows: Target.Os.WindowsVersion,70 windows: Target.Os.WindowsVersion,
7171
72 pub fn eql(a: OsVersion, b: OsVersion) bool {72 pub fn eql(a: OsVersion, b: OsVersion) bool {
73 const Tag = @typeInfo(OsVersion).Union.tag_type.?;73 const Tag = @typeInfo(OsVersion).@"union".tag_type.?;
74 const a_tag: Tag = a;74 const a_tag: Tag = a;
75 const b_tag: Tag = b;75 const b_tag: Tag = b;
76 if (a_tag != b_tag) return false;76 if (a_tag != b_tag) return false;
lib/std/Target/aarch64.zig+2-2
...@@ -242,7 +242,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;...@@ -242,7 +242,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
242242
243pub const all_features = blk: {243pub const all_features = blk: {
244 @setEvalBranchQuota(2000);244 @setEvalBranchQuota(2000);
245 const len = @typeInfo(Feature).Enum.fields.len;245 const len = @typeInfo(Feature).@"enum".fields.len;
246 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);246 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
247 var result: [len]CpuFeature = undefined;247 var result: [len]CpuFeature = undefined;
248 result[@intFromEnum(Feature.a510)] = .{248 result[@intFromEnum(Feature.a510)] = .{
...@@ -1660,7 +1660,7 @@ pub const all_features = blk: {...@@ -1660,7 +1660,7 @@ pub const all_features = blk: {
1660 const ti = @typeInfo(Feature);1660 const ti = @typeInfo(Feature);
1661 for (&result, 0..) |*elem, i| {1661 for (&result, 0..) |*elem, i| {
1662 elem.index = i;1662 elem.index = i;
1663 elem.name = ti.Enum.fields[i].name;1663 elem.name = ti.@"enum".fields[i].name;
1664 }1664 }
1665 break :blk result;1665 break :blk result;
1666};1666};
lib/std/Target/amdgpu.zig+2-2
...@@ -183,7 +183,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -183,7 +183,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
183pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;183pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
184184
185pub const all_features = blk: {185pub const all_features = blk: {
186 const len = @typeInfo(Feature).Enum.fields.len;186 const len = @typeInfo(Feature).@"enum".fields.len;
187 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);187 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
188 var result: [len]CpuFeature = undefined;188 var result: [len]CpuFeature = undefined;
189 result[@intFromEnum(Feature.@"16_bit_insts")] = .{189 result[@intFromEnum(Feature.@"16_bit_insts")] = .{
...@@ -1284,7 +1284,7 @@ pub const all_features = blk: {...@@ -1284,7 +1284,7 @@ pub const all_features = blk: {
1284 const ti = @typeInfo(Feature);1284 const ti = @typeInfo(Feature);
1285 for (&result, 0..) |*elem, i| {1285 for (&result, 0..) |*elem, i| {
1286 elem.index = i;1286 elem.index = i;
1287 elem.name = ti.Enum.fields[i].name;1287 elem.name = ti.@"enum".fields[i].name;
1288 }1288 }
1289 break :blk result;1289 break :blk result;
1290};1290};
lib/std/Target/arc.zig+2-2
...@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
14pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;14pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
1515
16pub const all_features = blk: {16pub const all_features = blk: {
17 const len = @typeInfo(Feature).Enum.fields.len;17 const len = @typeInfo(Feature).@"enum".fields.len;
18 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);18 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
19 var result: [len]CpuFeature = undefined;19 var result: [len]CpuFeature = undefined;
20 result[@intFromEnum(Feature.norm)] = .{20 result[@intFromEnum(Feature.norm)] = .{
...@@ -25,7 +25,7 @@ pub const all_features = blk: {...@@ -25,7 +25,7 @@ pub const all_features = blk: {
25 const ti = @typeInfo(Feature);25 const ti = @typeInfo(Feature);
26 for (&result, 0..) |*elem, i| {26 for (&result, 0..) |*elem, i| {
27 elem.index = i;27 elem.index = i;
28 elem.name = ti.Enum.fields[i].name;28 elem.name = ti.@"enum".fields[i].name;
29 }29 }
30 break :blk result;30 break :blk result;
31};31};
lib/std/Target/arm.zig+2-2
...@@ -215,7 +215,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;...@@ -215,7 +215,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
215215
216pub const all_features = blk: {216pub const all_features = blk: {
217 @setEvalBranchQuota(10000);217 @setEvalBranchQuota(10000);
218 const len = @typeInfo(Feature).Enum.fields.len;218 const len = @typeInfo(Feature).@"enum".fields.len;
219 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);219 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
220 var result: [len]CpuFeature = undefined;220 var result: [len]CpuFeature = undefined;
221 result[@intFromEnum(Feature.@"32bit")] = .{221 result[@intFromEnum(Feature.@"32bit")] = .{
...@@ -1735,7 +1735,7 @@ pub const all_features = blk: {...@@ -1735,7 +1735,7 @@ pub const all_features = blk: {
1735 const ti = @typeInfo(Feature);1735 const ti = @typeInfo(Feature);
1736 for (&result, 0..) |*elem, i| {1736 for (&result, 0..) |*elem, i| {
1737 elem.index = i;1737 elem.index = i;
1738 elem.name = ti.Enum.fields[i].name;1738 elem.name = ti.@"enum".fields[i].name;
1739 }1739 }
1740 break :blk result;1740 break :blk result;
1741};1741};
lib/std/Target/avr.zig+2-2
...@@ -49,7 +49,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -49,7 +49,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
49pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;49pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
5050
51pub const all_features = blk: {51pub const all_features = blk: {
52 const len = @typeInfo(Feature).Enum.fields.len;52 const len = @typeInfo(Feature).@"enum".fields.len;
53 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);53 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
54 var result: [len]CpuFeature = undefined;54 var result: [len]CpuFeature = undefined;
55 result[@intFromEnum(Feature.addsubiw)] = .{55 result[@intFromEnum(Feature.addsubiw)] = .{
...@@ -340,7 +340,7 @@ pub const all_features = blk: {...@@ -340,7 +340,7 @@ pub const all_features = blk: {
340 const ti = @typeInfo(Feature);340 const ti = @typeInfo(Feature);
341 for (&result, 0..) |*elem, i| {341 for (&result, 0..) |*elem, i| {
342 elem.index = i;342 elem.index = i;
343 elem.name = ti.Enum.fields[i].name;343 elem.name = ti.@"enum".fields[i].name;
344 }344 }
345 break :blk result;345 break :blk result;
346};346};
lib/std/Target/bpf.zig+2-2
...@@ -16,7 +16,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -16,7 +16,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
16pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;16pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
1717
18pub const all_features = blk: {18pub const all_features = blk: {
19 const len = @typeInfo(Feature).Enum.fields.len;19 const len = @typeInfo(Feature).@"enum".fields.len;
20 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);20 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
21 var result: [len]CpuFeature = undefined;21 var result: [len]CpuFeature = undefined;
22 result[@intFromEnum(Feature.alu32)] = .{22 result[@intFromEnum(Feature.alu32)] = .{
...@@ -37,7 +37,7 @@ pub const all_features = blk: {...@@ -37,7 +37,7 @@ pub const all_features = blk: {
37 const ti = @typeInfo(Feature);37 const ti = @typeInfo(Feature);
38 for (&result, 0..) |*elem, i| {38 for (&result, 0..) |*elem, i| {
39 elem.index = i;39 elem.index = i;
40 elem.name = ti.Enum.fields[i].name;40 elem.name = ti.@"enum".fields[i].name;
41 }41 }
42 break :blk result;42 break :blk result;
43};43};
lib/std/Target/csky.zig+2-2
...@@ -76,7 +76,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -76,7 +76,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
76pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;76pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
7777
78pub const all_features = blk: {78pub const all_features = blk: {
79 const len = @typeInfo(Feature).Enum.fields.len;79 const len = @typeInfo(Feature).@"enum".fields.len;
80 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);80 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
81 var result: [len]CpuFeature = undefined;81 var result: [len]CpuFeature = undefined;
82 result[@intFromEnum(Feature.@"10e60")] = .{82 result[@intFromEnum(Feature.@"10e60")] = .{
...@@ -418,7 +418,7 @@ pub const all_features = blk: {...@@ -418,7 +418,7 @@ pub const all_features = blk: {
418 const ti = @typeInfo(Feature);418 const ti = @typeInfo(Feature);
419 for (&result, 0..) |*elem, i| {419 for (&result, 0..) |*elem, i| {
420 elem.index = i;420 elem.index = i;
421 elem.name = ti.Enum.fields[i].name;421 elem.name = ti.@"enum".fields[i].name;
422 }422 }
423 break :blk result;423 break :blk result;
424};424};
lib/std/Target/hexagon.zig+2-2
...@@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
55pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;55pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
5656
57pub const all_features = blk: {57pub const all_features = blk: {
58 const len = @typeInfo(Feature).Enum.fields.len;58 const len = @typeInfo(Feature).@"enum".fields.len;
59 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);59 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
60 var result: [len]CpuFeature = undefined;60 var result: [len]CpuFeature = undefined;
61 result[@intFromEnum(Feature.audio)] = .{61 result[@intFromEnum(Feature.audio)] = .{
...@@ -298,7 +298,7 @@ pub const all_features = blk: {...@@ -298,7 +298,7 @@ pub const all_features = blk: {
298 const ti = @typeInfo(Feature);298 const ti = @typeInfo(Feature);
299 for (&result, 0..) |*elem, i| {299 for (&result, 0..) |*elem, i| {
300 elem.index = i;300 elem.index = i;
301 elem.name = ti.Enum.fields[i].name;301 elem.name = ti.@"enum".fields[i].name;
302 }302 }
303 break :blk result;303 break :blk result;
304};304};
lib/std/Target/loongarch.zig+2-2
...@@ -28,7 +28,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -28,7 +28,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
28pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;28pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
2929
30pub const all_features = blk: {30pub const all_features = blk: {
31 const len = @typeInfo(Feature).Enum.fields.len;31 const len = @typeInfo(Feature).@"enum".fields.len;
32 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);32 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
33 var result: [len]CpuFeature = undefined;33 var result: [len]CpuFeature = undefined;
34 result[@intFromEnum(Feature.@"32bit")] = .{34 result[@intFromEnum(Feature.@"32bit")] = .{
...@@ -115,7 +115,7 @@ pub const all_features = blk: {...@@ -115,7 +115,7 @@ pub const all_features = blk: {
115 const ti = @typeInfo(Feature);115 const ti = @typeInfo(Feature);
116 for (&result, 0..) |*elem, i| {116 for (&result, 0..) |*elem, i| {
117 elem.index = i;117 elem.index = i;
118 elem.name = ti.Enum.fields[i].name;118 elem.name = ti.@"enum".fields[i].name;
119 }119 }
120 break :blk result;120 break :blk result;
121};121};
lib/std/Target/m68k.zig+2-2
...@@ -36,7 +36,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -36,7 +36,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
36pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;36pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
3737
38pub const all_features = blk: {38pub const all_features = blk: {
39 const len = @typeInfo(Feature).Enum.fields.len;39 const len = @typeInfo(Feature).@"enum".fields.len;
40 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);40 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
41 var result: [len]CpuFeature = undefined;41 var result: [len]CpuFeature = undefined;
42 result[@intFromEnum(Feature.isa_68000)] = .{42 result[@intFromEnum(Feature.isa_68000)] = .{
...@@ -170,7 +170,7 @@ pub const all_features = blk: {...@@ -170,7 +170,7 @@ pub const all_features = blk: {
170 const ti = @typeInfo(Feature);170 const ti = @typeInfo(Feature);
171 for (&result, 0..) |*elem, i| {171 for (&result, 0..) |*elem, i| {
172 elem.index = i;172 elem.index = i;
173 elem.name = ti.Enum.fields[i].name;173 elem.name = ti.@"enum".fields[i].name;
174 }174 }
175 break :blk result;175 break :blk result;
176};176};
lib/std/Target/mips.zig+2-2
...@@ -65,7 +65,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -65,7 +65,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
65pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;65pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
6666
67pub const all_features = blk: {67pub const all_features = blk: {
68 const len = @typeInfo(Feature).Enum.fields.len;68 const len = @typeInfo(Feature).@"enum".fields.len;
69 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);69 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
70 var result: [len]CpuFeature = undefined;70 var result: [len]CpuFeature = undefined;
71 result[@intFromEnum(Feature.abs2008)] = .{71 result[@intFromEnum(Feature.abs2008)] = .{
...@@ -389,7 +389,7 @@ pub const all_features = blk: {...@@ -389,7 +389,7 @@ pub const all_features = blk: {
389 const ti = @typeInfo(Feature);389 const ti = @typeInfo(Feature);
390 for (&result, 0..) |*elem, i| {390 for (&result, 0..) |*elem, i| {
391 elem.index = i;391 elem.index = i;
392 elem.name = ti.Enum.fields[i].name;392 elem.name = ti.@"enum".fields[i].name;
393 }393 }
394 break :blk result;394 break :blk result;
395};395};
lib/std/Target/msp430.zig+2-2
...@@ -17,7 +17,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -17,7 +17,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
17pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;17pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
1818
19pub const all_features = blk: {19pub const all_features = blk: {
20 const len = @typeInfo(Feature).Enum.fields.len;20 const len = @typeInfo(Feature).@"enum".fields.len;
21 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);21 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
22 var result: [len]CpuFeature = undefined;22 var result: [len]CpuFeature = undefined;
23 result[@intFromEnum(Feature.ext)] = .{23 result[@intFromEnum(Feature.ext)] = .{
...@@ -43,7 +43,7 @@ pub const all_features = blk: {...@@ -43,7 +43,7 @@ pub const all_features = blk: {
43 const ti = @typeInfo(Feature);43 const ti = @typeInfo(Feature);
44 for (&result, 0..) |*elem, i| {44 for (&result, 0..) |*elem, i| {
45 elem.index = i;45 elem.index = i;
46 elem.name = ti.Enum.fields[i].name;46 elem.name = ti.@"enum".fields[i].name;
47 }47 }
48 break :blk result;48 break :blk result;
49};49};
lib/std/Target/nvptx.zig+2-2
...@@ -58,7 +58,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -58,7 +58,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
58pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;58pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
5959
60pub const all_features = blk: {60pub const all_features = blk: {
61 const len = @typeInfo(Feature).Enum.fields.len;61 const len = @typeInfo(Feature).@"enum".fields.len;
62 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);62 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
63 var result: [len]CpuFeature = undefined;63 var result: [len]CpuFeature = undefined;
64 result[@intFromEnum(Feature.ptx32)] = .{64 result[@intFromEnum(Feature.ptx32)] = .{
...@@ -289,7 +289,7 @@ pub const all_features = blk: {...@@ -289,7 +289,7 @@ pub const all_features = blk: {
289 const ti = @typeInfo(Feature);289 const ti = @typeInfo(Feature);
290 for (&result, 0..) |*elem, i| {290 for (&result, 0..) |*elem, i| {
291 elem.index = i;291 elem.index = i;
292 elem.name = ti.Enum.fields[i].name;292 elem.name = ti.@"enum".fields[i].name;
293 }293 }
294 break :blk result;294 break :blk result;
295};295};
lib/std/Target/powerpc.zig+2-2
...@@ -95,7 +95,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -95,7 +95,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
95pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;95pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
9696
97pub const all_features = blk: {97pub const all_features = blk: {
98 const len = @typeInfo(Feature).Enum.fields.len;98 const len = @typeInfo(Feature).@"enum".fields.len;
99 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);99 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
100 var result: [len]CpuFeature = undefined;100 var result: [len]CpuFeature = undefined;
101 result[@intFromEnum(Feature.@"64bit")] = .{101 result[@intFromEnum(Feature.@"64bit")] = .{
...@@ -606,7 +606,7 @@ pub const all_features = blk: {...@@ -606,7 +606,7 @@ pub const all_features = blk: {
606 const ti = @typeInfo(Feature);606 const ti = @typeInfo(Feature);
607 for (&result, 0..) |*elem, i| {607 for (&result, 0..) |*elem, i| {
608 elem.index = i;608 elem.index = i;
609 elem.name = ti.Enum.fields[i].name;609 elem.name = ti.@"enum".fields[i].name;
610 }610 }
611 break :blk result;611 break :blk result;
612};612};
lib/std/Target/riscv.zig+2-2
...@@ -201,7 +201,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -201,7 +201,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
201pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;201pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
202202
203pub const all_features = blk: {203pub const all_features = blk: {
204 const len = @typeInfo(Feature).Enum.fields.len;204 const len = @typeInfo(Feature).@"enum".fields.len;
205 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);205 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
206 var result: [len]CpuFeature = undefined;206 var result: [len]CpuFeature = undefined;
207 result[@intFromEnum(Feature.@"32bit")] = .{207 result[@intFromEnum(Feature.@"32bit")] = .{
...@@ -1298,7 +1298,7 @@ pub const all_features = blk: {...@@ -1298,7 +1298,7 @@ pub const all_features = blk: {
1298 const ti = @typeInfo(Feature);1298 const ti = @typeInfo(Feature);
1299 for (&result, 0..) |*elem, i| {1299 for (&result, 0..) |*elem, i| {
1300 elem.index = i;1300 elem.index = i;
1301 elem.name = ti.Enum.fields[i].name;1301 elem.name = ti.@"enum".fields[i].name;
1302 }1302 }
1303 break :blk result;1303 break :blk result;
1304};1304};
lib/std/Target/s390x.zig+2-2
...@@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -55,7 +55,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
55pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;55pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
5656
57pub const all_features = blk: {57pub const all_features = blk: {
58 const len = @typeInfo(Feature).Enum.fields.len;58 const len = @typeInfo(Feature).@"enum".fields.len;
59 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);59 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
60 var result: [len]CpuFeature = undefined;60 var result: [len]CpuFeature = undefined;
61 result[@intFromEnum(Feature.backchain)] = .{61 result[@intFromEnum(Feature.backchain)] = .{
...@@ -271,7 +271,7 @@ pub const all_features = blk: {...@@ -271,7 +271,7 @@ pub const all_features = blk: {
271 const ti = @typeInfo(Feature);271 const ti = @typeInfo(Feature);
272 for (&result, 0..) |*elem, i| {272 for (&result, 0..) |*elem, i| {
273 elem.index = i;273 elem.index = i;
274 elem.name = ti.Enum.fields[i].name;274 elem.name = ti.@"enum".fields[i].name;
275 }275 }
276 break :blk result;276 break :blk result;
277};277};
lib/std/Target/sparc.zig+2-2
...@@ -60,7 +60,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -60,7 +60,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
60pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;60pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
6161
62pub const all_features = blk: {62pub const all_features = blk: {
63 const len = @typeInfo(Feature).Enum.fields.len;63 const len = @typeInfo(Feature).@"enum".fields.len;
64 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);64 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
65 var result: [len]CpuFeature = undefined;65 var result: [len]CpuFeature = undefined;
66 result[@intFromEnum(Feature.deprecated_v8)] = .{66 result[@intFromEnum(Feature.deprecated_v8)] = .{
...@@ -303,7 +303,7 @@ pub const all_features = blk: {...@@ -303,7 +303,7 @@ pub const all_features = blk: {
303 const ti = @typeInfo(Feature);303 const ti = @typeInfo(Feature);
304 for (&result, 0..) |*elem, i| {304 for (&result, 0..) |*elem, i| {
305 elem.index = i;305 elem.index = i;
306 elem.name = ti.Enum.fields[i].name;306 elem.name = ti.@"enum".fields[i].name;
307 }307 }
308 break :blk result;308 break :blk result;
309};309};
lib/std/Target/spirv.zig+2-2
...@@ -301,7 +301,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;...@@ -301,7 +301,7 @@ pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
301301
302pub const all_features = blk: {302pub const all_features = blk: {
303 @setEvalBranchQuota(2000);303 @setEvalBranchQuota(2000);
304 const len = @typeInfo(Feature).Enum.fields.len;304 const len = @typeInfo(Feature).@"enum".fields.len;
305 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);305 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
306 var result: [len]CpuFeature = undefined;306 var result: [len]CpuFeature = undefined;
307 result[@intFromEnum(Feature.v1_1)] = .{307 result[@intFromEnum(Feature.v1_1)] = .{
...@@ -2077,7 +2077,7 @@ pub const all_features = blk: {...@@ -2077,7 +2077,7 @@ pub const all_features = blk: {
2077 const ti = @typeInfo(Feature);2077 const ti = @typeInfo(Feature);
2078 for (&result, 0..) |*elem, i| {2078 for (&result, 0..) |*elem, i| {
2079 elem.index = i;2079 elem.index = i;
2080 elem.name = ti.Enum.fields[i].name;2080 elem.name = ti.@"enum".fields[i].name;
2081 }2081 }
2082 break :blk result;2082 break :blk result;
2083};2083};
lib/std/Target/ve.zig+2-2
...@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
14pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;14pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
1515
16pub const all_features = blk: {16pub const all_features = blk: {
17 const len = @typeInfo(Feature).Enum.fields.len;17 const len = @typeInfo(Feature).@"enum".fields.len;
18 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);18 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
19 var result: [len]CpuFeature = undefined;19 var result: [len]CpuFeature = undefined;
20 result[@intFromEnum(Feature.vpu)] = .{20 result[@intFromEnum(Feature.vpu)] = .{
...@@ -25,7 +25,7 @@ pub const all_features = blk: {...@@ -25,7 +25,7 @@ pub const all_features = blk: {
25 const ti = @typeInfo(Feature);25 const ti = @typeInfo(Feature);
26 for (&result, 0..) |*elem, i| {26 for (&result, 0..) |*elem, i| {
27 elem.index = i;27 elem.index = i;
28 elem.name = ti.Enum.fields[i].name;28 elem.name = ti.@"enum".fields[i].name;
29 }29 }
30 break :blk result;30 break :blk result;
31};31};
lib/std/Target/wasm.zig+2-2
...@@ -26,7 +26,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -26,7 +26,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
26pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;26pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
2727
28pub const all_features = blk: {28pub const all_features = blk: {
29 const len = @typeInfo(Feature).Enum.fields.len;29 const len = @typeInfo(Feature).@"enum".fields.len;
30 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);30 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
31 var result: [len]CpuFeature = undefined;31 var result: [len]CpuFeature = undefined;
32 result[@intFromEnum(Feature.atomics)] = .{32 result[@intFromEnum(Feature.atomics)] = .{
...@@ -97,7 +97,7 @@ pub const all_features = blk: {...@@ -97,7 +97,7 @@ pub const all_features = blk: {
97 const ti = @typeInfo(Feature);97 const ti = @typeInfo(Feature);
98 for (&result, 0..) |*elem, i| {98 for (&result, 0..) |*elem, i| {
99 elem.index = i;99 elem.index = i;
100 elem.name = ti.Enum.fields[i].name;100 elem.name = ti.@"enum".fields[i].name;
101 }101 }
102 break :blk result;102 break :blk result;
103};103};
lib/std/Target/x86.zig+2-2
...@@ -199,7 +199,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -199,7 +199,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
199pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;199pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
200200
201pub const all_features = blk: {201pub const all_features = blk: {
202 const len = @typeInfo(Feature).Enum.fields.len;202 const len = @typeInfo(Feature).@"enum".fields.len;
203 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);203 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
204 var result: [len]CpuFeature = undefined;204 var result: [len]CpuFeature = undefined;
205 result[@intFromEnum(Feature.@"16bit_mode")] = .{205 result[@intFromEnum(Feature.@"16bit_mode")] = .{
...@@ -1272,7 +1272,7 @@ pub const all_features = blk: {...@@ -1272,7 +1272,7 @@ pub const all_features = blk: {
1272 const ti = @typeInfo(Feature);1272 const ti = @typeInfo(Feature);
1273 for (&result, 0..) |*elem, i| {1273 for (&result, 0..) |*elem, i| {
1274 elem.index = i;1274 elem.index = i;
1275 elem.name = ti.Enum.fields[i].name;1275 elem.name = ti.@"enum".fields[i].name;
1276 }1276 }
1277 break :blk result;1277 break :blk result;
1278};1278};
lib/std/Target/xtensa.zig+2-2
...@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;...@@ -14,7 +14,7 @@ pub const featureSetHasAny = CpuFeature.FeatureSetFns(Feature).featureSetHasAny;
14pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;14pub const featureSetHasAll = CpuFeature.FeatureSetFns(Feature).featureSetHasAll;
1515
16pub const all_features = blk: {16pub const all_features = blk: {
17 const len = @typeInfo(Feature).Enum.fields.len;17 const len = @typeInfo(Feature).@"enum".fields.len;
18 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);18 std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
19 var result: [len]CpuFeature = undefined;19 var result: [len]CpuFeature = undefined;
20 result[@intFromEnum(Feature.density)] = .{20 result[@intFromEnum(Feature.density)] = .{
...@@ -25,7 +25,7 @@ pub const all_features = blk: {...@@ -25,7 +25,7 @@ pub const all_features = blk: {
25 const ti = @typeInfo(Feature);25 const ti = @typeInfo(Feature);
26 for (&result, 0..) |*elem, i| {26 for (&result, 0..) |*elem, i| {
27 elem.index = i;27 elem.index = i;
28 elem.name = ti.Enum.fields[i].name;28 elem.name = ti.@"enum".fields[i].name;
29 }29 }
30 break :blk result;30 break :blk result;
31};31};
lib/std/Thread.zig+9-9
...@@ -401,15 +401,15 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {...@@ -401,15 +401,15 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
401 const default_value = if (Impl == PosixThreadImpl) null else 0;401 const default_value = if (Impl == PosixThreadImpl) null else 0;
402 const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', '!noreturn', 'void', or '!void'";402 const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', '!noreturn', 'void', or '!void'";
403403
404 switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {404 switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) {
405 .NoReturn => {405 .noreturn => {
406 @call(.auto, f, args);406 @call(.auto, f, args);
407 },407 },
408 .Void => {408 .void => {
409 @call(.auto, f, args);409 @call(.auto, f, args);
410 return default_value;410 return default_value;
411 },411 },
412 .Int => |info| {412 .int => |info| {
413 if (info.bits != 8) {413 if (info.bits != 8) {
414 @compileError(bad_fn_ret);414 @compileError(bad_fn_ret);
415 }415 }
...@@ -422,7 +422,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {...@@ -422,7 +422,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
422 // pthreads don't support exit status, ignore value422 // pthreads don't support exit status, ignore value
423 return default_value;423 return default_value;
424 },424 },
425 .ErrorUnion => |info| {425 .error_union => |info| {
426 switch (info.payload) {426 switch (info.payload) {
427 void, noreturn => {427 void, noreturn => {
428 @call(.auto, f, args) catch |err| {428 @call(.auto, f, args) catch |err| {
...@@ -850,17 +850,17 @@ const WasiThreadImpl = struct {...@@ -850,17 +850,17 @@ const WasiThreadImpl = struct {
850 fn entry(ptr: usize) void {850 fn entry(ptr: usize) void {
851 const w: *@This() = @ptrFromInt(ptr);851 const w: *@This() = @ptrFromInt(ptr);
852 const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'";852 const bad_fn_ret = "expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'";
853 switch (@typeInfo(@typeInfo(@TypeOf(f)).Fn.return_type.?)) {853 switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) {
854 .NoReturn, .Void => {854 .noreturn, .void => {
855 @call(.auto, f, w.args);855 @call(.auto, f, w.args);
856 },856 },
857 .Int => |info| {857 .int => |info| {
858 if (info.bits != 8) {858 if (info.bits != 8) {
859 @compileError(bad_fn_ret);859 @compileError(bad_fn_ret);
860 }860 }
861 _ = @call(.auto, f, w.args); // WASI threads don't support exit status, ignore value861 _ = @call(.auto, f, w.args); // WASI threads don't support exit status, ignore value
862 },862 },
863 .ErrorUnion => |info| {863 .error_union => |info| {
864 if (info.payload != void) {864 if (info.payload != void) {
865 @compileError(bad_fn_ret);865 @compileError(bad_fn_ret);
866 }866 }
lib/std/array_hash_map.zig+11-11
...@@ -2584,17 +2584,17 @@ pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K...@@ -2584,17 +2584,17 @@ pub fn getAutoEqlFn(comptime K: type, comptime Context: type) (fn (Context, K, K
25842584
2585pub fn autoEqlIsCheap(comptime K: type) bool {2585pub fn autoEqlIsCheap(comptime K: type) bool {
2586 return switch (@typeInfo(K)) {2586 return switch (@typeInfo(K)) {
2587 .Bool,2587 .bool,
2588 .Int,2588 .int,
2589 .Float,2589 .float,
2590 .Pointer,2590 .pointer,
2591 .ComptimeFloat,2591 .comptime_float,
2592 .ComptimeInt,2592 .comptime_int,
2593 .Enum,2593 .@"enum",
2594 .Fn,2594 .@"fn",
2595 .ErrorSet,2595 .error_set,
2596 .AnyFrame,2596 .@"anyframe",
2597 .EnumLiteral,2597 .enum_literal,
2598 => true,2598 => true,
2599 else => false,2599 else => false,
2600 };2600 };
lib/std/bit_set.zig+2-2
...@@ -319,10 +319,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {...@@ -319,10 +319,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
319 const mask_info: std.builtin.Type = @typeInfo(MaskIntType);319 const mask_info: std.builtin.Type = @typeInfo(MaskIntType);
320320
321 // Make sure the mask int is indeed an int321 // Make sure the mask int is indeed an int
322 if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));322 if (mask_info != .int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
323323
324 // It must also be unsigned.324 // It must also be unsigned.
325 if (mask_info.Int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));325 if (mask_info.int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));
326326
327 // And it must not be empty.327 // And it must not be empty.
328 if (MaskIntType == u0)328 if (MaskIntType == u0)
lib/std/builtin.zig+24-24
...@@ -257,30 +257,30 @@ pub const TypeId = std.meta.Tag(Type);...@@ -257,30 +257,30 @@ pub const TypeId = std.meta.Tag(Type);
257/// This data structure is used by the Zig language code generation and257/// This data structure is used by the Zig language code generation and
258/// therefore must be kept in sync with the compiler implementation.258/// therefore must be kept in sync with the compiler implementation.
259pub const Type = union(enum) {259pub const Type = union(enum) {
260 Type: void,260 type: void,
261 Void: void,261 void: void,
262 Bool: void,262 bool: void,
263 NoReturn: void,263 noreturn: void,
264 Int: Int,264 int: Int,
265 Float: Float,265 float: Float,
266 Pointer: Pointer,266 pointer: Pointer,
267 Array: Array,267 array: Array,
268 Struct: Struct,268 @"struct": Struct,
269 ComptimeFloat: void,269 comptime_float: void,
270 ComptimeInt: void,270 comptime_int: void,
271 Undefined: void,271 undefined: void,
272 Null: void,272 null: void,
273 Optional: Optional,273 optional: Optional,
274 ErrorUnion: ErrorUnion,274 error_union: ErrorUnion,
275 ErrorSet: ErrorSet,275 error_set: ErrorSet,
276 Enum: Enum,276 @"enum": Enum,
277 Union: Union,277 @"union": Union,
278 Fn: Fn,278 @"fn": Fn,
279 Opaque: Opaque,279 @"opaque": Opaque,
280 Frame: Frame,280 frame: Frame,
281 AnyFrame: AnyFrame,281 @"anyframe": AnyFrame,
282 Vector: Vector,282 vector: Vector,
283 EnumLiteral: void,283 enum_literal: void,
284284
285 /// This data structure is used by the Zig language code generation and285 /// This data structure is used by the Zig language code generation and
286 /// therefore must be kept in sync with the compiler implementation.286 /// therefore must be kept in sync with the compiler implementation.
lib/std/c/darwin.zig+1-1
...@@ -54,7 +54,7 @@ pub const EXC = enum(exception_type_t) {...@@ -54,7 +54,7 @@ pub const EXC = enum(exception_type_t) {
54 /// Abnormal process exited to corpse state54 /// Abnormal process exited to corpse state
55 CORPSE_NOTIFY = 13,55 CORPSE_NOTIFY = 13,
5656
57 pub const TYPES_COUNT = @typeInfo(EXC).Enum.fields.len;57 pub const TYPES_COUNT = @typeInfo(EXC).@"enum".fields.len;
58 pub const SOFT_SIGNAL = 0x10003;58 pub const SOFT_SIGNAL = 0x10003;
5959
60 pub const MASK = packed struct(u32) {60 pub const MASK = packed struct(u32) {
lib/std/compress/flate/huffman_encoder.zig+1-1
...@@ -455,7 +455,7 @@ test "generate a Huffman code for the 30 possible relative distances (LZ77 dista...@@ -455,7 +455,7 @@ test "generate a Huffman code for the 30 possible relative distances (LZ77 dista
455// Reverse bit-by-bit a N-bit code.455// Reverse bit-by-bit a N-bit code.
456fn bitReverse(comptime T: type, value: T, n: usize) T {456fn bitReverse(comptime T: type, value: T, n: usize) T {
457 const r = @bitReverse(value);457 const r = @bitReverse(value);
458 return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).Int.bits - n));458 return r >> @as(math.Log2Int(T), @intCast(@typeInfo(T).int.bits - n));
459}459}
460460
461test bitReverse {461test bitReverse {
lib/std/crypto/cmac.zig+1-1
...@@ -8,7 +8,7 @@ pub const CmacAes128 = Cmac(crypto.core.aes.Aes128);...@@ -8,7 +8,7 @@ pub const CmacAes128 = Cmac(crypto.core.aes.Aes128);
8/// NIST Special Publication 800-38B - The CMAC Mode for Authentication8/// NIST Special Publication 800-38B - The CMAC Mode for Authentication
9/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf9/// https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38b.pdf
10pub fn Cmac(comptime BlockCipher: type) type {10pub fn Cmac(comptime BlockCipher: type) type {
11 const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).Fn.return_type.?;11 const BlockCipherCtx = @typeInfo(@TypeOf(BlockCipher.initEnc)).@"fn".return_type.?;
12 const Block = [BlockCipher.block.block_length]u8;12 const Block = [BlockCipher.block.block_length]u8;
1313
14 return struct {14 return struct {
lib/std/crypto/ff.zig+2-2
...@@ -848,7 +848,7 @@ const ct_protected = struct {...@@ -848,7 +848,7 @@ const ct_protected = struct {
848848
849 // Multiplies two limbs and returns the result as a wide limb.849 // Multiplies two limbs and returns the result as a wide limb.
850 fn mulWide(x: Limb, y: Limb) WideLimb {850 fn mulWide(x: Limb, y: Limb) WideLimb {
851 const half_bits = @typeInfo(Limb).Int.bits / 2;851 const half_bits = @typeInfo(Limb).int.bits / 2;
852 const Half = meta.Int(.unsigned, half_bits);852 const Half = meta.Int(.unsigned, half_bits);
853 const x0 = @as(Half, @truncate(x));853 const x0 = @as(Half, @truncate(x));
854 const x1 = @as(Half, @truncate(x >> half_bits));854 const x1 = @as(Half, @truncate(x >> half_bits));
...@@ -901,7 +901,7 @@ const ct_unprotected = struct {...@@ -901,7 +901,7 @@ const ct_unprotected = struct {
901 fn mulWide(x: Limb, y: Limb) WideLimb {901 fn mulWide(x: Limb, y: Limb) WideLimb {
902 const wide = math.mulWide(Limb, x, y);902 const wide = math.mulWide(Limb, x, y);
903 return .{903 return .{
904 .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).Int.bits)),904 .hi = @as(Limb, @truncate(wide >> @typeInfo(Limb).int.bits)),
905 .lo = @as(Limb, @truncate(wide)),905 .lo = @as(Limb, @truncate(wide)),
906 };906 };
907 }907 }
lib/std/crypto/phc_encoding.zig+8-8
...@@ -91,7 +91,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult...@@ -91,7 +91,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
91 if (mem.eql(u8, opt_version.key, version_param_name)) {91 if (mem.eql(u8, opt_version.key, version_param_name)) {
92 if (@hasField(HashResult, "alg_version")) {92 if (@hasField(HashResult, "alg_version")) {
93 const value_type_info = switch (@typeInfo(@TypeOf(out.alg_version))) {93 const value_type_info = switch (@typeInfo(@TypeOf(out.alg_version))) {
94 .Optional => |opt| comptime @typeInfo(opt.child),94 .optional => |opt| @typeInfo(opt.child),
95 else => |t| t,95 else => |t| t,
96 };96 };
97 out.alg_version = fmt.parseUnsigned(97 out.alg_version = fmt.parseUnsigned(
...@@ -114,16 +114,16 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult...@@ -114,16 +114,16 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
114 inline for (comptime meta.fields(HashResult)) |p| {114 inline for (comptime meta.fields(HashResult)) |p| {
115 if (mem.eql(u8, p.name, param.key)) {115 if (mem.eql(u8, p.name, param.key)) {
116 switch (@typeInfo(p.type)) {116 switch (@typeInfo(p.type)) {
117 .Int => @field(out, p.name) = fmt.parseUnsigned(117 .int => @field(out, p.name) = fmt.parseUnsigned(
118 p.type,118 p.type,
119 param.value,119 param.value,
120 10,120 10,
121 ) catch return Error.InvalidEncoding,121 ) catch return Error.InvalidEncoding,
122 .Pointer => |ptr| {122 .pointer => |ptr| {
123 if (!ptr.is_const) @compileError("Value slice must be constant");123 if (!ptr.is_const) @compileError("Value slice must be constant");
124 @field(out, p.name) = param.value;124 @field(out, p.name) = param.value;
125 },125 },
126 .Struct => try @field(out, p.name).fromB64(param.value),126 .@"struct" => try @field(out, p.name).fromB64(param.value),
127 else => std.debug.panic(127 else => std.debug.panic(
128 "Value for [{s}] must be an integer, a constant slice or a BinValue",128 "Value for [{s}] must be an integer, a constant slice or a BinValue",
129 .{p.name},129 .{p.name},
...@@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult...@@ -164,7 +164,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
164 // with default values164 // with default values
165 var expected_fields: usize = 0;165 var expected_fields: usize = 0;
166 inline for (comptime meta.fields(HashResult)) |p| {166 inline for (comptime meta.fields(HashResult)) |p| {
167 if (@typeInfo(p.type) != .Optional and p.default_value == null) {167 if (@typeInfo(p.type) != .optional and p.default_value == null) {
168 expected_fields += 1;168 expected_fields += 1;
169 }169 }
170 }170 }
...@@ -202,7 +202,7 @@ fn serializeTo(params: anytype, out: anytype) !void {...@@ -202,7 +202,7 @@ fn serializeTo(params: anytype, out: anytype) !void {
202 try out.writeAll(params.alg_id);202 try out.writeAll(params.alg_id);
203203
204 if (@hasField(HashResult, "alg_version")) {204 if (@hasField(HashResult, "alg_version")) {
205 if (@typeInfo(@TypeOf(params.alg_version)) == .Optional) {205 if (@typeInfo(@TypeOf(params.alg_version)) == .optional) {
206 if (params.alg_version) |alg_version| {206 if (params.alg_version) |alg_version| {
207 try out.print(207 try out.print(
208 "{s}{s}{s}{}",208 "{s}{s}{s}{}",
...@@ -226,12 +226,12 @@ fn serializeTo(params: anytype, out: anytype) !void {...@@ -226,12 +226,12 @@ fn serializeTo(params: anytype, out: anytype) !void {
226 {226 {
227 const value = @field(params, p.name);227 const value = @field(params, p.name);
228 try out.writeAll(if (has_params) params_delimiter else fields_delimiter);228 try out.writeAll(if (has_params) params_delimiter else fields_delimiter);
229 if (@typeInfo(p.type) == .Struct) {229 if (@typeInfo(p.type) == .@"struct") {
230 var buf: [@TypeOf(value).max_encoded_length]u8 = undefined;230 var buf: [@TypeOf(value).max_encoded_length]u8 = undefined;
231 try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) });231 try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) });
232 } else {232 } else {
233 try out.print(233 try out.print(
234 if (@typeInfo(@TypeOf(value)) == .Pointer) "{s}{s}{s}" else "{s}{s}{}",234 if (@typeInfo(@TypeOf(value)) == .pointer) "{s}{s}{s}" else "{s}{s}{}",
235 .{ p.name, kv_delimiter, value },235 .{ p.name, kv_delimiter, value },
236 );236 );
237 }237 }
lib/std/crypto/timing_safe.zig+7-7
...@@ -11,27 +11,27 @@ const Order = std.math.Order;...@@ -11,27 +11,27 @@ const Order = std.math.Order;
11/// For all other applications, use mem.eql() instead.11/// For all other applications, use mem.eql() instead.
12pub fn eql(comptime T: type, a: T, b: T) bool {12pub fn eql(comptime T: type, a: T, b: T) bool {
13 switch (@typeInfo(T)) {13 switch (@typeInfo(T)) {
14 .Array => |info| {14 .array => |info| {
15 const C = info.child;15 const C = info.child;
16 if (@typeInfo(C) != .Int) {16 if (@typeInfo(C) != .int) {
17 @compileError("Elements to be compared must be integers");17 @compileError("Elements to be compared must be integers");
18 }18 }
19 var acc = @as(C, 0);19 var acc = @as(C, 0);
20 for (a, 0..) |x, i| {20 for (a, 0..) |x, i| {
21 acc |= x ^ b[i];21 acc |= x ^ b[i];
22 }22 }
23 const s = @typeInfo(C).Int.bits;23 const s = @typeInfo(C).int.bits;
24 const Cu = std.meta.Int(.unsigned, s);24 const Cu = std.meta.Int(.unsigned, s);
25 const Cext = std.meta.Int(.unsigned, s + 1);25 const Cext = std.meta.Int(.unsigned, s + 1);
26 return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s))));26 return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s))));
27 },27 },
28 .Vector => |info| {28 .vector => |info| {
29 const C = info.child;29 const C = info.child;
30 if (@typeInfo(C) != .Int) {30 if (@typeInfo(C) != .int) {
31 @compileError("Elements to be compared must be integers");31 @compileError("Elements to be compared must be integers");
32 }32 }
33 const acc = @reduce(.Or, a ^ b);33 const acc = @reduce(.Or, a ^ b);
34 const s = @typeInfo(C).Int.bits;34 const s = @typeInfo(C).int.bits;
35 const Cu = std.meta.Int(.unsigned, s);35 const Cu = std.meta.Int(.unsigned, s);
36 const Cext = std.meta.Int(.unsigned, s + 1);36 const Cext = std.meta.Int(.unsigned, s + 1);
37 return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s))));37 return @as(bool, @bitCast(@as(u1, @truncate((@as(Cext, @as(Cu, @bitCast(acc))) -% 1) >> s))));
...@@ -47,7 +47,7 @@ pub fn eql(comptime T: type, a: T, b: T) bool {...@@ -47,7 +47,7 @@ pub fn eql(comptime T: type, a: T, b: T) bool {
47pub fn compare(comptime T: type, a: []const T, b: []const T, endian: Endian) Order {47pub fn compare(comptime T: type, a: []const T, b: []const T, endian: Endian) Order {
48 assert(a.len == b.len);48 assert(a.len == b.len);
49 const bits = switch (@typeInfo(T)) {49 const bits = switch (@typeInfo(T)) {
50 .Int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits,50 .int => |cinfo| if (cinfo.signedness != .unsigned) @compileError("Elements to be compared must be unsigned") else cinfo.bits,
51 else => @compileError("Elements to be compared must be integers"),51 else => @compileError("Elements to be compared must be integers"),
52 };52 };
53 const Cext = std.meta.Int(.unsigned, bits + 1);53 const Cext = std.meta.Int(.unsigned, bits + 1);
lib/std/crypto/tls.zig+2-2
...@@ -491,7 +491,7 @@ pub const Decoder = struct {...@@ -491,7 +491,7 @@ pub const Decoder = struct {
491 /// Use this function to increase `idx`.491 /// Use this function to increase `idx`.
492 pub fn decode(d: *Decoder, comptime T: type) T {492 pub fn decode(d: *Decoder, comptime T: type) T {
493 switch (@typeInfo(T)) {493 switch (@typeInfo(T)) {
494 .Int => |info| switch (info.bits) {494 .int => |info| switch (info.bits) {
495 8 => {495 8 => {
496 skip(d, 1);496 skip(d, 1);
497 return d.buf[d.idx - 1];497 return d.buf[d.idx - 1];
...@@ -511,7 +511,7 @@ pub const Decoder = struct {...@@ -511,7 +511,7 @@ pub const Decoder = struct {
511 },511 },
512 else => @compileError("unsupported int type: " ++ @typeName(T)),512 else => @compileError("unsupported int type: " ++ @typeName(T)),
513 },513 },
514 .Enum => |info| {514 .@"enum" => |info| {
515 const int = d.decode(info.tag_type);515 const int = d.decode(info.tag_type);
516 if (info.is_exhaustive) @compileError("exhaustive enum cannot be used");516 if (info.is_exhaustive) @compileError("exhaustive enum cannot be used");
517 return @as(T, @enumFromInt(int));517 return @as(T, @enumFromInt(int));
lib/std/debug.zig+1-1
...@@ -547,7 +547,7 @@ pub fn writeStackTrace(...@@ -547,7 +547,7 @@ pub fn writeStackTrace(
547}547}
548548
549pub const UnwindError = if (have_ucontext)549pub const UnwindError = if (have_ucontext)
550 @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).Fn.return_type.?).ErrorUnion.error_set550 @typeInfo(@typeInfo(@TypeOf(StackIterator.next_unwind)).@"fn".return_type.?).error_union.error_set
551else551else
552 void;552 void;
553553
lib/std/debug/Dwarf.zig+1-1
...@@ -2216,7 +2216,7 @@ pub const ElfModule = struct {...@@ -2216,7 +2216,7 @@ pub const ElfModule = struct {
2216 }2216 }
22172217
2218 var section_index: ?usize = null;2218 var section_index: ?usize = null;
2219 inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |sect, i| {2219 inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |sect, i| {
2220 if (mem.eql(u8, "." ++ sect.name, name)) section_index = i;2220 if (mem.eql(u8, "." ++ sect.name, name)) section_index = i;
2221 }2221 }
2222 if (section_index == null) continue;2222 if (section_index == null) continue;
lib/std/debug/Dwarf/expression.zig+3-3
...@@ -164,7 +164,7 @@ pub fn StackMachine(comptime options: Options) type {...@@ -164,7 +164,7 @@ pub fn StackMachine(comptime options: Options) type {
164 }164 }
165165
166 fn generic(value: anytype) Operand {166 fn generic(value: anytype) Operand {
167 const int_info = @typeInfo(@TypeOf(value)).Int;167 const int_info = @typeInfo(@TypeOf(value)).int;
168 if (@sizeOf(@TypeOf(value)) > options.addr_size) {168 if (@sizeOf(@TypeOf(value)) > options.addr_size) {
169 return .{ .generic = switch (int_info.signedness) {169 return .{ .generic = switch (int_info.signedness) {
170 .signed => @bitCast(@as(addr_type_signed, @truncate(value))),170 .signed => @bitCast(@as(addr_type_signed, @truncate(value))),
...@@ -843,7 +843,7 @@ pub fn Builder(comptime options: Options) type {...@@ -843,7 +843,7 @@ pub fn Builder(comptime options: Options) type {
843 }843 }
844844
845 pub fn writeConst(writer: anytype, comptime T: type, value: T) !void {845 pub fn writeConst(writer: anytype, comptime T: type, value: T) !void {
846 if (@typeInfo(T) != .Int) @compileError("Constants must be integers");846 if (@typeInfo(T) != .int) @compileError("Constants must be integers");
847847
848 switch (T) {848 switch (T) {
849 u8, i8, u16, i16, u32, i32, u64, i64 => {849 u8, i8, u16, i16, u32, i32, u64, i64 => {
...@@ -861,7 +861,7 @@ pub fn Builder(comptime options: Options) type {...@@ -861,7 +861,7 @@ pub fn Builder(comptime options: Options) type {
861861
862 try writer.writeInt(T, value, options.endian);862 try writer.writeInt(T, value, options.endian);
863 },863 },
864 else => switch (@typeInfo(T).Int.signedness) {864 else => switch (@typeInfo(T).int.signedness) {
865 .unsigned => {865 .unsigned => {
866 try writer.writeByte(OP.constu);866 try writer.writeByte(OP.constu);
867 try leb.writeUleb128(writer, value);867 try leb.writeUleb128(writer, value);
lib/std/debug/FixedBufferReader.zig+1-1
...@@ -32,7 +32,7 @@ pub fn readByteSigned(fbr: *FixedBufferReader) Error!i8 {...@@ -32,7 +32,7 @@ pub fn readByteSigned(fbr: *FixedBufferReader) Error!i8 {
32}32}
3333
34pub fn readInt(fbr: *FixedBufferReader, comptime T: type) Error!T {34pub fn readInt(fbr: *FixedBufferReader, comptime T: type) Error!T {
35 const size = @divExact(@typeInfo(T).Int.bits, 8);35 const size = @divExact(@typeInfo(T).int.bits, 8);
36 if (fbr.buf.len - fbr.pos < size) return error.EndOfBuffer;36 if (fbr.buf.len - fbr.pos < size) return error.EndOfBuffer;
37 defer fbr.pos += size;37 defer fbr.pos += size;
38 return std.mem.readInt(T, fbr.buf[fbr.pos..][0..size], fbr.endian);38 return std.mem.readInt(T, fbr.buf[fbr.pos..][0..size], fbr.endian);
lib/std/debug/Pdb.zig+1-1
...@@ -495,7 +495,7 @@ const MsfStream = struct {...@@ -495,7 +495,7 @@ const MsfStream = struct {
495 blocks: []u32 = undefined,495 blocks: []u32 = undefined,
496 block_size: u32 = undefined,496 block_size: u32 = undefined,
497497
498 pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).Fn.return_type.?).ErrorUnion.error_set;498 pub const Error = @typeInfo(@typeInfo(@TypeOf(read)).@"fn".return_type.?).error_union.error_set;
499499
500 fn init(block_size: u32, file: File, blocks: []u32) MsfStream {500 fn init(block_size: u32, file: File, blocks: []u32) MsfStream {
501 const stream = MsfStream{501 const stream = MsfStream{
lib/std/debug/SelfInfo.zig+5-5
...@@ -37,7 +37,7 @@ modules: if (native_os == .windows) std.ArrayListUnmanaged(WindowsModule) else v...@@ -37,7 +37,7 @@ modules: if (native_os == .windows) std.ArrayListUnmanaged(WindowsModule) else v
37pub const OpenError = error{37pub const OpenError = error{
38 MissingDebugInfo,38 MissingDebugInfo,
39 UnsupportedOperatingSystem,39 UnsupportedOperatingSystem,
40} || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).Fn.return_type.?).ErrorUnion.error_set;40} || @typeInfo(@typeInfo(@TypeOf(SelfInfo.init)).@"fn".return_type.?).error_union.error_set;
4141
42pub fn open(allocator: Allocator) OpenError!SelfInfo {42pub fn open(allocator: Allocator) OpenError!SelfInfo {
43 nosuspend {43 nosuspend {
...@@ -582,7 +582,7 @@ pub const Module = switch (native_os) {...@@ -582,7 +582,7 @@ pub const Module = switch (native_os) {
582 if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue;582 if (!std.mem.eql(u8, "__DWARF", sect.segName())) continue;
583583
584 var section_index: ?usize = null;584 var section_index: ?usize = null;
585 inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| {585 inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| {
586 if (mem.eql(u8, "__" ++ section.name, sect.sectName())) section_index = i;586 if (mem.eql(u8, "__" ++ section.name, sect.sectName())) section_index = i;
587 }587 }
588 if (section_index == null) continue;588 if (section_index == null) continue;
...@@ -981,7 +981,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module {...@@ -981,7 +981,7 @@ fn readCoffDebugInfo(allocator: Allocator, coff_obj: *coff.Coff) !Module {
981 var sections: Dwarf.SectionArray = Dwarf.null_section_array;981 var sections: Dwarf.SectionArray = Dwarf.null_section_array;
982 errdefer for (sections) |section| if (section) |s| if (s.owned) allocator.free(s.data);982 errdefer for (sections) |section| if (section) |s| if (s.owned) allocator.free(s.data);
983983
984 inline for (@typeInfo(Dwarf.Section.Id).Enum.fields, 0..) |section, i| {984 inline for (@typeInfo(Dwarf.Section.Id).@"enum".fields, 0..) |section, i| {
985 sections[i] = if (coff_obj.getSectionByName("." ++ section.name)) |section_header| blk: {985 sections[i] = if (coff_obj.getSectionByName("." ++ section.name)) |section_header| blk: {
986 break :blk .{986 break :blk .{
987 .data = try coff_obj.getSectionDataAlloc(section_header, allocator),987 .data = try coff_obj.getSectionDataAlloc(section_header, allocator),
...@@ -1443,7 +1443,7 @@ pub fn unwindFrameMachO(...@@ -1443,7 +1443,7 @@ pub fn unwindFrameMachO(
1443 if (ma.load(usize, new_sp) == null or ma.load(usize, min_reg_addr) == null) return error.InvalidUnwindInfo;1443 if (ma.load(usize, new_sp) == null or ma.load(usize, min_reg_addr) == null) return error.InvalidUnwindInfo;
14441444
1445 var reg_addr = fp - @sizeOf(usize);1445 var reg_addr = fp - @sizeOf(usize);
1446 inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).Struct.fields, 0..) |field, i| {1446 inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.x_reg_pairs)).@"struct".fields, 0..) |field, i| {
1447 if (@field(encoding.value.arm64.frame.x_reg_pairs, field.name) != 0) {1447 if (@field(encoding.value.arm64.frame.x_reg_pairs, field.name) != 0) {
1448 (try regValueNative(context.thread_context, 19 + i, reg_context)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;1448 (try regValueNative(context.thread_context, 19 + i, reg_context)).* = @as(*const usize, @ptrFromInt(reg_addr)).*;
1449 reg_addr += @sizeOf(usize);1449 reg_addr += @sizeOf(usize);
...@@ -1452,7 +1452,7 @@ pub fn unwindFrameMachO(...@@ -1452,7 +1452,7 @@ pub fn unwindFrameMachO(
1452 }1452 }
1453 }1453 }
14541454
1455 inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).Struct.fields, 0..) |field, i| {1455 inline for (@typeInfo(@TypeOf(encoding.value.arm64.frame.d_reg_pairs)).@"struct".fields, 0..) |field, i| {
1456 if (@field(encoding.value.arm64.frame.d_reg_pairs, field.name) != 0) {1456 if (@field(encoding.value.arm64.frame.d_reg_pairs, field.name) != 0) {
1457 // Only the lower half of the 128-bit V registers are restored during unwinding1457 // Only the lower half of the 128-bit V registers are restored during unwinding
1458 @memcpy(1458 @memcpy(
lib/std/enums.zig+31-31
...@@ -13,9 +13,9 @@ const eval_branch_quota_cushion = 10;...@@ -13,9 +13,9 @@ const eval_branch_quota_cushion = 10;
13/// the first name is used. Each field is of type Data and has the provided13/// the first name is used. Each field is of type Data and has the provided
14/// default, which may be undefined.14/// default, which may be undefined.
15pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {15pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {
16 @setEvalBranchQuota(@typeInfo(E).Enum.fields.len + eval_branch_quota_cushion);16 @setEvalBranchQuota(@typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion);
17 var struct_fields: [@typeInfo(E).Enum.fields.len]std.builtin.Type.StructField = undefined;17 var struct_fields: [@typeInfo(E).@"enum".fields.len]std.builtin.Type.StructField = undefined;
18 for (&struct_fields, @typeInfo(E).Enum.fields) |*struct_field, enum_field| {18 for (&struct_fields, @typeInfo(E).@"enum".fields) |*struct_field, enum_field| {
19 struct_field.* = .{19 struct_field.* = .{
20 .name = enum_field.name ++ "",20 .name = enum_field.name ++ "",
21 .type = Data,21 .type = Data,
...@@ -24,7 +24,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def...@@ -24,7 +24,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
24 .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0,24 .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0,
25 };25 };
26 }26 }
27 return @Type(.{ .Struct = .{27 return @Type(.{ .@"struct" = .{
28 .layout = .auto,28 .layout = .auto,
29 .fields = &struct_fields,29 .fields = &struct_fields,
30 .decls = &.{},30 .decls = &.{},
...@@ -49,14 +49,14 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi...@@ -49,14 +49,14 @@ pub inline fn valuesFromFields(comptime E: type, comptime fields: []const EnumFi
49/// Returns the set of all named values in the given enum, in49/// Returns the set of all named values in the given enum, in
50/// declaration order.50/// declaration order.
51pub fn values(comptime E: type) []const E {51pub fn values(comptime E: type) []const E {
52 return comptime valuesFromFields(E, @typeInfo(E).Enum.fields);52 return comptime valuesFromFields(E, @typeInfo(E).@"enum".fields);
53}53}
5454
55/// A safe alternative to @tagName() for non-exhaustive enums that doesn't55/// A safe alternative to @tagName() for non-exhaustive enums that doesn't
56/// panic when `e` has no tagged value.56/// panic when `e` has no tagged value.
57/// Returns the tag name for `e` or null if no tag exists.57/// Returns the tag name for `e` or null if no tag exists.
58pub fn tagName(comptime E: type, e: E) ?[]const u8 {58pub fn tagName(comptime E: type, e: E) ?[]const u8 {
59 return inline for (@typeInfo(E).Enum.fields) |f| {59 return inline for (@typeInfo(E).@"enum".fields) |f| {
60 if (@intFromEnum(e) == f.value) break f.name;60 if (@intFromEnum(e) == f.value) break f.name;
61 } else null;61 } else null;
62}62}
...@@ -80,7 +80,7 @@ test tagName {...@@ -80,7 +80,7 @@ test tagName {
80pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_int) comptime_int {80pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_int) comptime_int {
81 var max_value: comptime_int = -1;81 var max_value: comptime_int = -1;
82 const max_usize: comptime_int = ~@as(usize, 0);82 const max_usize: comptime_int = ~@as(usize, 0);
83 const fields = @typeInfo(E).Enum.fields;83 const fields = @typeInfo(E).@"enum".fields;
84 for (fields) |f| {84 for (fields) |f| {
85 if (f.value < 0) {85 if (f.value < 0) {
86 @compileError("Cannot create a direct enum array for " ++ @typeName(E) ++ ", field ." ++ f.name ++ " has a negative value.");86 @compileError("Cannot create a direct enum array for " ++ @typeName(E) ++ ", field ." ++ f.name ++ " has a negative value.");
...@@ -159,7 +159,7 @@ pub fn directEnumArrayDefault(...@@ -159,7 +159,7 @@ pub fn directEnumArrayDefault(
159) [directEnumArrayLen(E, max_unused_slots)]Data {159) [directEnumArrayLen(E, max_unused_slots)]Data {
160 const len = comptime directEnumArrayLen(E, max_unused_slots);160 const len = comptime directEnumArrayLen(E, max_unused_slots);
161 var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;161 var result: [len]Data = if (default) |d| [_]Data{d} ** len else undefined;
162 inline for (@typeInfo(@TypeOf(init_values)).Struct.fields) |f| {162 inline for (@typeInfo(@TypeOf(init_values)).@"struct".fields) |f| {
163 const enum_value = @field(E, f.name);163 const enum_value = @field(E, f.name);
164 const index = @as(usize, @intCast(@intFromEnum(enum_value)));164 const index = @as(usize, @intCast(@intFromEnum(enum_value)));
165 result[index] = @field(init_values, f.name);165 result[index] = @field(init_values, f.name);
...@@ -204,8 +204,8 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E {...@@ -204,8 +204,8 @@ pub fn nameCast(comptime E: type, comptime value: anytype) E {
204 const V = @TypeOf(value);204 const V = @TypeOf(value);
205 if (V == E) break :blk value;205 if (V == E) break :blk value;
206 const name: ?[]const u8 = switch (@typeInfo(V)) {206 const name: ?[]const u8 = switch (@typeInfo(V)) {
207 .EnumLiteral, .Enum => @tagName(value),207 .enum_literal, .@"enum" => @tagName(value),
208 .Pointer => value,208 .pointer => value,
209 else => null,209 else => null,
210 };210 };
211 if (name) |n| {211 if (name) |n| {
...@@ -262,9 +262,9 @@ pub fn EnumSet(comptime E: type) type {...@@ -262,9 +262,9 @@ pub fn EnumSet(comptime E: type) type {
262262
263 /// Initializes the set using a struct of bools263 /// Initializes the set using a struct of bools
264 pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {264 pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self {
265 @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);265 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
266 var result: Self = .{};266 var result: Self = .{};
267 if (@typeInfo(E).Enum.is_exhaustive) {267 if (@typeInfo(E).@"enum".is_exhaustive) {
268 inline for (0..Self.len) |i| {268 inline for (0..Self.len) |i| {
269 const key = comptime Indexer.keyForIndex(i);269 const key = comptime Indexer.keyForIndex(i);
270 const tag = @tagName(key);270 const tag = @tagName(key);
...@@ -453,9 +453,9 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -453,9 +453,9 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
453453
454 /// Initializes the map using a sparse struct of optionals454 /// Initializes the map using a sparse struct of optionals
455 pub fn init(init_values: EnumFieldStruct(E, ?Value, @as(?Value, null))) Self {455 pub fn init(init_values: EnumFieldStruct(E, ?Value, @as(?Value, null))) Self {
456 @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);456 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
457 var result: Self = .{};457 var result: Self = .{};
458 if (@typeInfo(E).Enum.is_exhaustive) {458 if (@typeInfo(E).@"enum".is_exhaustive) {
459 inline for (0..Self.len) |i| {459 inline for (0..Self.len) |i| {
460 const key = comptime Indexer.keyForIndex(i);460 const key = comptime Indexer.keyForIndex(i);
461 const tag = @tagName(key);461 const tag = @tagName(key);
...@@ -497,7 +497,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {...@@ -497,7 +497,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
497 /// Initializes a full mapping with a provided default.497 /// Initializes a full mapping with a provided default.
498 /// Consider using EnumArray instead if the map will remain full.498 /// Consider using EnumArray instead if the map will remain full.
499 pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {499 pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
500 @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);500 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
501 var result: Self = .{501 var result: Self = .{
502 .bits = Self.BitSet.initFull(),502 .bits = Self.BitSet.initFull(),
503 .values = undefined,503 .values = undefined,
...@@ -683,9 +683,9 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -683,9 +683,9 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
683683
684 /// Initializes the multiset using a struct of counts.684 /// Initializes the multiset using a struct of counts.
685 pub fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self {685 pub fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self {
686 @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);686 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
687 var self = initWithCount(0);687 var self = initWithCount(0);
688 inline for (@typeInfo(E).Enum.fields) |field| {688 inline for (@typeInfo(E).@"enum".fields) |field| {
689 const c = @field(init_counts, field.name);689 const c = @field(init_counts, field.name);
690 const key = @as(E, @enumFromInt(field.value));690 const key = @as(E, @enumFromInt(field.value));
691 self.counts.set(key, c);691 self.counts.set(key, c);
...@@ -757,7 +757,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -757,7 +757,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
757 /// Increases the all key counts by given multiset. Caller757 /// Increases the all key counts by given multiset. Caller
758 /// asserts operation will not overflow any key.758 /// asserts operation will not overflow any key.
759 pub fn addSetAssertSafe(self: *Self, other: Self) void {759 pub fn addSetAssertSafe(self: *Self, other: Self) void {
760 inline for (@typeInfo(E).Enum.fields) |field| {760 inline for (@typeInfo(E).@"enum".fields) |field| {
761 const key = @as(E, @enumFromInt(field.value));761 const key = @as(E, @enumFromInt(field.value));
762 self.addAssertSafe(key, other.getCount(key));762 self.addAssertSafe(key, other.getCount(key));
763 }763 }
...@@ -765,7 +765,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -765,7 +765,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
765765
766 /// Increases the all key counts by given multiset.766 /// Increases the all key counts by given multiset.
767 pub fn addSet(self: *Self, other: Self) error{Overflow}!void {767 pub fn addSet(self: *Self, other: Self) error{Overflow}!void {
768 inline for (@typeInfo(E).Enum.fields) |field| {768 inline for (@typeInfo(E).@"enum".fields) |field| {
769 const key = @as(E, @enumFromInt(field.value));769 const key = @as(E, @enumFromInt(field.value));
770 try self.add(key, other.getCount(key));770 try self.add(key, other.getCount(key));
771 }771 }
...@@ -775,7 +775,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -775,7 +775,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
775 /// the given multiset has more key counts than this,775 /// the given multiset has more key counts than this,
776 /// then that key will have a key count of zero.776 /// then that key will have a key count of zero.
777 pub fn removeSet(self: *Self, other: Self) void {777 pub fn removeSet(self: *Self, other: Self) void {
778 inline for (@typeInfo(E).Enum.fields) |field| {778 inline for (@typeInfo(E).@"enum".fields) |field| {
779 const key = @as(E, @enumFromInt(field.value));779 const key = @as(E, @enumFromInt(field.value));
780 self.remove(key, other.getCount(key));780 self.remove(key, other.getCount(key));
781 }781 }
...@@ -784,7 +784,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -784,7 +784,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
784 /// Returns true iff all key counts are the same as784 /// Returns true iff all key counts are the same as
785 /// given multiset.785 /// given multiset.
786 pub fn eql(self: Self, other: Self) bool {786 pub fn eql(self: Self, other: Self) bool {
787 inline for (@typeInfo(E).Enum.fields) |field| {787 inline for (@typeInfo(E).@"enum".fields) |field| {
788 const key = @as(E, @enumFromInt(field.value));788 const key = @as(E, @enumFromInt(field.value));
789 if (self.getCount(key) != other.getCount(key)) {789 if (self.getCount(key) != other.getCount(key)) {
790 return false;790 return false;
...@@ -796,7 +796,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -796,7 +796,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
796 /// Returns true iff all key counts less than or796 /// Returns true iff all key counts less than or
797 /// equal to the given multiset.797 /// equal to the given multiset.
798 pub fn subsetOf(self: Self, other: Self) bool {798 pub fn subsetOf(self: Self, other: Self) bool {
799 inline for (@typeInfo(E).Enum.fields) |field| {799 inline for (@typeInfo(E).@"enum".fields) |field| {
800 const key = @as(E, @enumFromInt(field.value));800 const key = @as(E, @enumFromInt(field.value));
801 if (self.getCount(key) > other.getCount(key)) {801 if (self.getCount(key) > other.getCount(key)) {
802 return false;802 return false;
...@@ -808,7 +808,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {...@@ -808,7 +808,7 @@ pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type {
808 /// Returns true iff all key counts greater than or808 /// Returns true iff all key counts greater than or
809 /// equal to the given multiset.809 /// equal to the given multiset.
810 pub fn supersetOf(self: Self, other: Self) bool {810 pub fn supersetOf(self: Self, other: Self) bool {
811 inline for (@typeInfo(E).Enum.fields) |field| {811 inline for (@typeInfo(E).@"enum".fields) |field| {
812 const key = @as(E, @enumFromInt(field.value));812 const key = @as(E, @enumFromInt(field.value));
813 if (self.getCount(key) < other.getCount(key)) {813 if (self.getCount(key) < other.getCount(key)) {
814 return false;814 return false;
...@@ -1087,7 +1087,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {...@@ -1087,7 +1087,7 @@ pub fn EnumArray(comptime E: type, comptime V: type) type {
10871087
1088 /// Initializes values in the enum array, with the specified default.1088 /// Initializes values in the enum array, with the specified default.
1089 pub fn initDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {1089 pub fn initDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self {
1090 @setEvalBranchQuota(2 * @typeInfo(E).Enum.fields.len);1090 @setEvalBranchQuota(2 * @typeInfo(E).@"enum".fields.len);
1091 var result: Self = .{ .values = undefined };1091 var result: Self = .{ .values = undefined };
1092 inline for (0..Self.len) |i| {1092 inline for (0..Self.len) |i| {
1093 const key = comptime Indexer.keyForIndex(i);1093 const key = comptime Indexer.keyForIndex(i);
...@@ -1277,17 +1277,17 @@ test "EnumSet non-exhaustive" {...@@ -1277,17 +1277,17 @@ test "EnumSet non-exhaustive" {
1277pub fn EnumIndexer(comptime E: type) type {1277pub fn EnumIndexer(comptime E: type) type {
1278 // Assumes that the enum fields are sorted in ascending order (optimistic).1278 // Assumes that the enum fields are sorted in ascending order (optimistic).
1279 // Unsorted enums may require the user to manually increase the quota.1279 // Unsorted enums may require the user to manually increase the quota.
1280 @setEvalBranchQuota(3 * @typeInfo(E).Enum.fields.len + eval_branch_quota_cushion);1280 @setEvalBranchQuota(3 * @typeInfo(E).@"enum".fields.len + eval_branch_quota_cushion);
12811281
1282 if (!@typeInfo(E).Enum.is_exhaustive) {1282 if (!@typeInfo(E).@"enum".is_exhaustive) {
1283 const BackingInt = @typeInfo(E).Enum.tag_type;1283 const BackingInt = @typeInfo(E).@"enum".tag_type;
1284 if (@bitSizeOf(BackingInt) > @bitSizeOf(usize))1284 if (@bitSizeOf(BackingInt) > @bitSizeOf(usize))
1285 @compileError("Cannot create an enum indexer for a given non-exhaustive enum, tag_type is larger than usize.");1285 @compileError("Cannot create an enum indexer for a given non-exhaustive enum, tag_type is larger than usize.");
12861286
1287 return struct {1287 return struct {
1288 pub const Key: type = E;1288 pub const Key: type = E;
12891289
1290 const backing_int_sign = @typeInfo(BackingInt).Int.signedness;1290 const backing_int_sign = @typeInfo(BackingInt).int.signedness;
1291 const min_value = std.math.minInt(BackingInt);1291 const min_value = std.math.minInt(BackingInt);
1292 const max_value = std.math.maxInt(BackingInt);1292 const max_value = std.math.maxInt(BackingInt);
12931293
...@@ -1312,7 +1312,7 @@ pub fn EnumIndexer(comptime E: type) type {...@@ -1312,7 +1312,7 @@ pub fn EnumIndexer(comptime E: type) type {
1312 };1312 };
1313 }1313 }
13141314
1315 const const_fields = @typeInfo(E).Enum.fields;1315 const const_fields = @typeInfo(E).@"enum".fields;
1316 var fields = const_fields[0..const_fields.len].*;1316 var fields = const_fields[0..const_fields.len].*;
1317 const fields_len = fields.len;1317 const fields_len = fields.len;
13181318
...@@ -1359,7 +1359,7 @@ pub fn EnumIndexer(comptime E: type) type {...@@ -1359,7 +1359,7 @@ pub fn EnumIndexer(comptime E: type) type {
1359 // gives up some safety to avoid artificially limiting1359 // gives up some safety to avoid artificially limiting
1360 // the range of signed enum values to max_isize.1360 // the range of signed enum values to max_isize.
1361 const enum_value = if (min < 0) @as(isize, @bitCast(i)) +% min else i + min;1361 const enum_value = if (min < 0) @as(isize, @bitCast(i)) +% min else i + min;
1362 return @as(E, @enumFromInt(@as(@typeInfo(E).Enum.tag_type, @intCast(enum_value))));1362 return @as(E, @enumFromInt(@as(@typeInfo(E).@"enum".tag_type, @intCast(enum_value))));
1363 }1363 }
1364 };1364 };
1365 }1365 }
...@@ -1411,7 +1411,7 @@ test "EnumIndexer non-exhaustive" {...@@ -1411,7 +1411,7 @@ test "EnumIndexer non-exhaustive" {
14111411
1412 const RangedType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt));1412 const RangedType = std.meta.Int(.unsigned, @bitSizeOf(BackingInt));
1413 const max_index: comptime_int = std.math.maxInt(RangedType);1413 const max_index: comptime_int = std.math.maxInt(RangedType);
1414 const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).Int.signedness) {1414 const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) {
1415 .unsigned => 0,1415 .unsigned => 0,
1416 .signed => std.math.divCeil(comptime_int, max_index, 2) catch unreachable,1416 .signed => std.math.divCeil(comptime_int, max_index, 2) catch unreachable,
1417 };1417 };
lib/std/fmt.zig+38-38
...@@ -87,11 +87,11 @@ pub fn format(...@@ -87,11 +87,11 @@ pub fn format(
87) !void {87) !void {
88 const ArgsType = @TypeOf(args);88 const ArgsType = @TypeOf(args);
89 const args_type_info = @typeInfo(ArgsType);89 const args_type_info = @typeInfo(ArgsType);
90 if (args_type_info != .Struct) {90 if (args_type_info != .@"struct") {
91 @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));91 @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
92 }92 }
9393
94 const fields_info = args_type_info.Struct.fields;94 const fields_info = args_type_info.@"struct".fields;
95 if (fields_info.len > max_format_args) {95 if (fields_info.len > max_format_args) {
96 @compileError("32 arguments max are supported per format call");96 @compileError("32 arguments max are supported per format call");
97 }97 }
...@@ -397,7 +397,7 @@ pub const Parser = struct {...@@ -397,7 +397,7 @@ pub const Parser = struct {
397};397};
398398
399pub const ArgSetType = u32;399pub const ArgSetType = u32;
400const max_format_args = @typeInfo(ArgSetType).Int.bits;400const max_format_args = @typeInfo(ArgSetType).int.bits;
401401
402pub const ArgState = struct {402pub const ArgState = struct {
403 next_arg: usize = 0,403 next_arg: usize = 0,
...@@ -430,7 +430,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T...@@ -430,7 +430,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
430 const T = @TypeOf(value);430 const T = @TypeOf(value);
431431
432 switch (@typeInfo(T)) {432 switch (@typeInfo(T)) {
433 .Pointer => |info| {433 .pointer => |info| {
434 try writer.writeAll(@typeName(info.child) ++ "@");434 try writer.writeAll(@typeName(info.child) ++ "@");
435 if (info.size == .Slice)435 if (info.size == .Slice)
436 try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)436 try formatInt(@intFromPtr(value.ptr), 16, .lower, FormatOptions{}, writer)
...@@ -438,8 +438,8 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T...@@ -438,8 +438,8 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
438 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);438 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
439 return;439 return;
440 },440 },
441 .Optional => |info| {441 .optional => |info| {
442 if (@typeInfo(info.child) == .Pointer) {442 if (@typeInfo(info.child) == .pointer) {
443 try writer.writeAll(@typeName(info.child) ++ "@");443 try writer.writeAll(@typeName(info.child) ++ "@");
444 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);444 try formatInt(@intFromPtr(value), 16, .lower, FormatOptions{}, writer);
445 return;445 return;
...@@ -456,17 +456,17 @@ const ANY = "any";...@@ -456,17 +456,17 @@ const ANY = "any";
456456
457pub fn defaultSpec(comptime T: type) [:0]const u8 {457pub fn defaultSpec(comptime T: type) [:0]const u8 {
458 switch (@typeInfo(T)) {458 switch (@typeInfo(T)) {
459 .Array => |_| return ANY,459 .array => |_| return ANY,
460 .Pointer => |ptr_info| switch (ptr_info.size) {460 .pointer => |ptr_info| switch (ptr_info.size) {
461 .One => switch (@typeInfo(ptr_info.child)) {461 .One => switch (@typeInfo(ptr_info.child)) {
462 .Array => |_| return ANY,462 .array => |_| return ANY,
463 else => {},463 else => {},
464 },464 },
465 .Many, .C => return "*",465 .Many, .C => return "*",
466 .Slice => return ANY,466 .Slice => return ANY,
467 },467 },
468 .Optional => |info| return "?" ++ defaultSpec(info.child),468 .optional => |info| return "?" ++ defaultSpec(info.child),
469 .ErrorUnion => |info| return "!" ++ defaultSpec(info.payload),469 .error_union => |info| return "!" ++ defaultSpec(info.payload),
470 else => {},470 else => {},
471 }471 }
472 return "";472 return "";
...@@ -494,7 +494,7 @@ pub fn formatType(...@@ -494,7 +494,7 @@ pub fn formatType(
494 const actual_fmt = comptime if (std.mem.eql(u8, fmt, ANY))494 const actual_fmt = comptime if (std.mem.eql(u8, fmt, ANY))
495 defaultSpec(T)495 defaultSpec(T)
496 else if (fmt.len != 0 and (fmt[0] == '?' or fmt[0] == '!')) switch (@typeInfo(T)) {496 else if (fmt.len != 0 and (fmt[0] == '?' or fmt[0] == '!')) switch (@typeInfo(T)) {
497 .Optional, .ErrorUnion => fmt,497 .optional, .error_union => fmt,
498 else => stripOptionalOrErrorUnionSpec(fmt),498 else => stripOptionalOrErrorUnionSpec(fmt),
499 } else fmt;499 } else fmt;
500500
...@@ -507,18 +507,18 @@ pub fn formatType(...@@ -507,18 +507,18 @@ pub fn formatType(
507 }507 }
508508
509 switch (@typeInfo(T)) {509 switch (@typeInfo(T)) {
510 .ComptimeInt, .Int, .ComptimeFloat, .Float => {510 .comptime_int, .int, .comptime_float, .float => {
511 return formatValue(value, actual_fmt, options, writer);511 return formatValue(value, actual_fmt, options, writer);
512 },512 },
513 .Void => {513 .void => {
514 if (actual_fmt.len != 0) invalidFmtError(fmt, value);514 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
515 return formatBuf("void", options, writer);515 return formatBuf("void", options, writer);
516 },516 },
517 .Bool => {517 .bool => {
518 if (actual_fmt.len != 0) invalidFmtError(fmt, value);518 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
519 return formatBuf(if (value) "true" else "false", options, writer);519 return formatBuf(if (value) "true" else "false", options, writer);
520 },520 },
521 .Optional => {521 .optional => {
522 if (actual_fmt.len == 0 or actual_fmt[0] != '?')522 if (actual_fmt.len == 0 or actual_fmt[0] != '?')
523 @compileError("cannot format optional without a specifier (i.e. {?} or {any})");523 @compileError("cannot format optional without a specifier (i.e. {?} or {any})");
524 const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt);524 const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt);
...@@ -528,7 +528,7 @@ pub fn formatType(...@@ -528,7 +528,7 @@ pub fn formatType(
528 return formatBuf("null", options, writer);528 return formatBuf("null", options, writer);
529 }529 }
530 },530 },
531 .ErrorUnion => {531 .error_union => {
532 if (actual_fmt.len == 0 or actual_fmt[0] != '!')532 if (actual_fmt.len == 0 or actual_fmt[0] != '!')
533 @compileError("cannot format error union without a specifier (i.e. {!} or {any})");533 @compileError("cannot format error union without a specifier (i.e. {!} or {any})");
534 const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt);534 const remaining_fmt = comptime stripOptionalOrErrorUnionSpec(actual_fmt);
...@@ -538,12 +538,12 @@ pub fn formatType(...@@ -538,12 +538,12 @@ pub fn formatType(
538 return formatType(err, "", options, writer, max_depth);538 return formatType(err, "", options, writer, max_depth);
539 }539 }
540 },540 },
541 .ErrorSet => {541 .error_set => {
542 if (actual_fmt.len != 0) invalidFmtError(fmt, value);542 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
543 try writer.writeAll("error.");543 try writer.writeAll("error.");
544 return writer.writeAll(@errorName(value));544 return writer.writeAll(@errorName(value));
545 },545 },
546 .Enum => |enumInfo| {546 .@"enum" => |enumInfo| {
547 try writer.writeAll(@typeName(T));547 try writer.writeAll(@typeName(T));
548 if (enumInfo.is_exhaustive) {548 if (enumInfo.is_exhaustive) {
549 if (actual_fmt.len != 0) invalidFmtError(fmt, value);549 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
...@@ -566,7 +566,7 @@ pub fn formatType(...@@ -566,7 +566,7 @@ pub fn formatType(
566 try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth);566 try formatType(@intFromEnum(value), actual_fmt, options, writer, max_depth);
567 try writer.writeAll(")");567 try writer.writeAll(")");
568 },568 },
569 .Union => |info| {569 .@"union" => |info| {
570 if (actual_fmt.len != 0) invalidFmtError(fmt, value);570 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
571 try writer.writeAll(@typeName(T));571 try writer.writeAll(@typeName(T));
572 if (max_depth == 0) {572 if (max_depth == 0) {
...@@ -586,7 +586,7 @@ pub fn formatType(...@@ -586,7 +586,7 @@ pub fn formatType(
586 try format(writer, "@{x}", .{@intFromPtr(&value)});586 try format(writer, "@{x}", .{@intFromPtr(&value)});
587 }587 }
588 },588 },
589 .Struct => |info| {589 .@"struct" => |info| {
590 if (actual_fmt.len != 0) invalidFmtError(fmt, value);590 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
591 if (info.is_tuple) {591 if (info.is_tuple) {
592 // Skip the type and field names when formatting tuples.592 // Skip the type and field names when formatting tuples.
...@@ -621,9 +621,9 @@ pub fn formatType(...@@ -621,9 +621,9 @@ pub fn formatType(
621 }621 }
622 try writer.writeAll(" }");622 try writer.writeAll(" }");
623 },623 },
624 .Pointer => |ptr_info| switch (ptr_info.size) {624 .pointer => |ptr_info| switch (ptr_info.size) {
625 .One => switch (@typeInfo(ptr_info.child)) {625 .One => switch (@typeInfo(ptr_info.child)) {
626 .Array, .Enum, .Union, .Struct => {626 .array, .@"enum", .@"union", .@"struct" => {
627 return formatType(value.*, actual_fmt, options, writer, max_depth);627 return formatType(value.*, actual_fmt, options, writer, max_depth);
628 },628 },
629 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),629 else => return format(writer, "{s}@{x}", .{ @typeName(ptr_info.child), @intFromPtr(value) }),
...@@ -658,7 +658,7 @@ pub fn formatType(...@@ -658,7 +658,7 @@ pub fn formatType(
658 try writer.writeAll(" }");658 try writer.writeAll(" }");
659 },659 },
660 },660 },
661 .Array => |info| {661 .array => |info| {
662 if (actual_fmt.len == 0)662 if (actual_fmt.len == 0)
663 @compileError("cannot format array without a specifier (i.e. {s} or {any})");663 @compileError("cannot format array without a specifier (i.e. {s} or {any})");
664 if (max_depth == 0) {664 if (max_depth == 0) {
...@@ -676,7 +676,7 @@ pub fn formatType(...@@ -676,7 +676,7 @@ pub fn formatType(
676 }676 }
677 try writer.writeAll(" }");677 try writer.writeAll(" }");
678 },678 },
679 .Vector => |info| {679 .vector => |info| {
680 try writer.writeAll("{ ");680 try writer.writeAll("{ ");
681 var i: usize = 0;681 var i: usize = 0;
682 while (i < info.len) : (i += 1) {682 while (i < info.len) : (i += 1) {
...@@ -687,17 +687,17 @@ pub fn formatType(...@@ -687,17 +687,17 @@ pub fn formatType(
687 }687 }
688 try writer.writeAll(" }");688 try writer.writeAll(" }");
689 },689 },
690 .Fn => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"),690 .@"fn" => @compileError("unable to format function body type, use '*const " ++ @typeName(T) ++ "' for a function pointer type"),
691 .Type => {691 .type => {
692 if (actual_fmt.len != 0) invalidFmtError(fmt, value);692 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
693 return formatBuf(@typeName(value), options, writer);693 return formatBuf(@typeName(value), options, writer);
694 },694 },
695 .EnumLiteral => {695 .enum_literal => {
696 if (actual_fmt.len != 0) invalidFmtError(fmt, value);696 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
697 const buffer = [_]u8{'.'} ++ @tagName(value);697 const buffer = [_]u8{'.'} ++ @tagName(value);
698 return formatBuf(buffer, options, writer);698 return formatBuf(buffer, options, writer);
699 },699 },
700 .Null => {700 .null => {
701 if (actual_fmt.len != 0) invalidFmtError(fmt, value);701 if (actual_fmt.len != 0) invalidFmtError(fmt, value);
702 return formatBuf("null", options, writer);702 return formatBuf("null", options, writer);
703 },703 },
...@@ -713,9 +713,9 @@ fn formatValue(...@@ -713,9 +713,9 @@ fn formatValue(
713) !void {713) !void {
714 const T = @TypeOf(value);714 const T = @TypeOf(value);
715 switch (@typeInfo(T)) {715 switch (@typeInfo(T)) {
716 .Float, .ComptimeFloat => return formatFloatValue(value, fmt, options, writer),716 .float, .comptime_float => return formatFloatValue(value, fmt, options, writer),
717 .Int, .ComptimeInt => return formatIntValue(value, fmt, options, writer),717 .int, .comptime_int => return formatIntValue(value, fmt, options, writer),
718 .Bool => return formatBuf(if (value) "true" else "false", options, writer),718 .bool => return formatBuf(if (value) "true" else "false", options, writer),
719 else => comptime unreachable,719 else => comptime unreachable,
720 }720 }
721}721}
...@@ -738,13 +738,13 @@ pub fn formatIntValue(...@@ -738,13 +738,13 @@ pub fn formatIntValue(
738 base = 10;738 base = 10;
739 case = .lower;739 case = .lower;
740 } else if (comptime std.mem.eql(u8, fmt, "c")) {740 } else if (comptime std.mem.eql(u8, fmt, "c")) {
741 if (@typeInfo(@TypeOf(int_value)).Int.bits <= 8) {741 if (@typeInfo(@TypeOf(int_value)).int.bits <= 8) {
742 return formatAsciiChar(@as(u8, int_value), options, writer);742 return formatAsciiChar(@as(u8, int_value), options, writer);
743 } else {743 } else {
744 @compileError("cannot print integer that is larger than 8 bits as an ASCII character");744 @compileError("cannot print integer that is larger than 8 bits as an ASCII character");
745 }745 }
746 } else if (comptime std.mem.eql(u8, fmt, "u")) {746 } else if (comptime std.mem.eql(u8, fmt, "u")) {
747 if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) {747 if (@typeInfo(@TypeOf(int_value)).int.bits <= 21) {
748 return formatUnicodeCodepoint(@as(u21, int_value), options, writer);748 return formatUnicodeCodepoint(@as(u21, int_value), options, writer);
749 } else {749 } else {
750 @compileError("cannot print integer that is larger than 21 bits as an UTF-8 sequence");750 @compileError("cannot print integer that is larger than 21 bits as an UTF-8 sequence");
...@@ -1179,7 +1179,7 @@ pub fn formatInt(...@@ -1179,7 +1179,7 @@ pub fn formatInt(
1179 break :blk @as(Int, value);1179 break :blk @as(Int, value);
1180 } else value;1180 } else value;
11811181
1182 const value_info = @typeInfo(@TypeOf(int_value)).Int;1182 const value_info = @typeInfo(@TypeOf(int_value)).int;
11831183
1184 // The type must have the same size as `base` or be wider in order for the1184 // The type must have the same size as `base` or be wider in order for the
1185 // division to work1185 // division to work
...@@ -1480,7 +1480,7 @@ pub const ParseIntError = error{...@@ -1480,7 +1480,7 @@ pub const ParseIntError = error{
1480/// ) !void;1480/// ) !void;
1481///1481///
1482pub fn Formatter(comptime format_fn: anytype) type {1482pub fn Formatter(comptime format_fn: anytype) type {
1483 const Data = @typeInfo(@TypeOf(format_fn)).Fn.params[0].type.?;1483 const Data = @typeInfo(@TypeOf(format_fn)).@"fn".params[0].type.?;
1484 return struct {1484 return struct {
1485 data: Data,1485 data: Data,
1486 pub fn format(1486 pub fn format(
...@@ -1624,7 +1624,7 @@ fn parseIntWithSign(...@@ -1624,7 +1624,7 @@ fn parseIntWithSign(
1624 // accumulate into Accumulate which is always 8 bits or larger. this prevents1624 // accumulate into Accumulate which is always 8 bits or larger. this prevents
1625 // `buf_base` from overflowing Result.1625 // `buf_base` from overflowing Result.
1626 const info = @typeInfo(Result);1626 const info = @typeInfo(Result);
1627 const Accumulate = std.meta.Int(info.Int.signedness, @max(8, info.Int.bits));1627 const Accumulate = std.meta.Int(info.int.signedness, @max(8, info.int.bits));
1628 var accumulate: Accumulate = 0;1628 var accumulate: Accumulate = 0;
16291629
1630 if (buf_start[0] == '_' or buf_start[buf_start.len - 1] == '_') return error.InvalidCharacter;1630 if (buf_start[0] == '_' or buf_start[buf_start.len - 1] == '_') return error.InvalidCharacter;
...@@ -2724,7 +2724,7 @@ pub const hex_charset = "0123456789abcdef";...@@ -2724,7 +2724,7 @@ pub const hex_charset = "0123456789abcdef";
2724/// Converts an unsigned integer of any multiple of u8 to an array of lowercase2724/// Converts an unsigned integer of any multiple of u8 to an array of lowercase
2725/// hex bytes, little endian.2725/// hex bytes, little endian.
2726pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 {2726pub fn hex(x: anytype) [@sizeOf(@TypeOf(x)) * 2]u8 {
2727 comptime assert(@typeInfo(@TypeOf(x)).Int.signedness == .unsigned);2727 comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned);
2728 var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined;2728 var result: [@sizeOf(@TypeOf(x)) * 2]u8 = undefined;
2729 var i: usize = 0;2729 var i: usize = 0;
2730 while (i < result.len / 2) : (i += 1) {2730 while (i < result.len / 2) : (i += 1) {
lib/std/fmt/format_float.zig+6-6
...@@ -12,7 +12,7 @@ pub const min_buffer_size = 53;...@@ -12,7 +12,7 @@ pub const min_buffer_size = 53;
1212
13/// Returns the minimum buffer size needed to print every float of a specific type and format.13/// Returns the minimum buffer size needed to print every float of a specific type and format.
14pub fn bufferSize(comptime mode: Format, comptime T: type) comptime_int {14pub fn bufferSize(comptime mode: Format, comptime T: type) comptime_int {
15 comptime std.debug.assert(@typeInfo(T) == .Float);15 comptime std.debug.assert(@typeInfo(T) == .float);
16 return switch (mode) {16 return switch (mode) {
17 .scientific => 53,17 .scientific => 53,
18 // Based on minimum subnormal values.18 // Based on minimum subnormal values.
...@@ -60,8 +60,8 @@ pub fn formatFloat(buf: []u8, v_: anytype, options: FormatOptions) FormatError![...@@ -60,8 +60,8 @@ pub fn formatFloat(buf: []u8, v_: anytype, options: FormatOptions) FormatError![
60 };60 };
6161
62 const T = @TypeOf(v);62 const T = @TypeOf(v);
63 comptime std.debug.assert(@typeInfo(T) == .Float);63 comptime std.debug.assert(@typeInfo(T) == .float);
64 const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });64 const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
6565
66 const DT = if (@bitSizeOf(T) <= 64) u64 else u128;66 const DT = if (@bitSizeOf(T) <= 64) u64 else u128;
67 const tables = switch (DT) {67 const tables = switch (DT) {
...@@ -563,13 +563,13 @@ fn pow5Factor(value_: anytype) u32 {...@@ -563,13 +563,13 @@ fn pow5Factor(value_: anytype) u32 {
563563
564fn multipleOfPowerOf5(value: anytype, p: u32) bool {564fn multipleOfPowerOf5(value: anytype, p: u32) bool {
565 const T = @TypeOf(value);565 const T = @TypeOf(value);
566 std.debug.assert(@typeInfo(T) == .Int);566 std.debug.assert(@typeInfo(T) == .int);
567 return pow5Factor(value) >= p;567 return pow5Factor(value) >= p;
568}568}
569569
570fn multipleOfPowerOf2(value: anytype, p: u32) bool {570fn multipleOfPowerOf2(value: anytype, p: u32) bool {
571 const T = @TypeOf(value);571 const T = @TypeOf(value);
572 std.debug.assert(@typeInfo(T) == .Int);572 std.debug.assert(@typeInfo(T) == .int);
573 return (value & ((@as(T, 1) << @as(std.math.Log2Int(T), @intCast(p))) - 1)) == 0;573 return (value & ((@as(T, 1) << @as(std.math.Log2Int(T), @intCast(p))) - 1)) == 0;
574}574}
575575
...@@ -1516,7 +1516,7 @@ const FLOAT128_POW5_INV_ERRORS: [154]u64 = .{...@@ -1516,7 +1516,7 @@ const FLOAT128_POW5_INV_ERRORS: [154]u64 = .{
1516const builtin = @import("builtin");1516const builtin = @import("builtin");
15171517
1518fn check(comptime T: type, value: T, comptime expected: []const u8) !void {1518fn check(comptime T: type, value: T, comptime expected: []const u8) !void {
1519 const I = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });1519 const I = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
15201520
1521 var buf: [6000]u8 = undefined;1521 var buf: [6000]u8 = undefined;
1522 const value_bits: I = @bitCast(value);1522 const value_bits: I = @bitCast(value);
lib/std/fmt/parse_float.zig+2-2
...@@ -17,7 +17,7 @@ pub const ParseFloatError = error{...@@ -17,7 +17,7 @@ pub const ParseFloatError = error{
17};17};
1818
19pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T {19pub fn parseFloat(comptime T: type, s: []const u8) ParseFloatError!T {
20 if (@typeInfo(T) != .Float) {20 if (@typeInfo(T) != .float) {
21 @compileError("Cannot parse a float into a non-floating point type.");21 @compileError("Cannot parse a float into a non-floating point type.");
22 }22 }
2323
...@@ -128,7 +128,7 @@ test parseFloat {...@@ -128,7 +128,7 @@ test parseFloat {
128128
129test "nan and inf" {129test "nan and inf" {
130 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {130 inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| {
131 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);131 const Z = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
132132
133 try expectEqual(@as(Z, @bitCast(try parseFloat(T, "nAn"))), @as(Z, @bitCast(std.math.nan(T))));133 try expectEqual(@as(Z, @bitCast(try parseFloat(T, "nAn"))), @as(Z, @bitCast(std.math.nan(T))));
134 try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));134 try expectEqual(try parseFloat(T, "inF"), std.math.inf(T));
lib/std/hash/auto_hash.zig+28-28
...@@ -22,7 +22,7 @@ pub const HashStrategy = enum {...@@ -22,7 +22,7 @@ pub const HashStrategy = enum {
22pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {22pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
23 const info = @typeInfo(@TypeOf(key));23 const info = @typeInfo(@TypeOf(key));
2424
25 switch (info.Pointer.size) {25 switch (info.pointer.size) {
26 .One => switch (strat) {26 .One => switch (strat) {
27 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),27 .Shallow => hash(hasher, @intFromPtr(key), .Shallow),
28 .Deep => hash(hasher, key.*, .Shallow),28 .Deep => hash(hasher, key.*, .Shallow),
...@@ -64,7 +64,7 @@ pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) vo...@@ -64,7 +64,7 @@ pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) vo
64pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {64pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
65 const Key = @TypeOf(key);65 const Key = @TypeOf(key);
66 const Hasher = switch (@typeInfo(@TypeOf(hasher))) {66 const Hasher = switch (@typeInfo(@TypeOf(hasher))) {
67 .Pointer => |ptr| ptr.child,67 .pointer => |ptr| ptr.child,
68 else => @TypeOf(hasher),68 else => @TypeOf(hasher),
69 };69 };
7070
...@@ -74,24 +74,24 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -74,24 +74,24 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
74 }74 }
7575
76 switch (@typeInfo(Key)) {76 switch (@typeInfo(Key)) {
77 .NoReturn,77 .noreturn,
78 .Opaque,78 .@"opaque",
79 .Undefined,79 .undefined,
80 .Null,80 .null,
81 .ComptimeFloat,81 .comptime_float,
82 .ComptimeInt,82 .comptime_int,
83 .Type,83 .type,
84 .EnumLiteral,84 .enum_literal,
85 .Frame,85 .frame,
86 .Float,86 .float,
87 => @compileError("unable to hash type " ++ @typeName(Key)),87 => @compileError("unable to hash type " ++ @typeName(Key)),
8888
89 .Void => return,89 .void => return,
9090
91 // Help the optimizer see that hashing an int is easy by inlining!91 // Help the optimizer see that hashing an int is easy by inlining!
92 // TODO Check if the situation is better after #561 is resolved.92 // TODO Check if the situation is better after #561 is resolved.
93 .Int => |int| switch (int.signedness) {93 .int => |int| switch (int.signedness) {
94 .signed => hash(hasher, @as(@Type(.{ .Int = .{94 .signed => hash(hasher, @as(@Type(.{ .int = .{
95 .bits = int.bits,95 .bits = int.bits,
96 .signedness = .unsigned,96 .signedness = .unsigned,
97 } }), @bitCast(key)), strat),97 } }), @bitCast(key)), strat),
...@@ -107,18 +107,18 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -107,18 +107,18 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
107 },107 },
108 },108 },
109109
110 .Bool => hash(hasher, @intFromBool(key), strat),110 .bool => hash(hasher, @intFromBool(key), strat),
111 .Enum => hash(hasher, @intFromEnum(key), strat),111 .@"enum" => hash(hasher, @intFromEnum(key), strat),
112 .ErrorSet => hash(hasher, @intFromError(key), strat),112 .error_set => hash(hasher, @intFromError(key), strat),
113 .AnyFrame, .Fn => hash(hasher, @intFromPtr(key), strat),113 .@"anyframe", .@"fn" => hash(hasher, @intFromPtr(key), strat),
114114
115 .Pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }),115 .pointer => @call(.always_inline, hashPointer, .{ hasher, key, strat }),
116116
117 .Optional => if (key) |k| hash(hasher, k, strat),117 .optional => if (key) |k| hash(hasher, k, strat),
118118
119 .Array => hashArray(hasher, key, strat),119 .array => hashArray(hasher, key, strat),
120120
121 .Vector => |info| {121 .vector => |info| {
122 if (std.meta.hasUniqueRepresentation(Key)) {122 if (std.meta.hasUniqueRepresentation(Key)) {
123 hasher.update(mem.asBytes(&key));123 hasher.update(mem.asBytes(&key));
124 } else {124 } else {
...@@ -129,7 +129,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -129,7 +129,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
129 }129 }
130 },130 },
131131
132 .Struct => |info| {132 .@"struct" => |info| {
133 inline for (info.fields) |field| {133 inline for (info.fields) |field| {
134 // We reuse the hash of the previous field as the seed for the134 // We reuse the hash of the previous field as the seed for the
135 // next one so that they're dependant.135 // next one so that they're dependant.
...@@ -137,7 +137,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -137,7 +137,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
137 }137 }
138 },138 },
139139
140 .Union => |info| {140 .@"union" => |info| {
141 if (info.tag_type) |tag_type| {141 if (info.tag_type) |tag_type| {
142 const tag = std.meta.activeTag(key);142 const tag = std.meta.activeTag(key);
143 hash(hasher, tag, strat);143 hash(hasher, tag, strat);
...@@ -155,7 +155,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -155,7 +155,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
155 } else @compileError("cannot hash untagged union type: " ++ @typeName(Key) ++ ", provide your own hash function");155 } else @compileError("cannot hash untagged union type: " ++ @typeName(Key) ++ ", provide your own hash function");
156 },156 },
157157
158 .ErrorUnion => blk: {158 .error_union => blk: {
159 const payload = key catch |err| {159 const payload = key catch |err| {
160 hash(hasher, err, strat);160 hash(hasher, err, strat);
161 break :blk;161 break :blk;
...@@ -167,9 +167,9 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -167,9 +167,9 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
167167
168inline fn typeContainsSlice(comptime K: type) bool {168inline fn typeContainsSlice(comptime K: type) bool {
169 return switch (@typeInfo(K)) {169 return switch (@typeInfo(K)) {
170 .Pointer => |info| info.size == .Slice,170 .pointer => |info| info.size == .Slice,
171171
172 inline .Struct, .Union => |info| {172 inline .@"struct", .@"union" => |info| {
173 inline for (info.fields) |field| {173 inline for (info.fields) |field| {
174 if (typeContainsSlice(field.type)) {174 if (typeContainsSlice(field.type)) {
175 return true;175 return true;
lib/std/hash/verify.zig+5-5
...@@ -1,9 +1,9 @@...@@ -1,9 +1,9 @@
1const std = @import("std");1const std = @import("std");
22
3fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).Fn.return_type.? {3fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typeInfo(@TypeOf(hash_fn)).@"fn".return_type.? {
4 const HashFn = @typeInfo(@TypeOf(hash_fn)).Fn;4 const HashFn = @typeInfo(@TypeOf(hash_fn)).@"fn";
5 if (HashFn.params.len > 1) {5 if (HashFn.params.len > 1) {
6 if (@typeInfo(HashFn.params[0].type.?) == .Int) {6 if (@typeInfo(HashFn.params[0].type.?) == .int) {
7 return hash_fn(@intCast(seed), buf);7 return hash_fn(@intCast(seed), buf);
8 } else {8 } else {
9 return hash_fn(buf, @intCast(seed));9 return hash_fn(buf, @intCast(seed));
...@@ -14,7 +14,7 @@ fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typ...@@ -14,7 +14,7 @@ fn hashMaybeSeed(comptime hash_fn: anytype, seed: anytype, buf: []const u8) @typ
14}14}
1515
16fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash {16fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash {
17 const HashFn = @typeInfo(@TypeOf(Hash.init)).Fn;17 const HashFn = @typeInfo(@TypeOf(Hash.init)).@"fn";
18 if (HashFn.params.len == 1) {18 if (HashFn.params.len == 1) {
19 return Hash.init(@intCast(seed));19 return Hash.init(@intCast(seed));
20 } else {20 } else {
...@@ -27,7 +27,7 @@ fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash {...@@ -27,7 +27,7 @@ fn initMaybeSeed(comptime Hash: anytype, seed: anytype) Hash {
27// Hash keys of the form {0}, {0,1}, {0,1,2}... up to N=255, using 256-N as seed.27// Hash keys of the form {0}, {0,1}, {0,1,2}... up to N=255, using 256-N as seed.
28// First four-bytes of the hash, interpreted as little-endian is the verification code.28// First four-bytes of the hash, interpreted as little-endian is the verification code.
29pub fn smhasher(comptime hash_fn: anytype) u32 {29pub fn smhasher(comptime hash_fn: anytype) u32 {
30 const HashFnTy = @typeInfo(@TypeOf(hash_fn)).Fn;30 const HashFnTy = @typeInfo(@TypeOf(hash_fn)).@"fn";
31 const HashResult = HashFnTy.return_type.?;31 const HashResult = HashFnTy.return_type.?;
32 const hash_size = @sizeOf(HashResult);32 const hash_size = @sizeOf(HashResult);
3333
lib/std/hash_map.zig+11-11
...@@ -139,10 +139,10 @@ pub fn verifyContext(...@@ -139,10 +139,10 @@ pub fn verifyContext(
139 var Context = RawContext;139 var Context = RawContext;
140 // Make sure the context is a namespace type which may have member functions140 // Make sure the context is a namespace type which may have member functions
141 switch (@typeInfo(Context)) {141 switch (@typeInfo(Context)) {
142 .Struct, .Union, .Enum => {},142 .@"struct", .@"union", .@"enum" => {},
143 // Special-case .Opaque for a better error message143 // Special-case .@"opaque" for a better error message
144 .Opaque => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."),144 .@"opaque" => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is opaque. Use a pointer instead."),
145 .Pointer => |ptr| {145 .pointer => |ptr| {
146 if (ptr.size != .One) {146 if (ptr.size != .One) {
147 @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is not a single pointer.");147 @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context) ++ " because it is not a single pointer.");
148 }148 }
...@@ -150,7 +150,7 @@ pub fn verifyContext(...@@ -150,7 +150,7 @@ pub fn verifyContext(
150 allow_const_ptr = true;150 allow_const_ptr = true;
151 allow_mutable_ptr = !ptr.is_const;151 allow_mutable_ptr = !ptr.is_const;
152 switch (@typeInfo(Context)) {152 switch (@typeInfo(Context)) {
153 .Struct, .Union, .Enum, .Opaque => {},153 .@"struct", .@"union", .@"enum", .@"opaque" => {},
154 else => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context)),154 else => @compileError("Hash context must be a type with hash and eql member functions. Cannot use " ++ @typeName(Context)),
155 }155 }
156 },156 },
...@@ -179,8 +179,8 @@ pub fn verifyContext(...@@ -179,8 +179,8 @@ pub fn verifyContext(
179 if (@hasDecl(Context, "hash")) {179 if (@hasDecl(Context, "hash")) {
180 const hash = Context.hash;180 const hash = Context.hash;
181 const info = @typeInfo(@TypeOf(hash));181 const info = @typeInfo(@TypeOf(hash));
182 if (info == .Fn) {182 if (info == .@"fn") {
183 const func = info.Fn;183 const func = info.@"fn";
184 if (func.params.len != 2) {184 if (func.params.len != 2) {
185 errors = errors ++ lazy.err_invalid_hash_signature;185 errors = errors ++ lazy.err_invalid_hash_signature;
186 } else {186 } else {
...@@ -255,8 +255,8 @@ pub fn verifyContext(...@@ -255,8 +255,8 @@ pub fn verifyContext(
255 if (@hasDecl(Context, "eql")) {255 if (@hasDecl(Context, "eql")) {
256 const eql = Context.eql;256 const eql = Context.eql;
257 const info = @typeInfo(@TypeOf(eql));257 const info = @typeInfo(@TypeOf(eql));
258 if (info == .Fn) {258 if (info == .@"fn") {
259 const func = info.Fn;259 const func = info.@"fn";
260 const args_len = if (is_array) 4 else 3;260 const args_len = if (is_array) 4 else 3;
261 if (func.params.len != args_len) {261 if (func.params.len != args_len) {
262 errors = errors ++ lazy.err_invalid_eql_signature;262 errors = errors ++ lazy.err_invalid_eql_signature;
...@@ -824,8 +824,8 @@ pub fn HashMapUnmanaged(...@@ -824,8 +824,8 @@ pub fn HashMapUnmanaged(
824 }824 }
825825
826 pub fn takeFingerprint(hash: Hash) FingerPrint {826 pub fn takeFingerprint(hash: Hash) FingerPrint {
827 const hash_bits = @typeInfo(Hash).Int.bits;827 const hash_bits = @typeInfo(Hash).int.bits;
828 const fp_bits = @typeInfo(FingerPrint).Int.bits;828 const fp_bits = @typeInfo(FingerPrint).int.bits;
829 return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits)));829 return @as(FingerPrint, @truncate(hash >> (hash_bits - fp_bits)));
830 }830 }
831831
lib/std/heap/logging_allocator.zig+1-1
...@@ -15,7 +15,7 @@ pub fn LoggingAllocator(...@@ -15,7 +15,7 @@ pub fn LoggingAllocator(
15/// with the given scope on every call to the allocator.15/// with the given scope on every call to the allocator.
16/// For logging to a `std.io.Writer` see `std.heap.LogToWriterAllocator`16/// For logging to a `std.io.Writer` see `std.heap.LogToWriterAllocator`
17pub fn ScopedLoggingAllocator(17pub fn ScopedLoggingAllocator(
18 comptime scope: @Type(.EnumLiteral),18 comptime scope: @Type(.enum_literal),
19 comptime success_log_level: std.log.Level,19 comptime success_log_level: std.log.Level,
20 comptime failure_log_level: std.log.Level,20 comptime failure_log_level: std.log.Level,
21) type {21) type {
lib/std/io.zig+4-4
...@@ -434,7 +434,7 @@ pub fn poll(...@@ -434,7 +434,7 @@ pub fn poll(
434 comptime StreamEnum: type,434 comptime StreamEnum: type,
435 files: PollFiles(StreamEnum),435 files: PollFiles(StreamEnum),
436) Poller(StreamEnum) {436) Poller(StreamEnum) {
437 const enum_fields = @typeInfo(StreamEnum).Enum.fields;437 const enum_fields = @typeInfo(StreamEnum).@"enum".fields;
438 var result: Poller(StreamEnum) = undefined;438 var result: Poller(StreamEnum) = undefined;
439439
440 if (is_windows) result.windows = .{440 if (is_windows) result.windows = .{
...@@ -473,7 +473,7 @@ pub const PollFifo = std.fifo.LinearFifo(u8, .Dynamic);...@@ -473,7 +473,7 @@ pub const PollFifo = std.fifo.LinearFifo(u8, .Dynamic);
473473
474pub fn Poller(comptime StreamEnum: type) type {474pub fn Poller(comptime StreamEnum: type) type {
475 return struct {475 return struct {
476 const enum_fields = @typeInfo(StreamEnum).Enum.fields;476 const enum_fields = @typeInfo(StreamEnum).@"enum".fields;
477 const PollFd = if (is_windows) void else posix.pollfd;477 const PollFd = if (is_windows) void else posix.pollfd;
478478
479 fifos: [enum_fields.len]PollFifo,479 fifos: [enum_fields.len]PollFifo,
...@@ -676,7 +676,7 @@ fn windowsAsyncRead(...@@ -676,7 +676,7 @@ fn windowsAsyncRead(
676/// Given an enum, returns a struct with fields of that enum, each field676/// Given an enum, returns a struct with fields of that enum, each field
677/// representing an I/O stream for polling.677/// representing an I/O stream for polling.
678pub fn PollFiles(comptime StreamEnum: type) type {678pub fn PollFiles(comptime StreamEnum: type) type {
679 const enum_fields = @typeInfo(StreamEnum).Enum.fields;679 const enum_fields = @typeInfo(StreamEnum).@"enum".fields;
680 var struct_fields: [enum_fields.len]std.builtin.Type.StructField = undefined;680 var struct_fields: [enum_fields.len]std.builtin.Type.StructField = undefined;
681 for (&struct_fields, enum_fields) |*struct_field, enum_field| {681 for (&struct_fields, enum_fields) |*struct_field, enum_field| {
682 struct_field.* = .{682 struct_field.* = .{
...@@ -687,7 +687,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {...@@ -687,7 +687,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {
687 .alignment = @alignOf(fs.File),687 .alignment = @alignOf(fs.File),
688 };688 };
689 }689 }
690 return @Type(.{ .Struct = .{690 return @Type(.{ .@"struct" = .{
691 .layout = .auto,691 .layout = .auto,
692 .fields = &struct_fields,692 .fields = &struct_fields,
693 .decls = &.{},693 .decls = &.{},
lib/std/io/Reader.zig+3-3
...@@ -277,7 +277,7 @@ pub fn readBoundedBytes(self: Self, comptime num_bytes: usize) anyerror!std.Boun...@@ -277,7 +277,7 @@ pub fn readBoundedBytes(self: Self, comptime num_bytes: usize) anyerror!std.Boun
277}277}
278278
279pub inline fn readInt(self: Self, comptime T: type, endian: std.builtin.Endian) anyerror!T {279pub inline fn readInt(self: Self, comptime T: type, endian: std.builtin.Endian) anyerror!T {
280 const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).Int.bits, 8));280 const bytes = try self.readBytesNoEof(@divExact(@typeInfo(T).int.bits, 8));
281 return mem.readInt(T, &bytes, endian);281 return mem.readInt(T, &bytes, endian);
282}282}
283283
...@@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {...@@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {
326326
327pub fn readStruct(self: Self, comptime T: type) anyerror!T {327pub fn readStruct(self: Self, comptime T: type) anyerror!T {
328 // Only extern and packed structs have defined in-memory layout.328 // Only extern and packed structs have defined in-memory layout.
329 comptime assert(@typeInfo(T).Struct.layout != .auto);329 comptime assert(@typeInfo(T).@"struct".layout != .auto);
330 var res: [1]T = undefined;330 var res: [1]T = undefined;
331 try self.readNoEof(mem.sliceAsBytes(res[0..]));331 try self.readNoEof(mem.sliceAsBytes(res[0..]));
332 return res[0];332 return res[0];
...@@ -348,7 +348,7 @@ pub fn readEnum(self: Self, comptime Enum: type, endian: std.builtin.Endian) any...@@ -348,7 +348,7 @@ pub fn readEnum(self: Self, comptime Enum: type, endian: std.builtin.Endian) any
348 /// An integer was read, but it did not match any of the tags in the supplied enum.348 /// An integer was read, but it did not match any of the tags in the supplied enum.
349 InvalidValue,349 InvalidValue,
350 };350 };
351 const type_info = @typeInfo(Enum).Enum;351 const type_info = @typeInfo(Enum).@"enum";
352 const tag = try self.readInt(type_info.tag_type, endian);352 const tag = try self.readInt(type_info.tag_type, endian);
353353
354 inline for (std.meta.fields(Enum)) |field| {354 inline for (std.meta.fields(Enum)) |field| {
lib/std/io/Writer.zig+2-2
...@@ -49,14 +49,14 @@ pub fn writeBytesNTimes(self: Self, bytes: []const u8, n: usize) anyerror!void {...@@ -49,14 +49,14 @@ pub fn writeBytesNTimes(self: Self, bytes: []const u8, n: usize) anyerror!void {
49}49}
5050
51pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.builtin.Endian) anyerror!void {51pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.builtin.Endian) anyerror!void {
52 var bytes: [@divExact(@typeInfo(T).Int.bits, 8)]u8 = undefined;52 var bytes: [@divExact(@typeInfo(T).int.bits, 8)]u8 = undefined;
53 mem.writeInt(std.math.ByteAlignedInt(@TypeOf(value)), &bytes, value, endian);53 mem.writeInt(std.math.ByteAlignedInt(@TypeOf(value)), &bytes, value, endian);
54 return self.writeAll(&bytes);54 return self.writeAll(&bytes);
55}55}
5656
57pub fn writeStruct(self: Self, value: anytype) anyerror!void {57pub fn writeStruct(self: Self, value: anytype) anyerror!void {
58 // Only extern and packed structs have defined in-memory layout.58 // Only extern and packed structs have defined in-memory layout.
59 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto);59 comptime assert(@typeInfo(@TypeOf(value)).@"struct".layout != .auto);
60 return self.writeAll(mem.asBytes(&value));60 return self.writeAll(mem.asBytes(&value));
61}61}
6262
lib/std/io/bit_writer.zig+1-1
...@@ -33,7 +33,7 @@ pub fn BitWriter(comptime endian: std.builtin.Endian, comptime WriterType: type)...@@ -33,7 +33,7 @@ pub fn BitWriter(comptime endian: std.builtin.Endian, comptime WriterType: type)
33 if (bits == 0) return;33 if (bits == 0) return;
3434
35 const U = @TypeOf(value);35 const U = @TypeOf(value);
36 comptime assert(@typeInfo(U).Int.signedness == .unsigned);36 comptime assert(@typeInfo(U).int.signedness == .unsigned);
3737
38 //by extending the buffer to a minimum of u8 we can cover a number of edge cases38 //by extending the buffer to a minimum of u8 we can cover a number of edge cases
39 // related to shifting and casting.39 // related to shifting and casting.
lib/std/io/fixed_buffer_stream.zig+3-3
...@@ -115,18 +115,18 @@ pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer...@@ -115,18 +115,18 @@ pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(Slice(@TypeOf(buffer
115115
116fn Slice(comptime T: type) type {116fn Slice(comptime T: type) type {
117 switch (@typeInfo(T)) {117 switch (@typeInfo(T)) {
118 .Pointer => |ptr_info| {118 .pointer => |ptr_info| {
119 var new_ptr_info = ptr_info;119 var new_ptr_info = ptr_info;
120 switch (ptr_info.size) {120 switch (ptr_info.size) {
121 .Slice => {},121 .Slice => {},
122 .One => switch (@typeInfo(ptr_info.child)) {122 .One => switch (@typeInfo(ptr_info.child)) {
123 .Array => |info| new_ptr_info.child = info.child,123 .array => |info| new_ptr_info.child = info.child,
124 else => @compileError("invalid type given to fixedBufferStream"),124 else => @compileError("invalid type given to fixedBufferStream"),
125 },125 },
126 else => @compileError("invalid type given to fixedBufferStream"),126 else => @compileError("invalid type given to fixedBufferStream"),
127 }127 }
128 new_ptr_info.size = .Slice;128 new_ptr_info.size = .Slice;
129 return @Type(.{ .Pointer = new_ptr_info });129 return @Type(.{ .pointer = new_ptr_info });
130 },130 },
131 else => @compileError("invalid type given to fixedBufferStream"),131 else => @compileError("invalid type given to fixedBufferStream"),
132 }132 }
lib/std/io/multi_writer.zig+1-1
...@@ -4,7 +4,7 @@ const io = std.io;...@@ -4,7 +4,7 @@ const io = std.io;
4/// Takes a tuple of streams, and constructs a new stream that writes to all of them4/// Takes a tuple of streams, and constructs a new stream that writes to all of them
5pub fn MultiWriter(comptime Writers: type) type {5pub fn MultiWriter(comptime Writers: type) type {
6 comptime var ErrSet = error{};6 comptime var ErrSet = error{};
7 inline for (@typeInfo(Writers).Struct.fields) |field| {7 inline for (@typeInfo(Writers).@"struct".fields) |field| {
8 const StreamType = field.type;8 const StreamType = field.type;
9 ErrSet = ErrSet || StreamType.Error;9 ErrSet = ErrSet || StreamType.Error;
10 }10 }
lib/std/io/tty.zig+1-1
...@@ -75,7 +75,7 @@ pub const Config = union(enum) {...@@ -75,7 +75,7 @@ pub const Config = union(enum) {
75 conf: Config,75 conf: Config,
76 writer: anytype,76 writer: anytype,
77 color: Color,77 color: Color,
78 ) (@typeInfo(@TypeOf(writer.writeAll(""))).ErrorUnion.error_set ||78 ) (@typeInfo(@TypeOf(writer.writeAll(""))).error_union.error_set ||
79 windows.SetConsoleTextAttributeError)!void {79 windows.SetConsoleTextAttributeError)!void {
80 nosuspend switch (conf) {80 nosuspend switch (conf) {
81 .no_color => return,81 .no_color => return,
lib/std/json/static.zig+23-23
...@@ -219,14 +219,14 @@ pub fn innerParse(...@@ -219,14 +219,14 @@ pub fn innerParse(
219 options: ParseOptions,219 options: ParseOptions,
220) ParseError(@TypeOf(source.*))!T {220) ParseError(@TypeOf(source.*))!T {
221 switch (@typeInfo(T)) {221 switch (@typeInfo(T)) {
222 .Bool => {222 .bool => {
223 return switch (try source.next()) {223 return switch (try source.next()) {
224 .true => true,224 .true => true,
225 .false => false,225 .false => false,
226 else => error.UnexpectedToken,226 else => error.UnexpectedToken,
227 };227 };
228 },228 },
229 .Float, .ComptimeFloat => {229 .float, .comptime_float => {
230 const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);230 const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
231 defer freeAllocated(allocator, token);231 defer freeAllocated(allocator, token);
232 const slice = switch (token) {232 const slice = switch (token) {
...@@ -235,7 +235,7 @@ pub fn innerParse(...@@ -235,7 +235,7 @@ pub fn innerParse(
235 };235 };
236 return try std.fmt.parseFloat(T, slice);236 return try std.fmt.parseFloat(T, slice);
237 },237 },
238 .Int, .ComptimeInt => {238 .int, .comptime_int => {
239 const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);239 const token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
240 defer freeAllocated(allocator, token);240 defer freeAllocated(allocator, token);
241 const slice = switch (token) {241 const slice = switch (token) {
...@@ -244,7 +244,7 @@ pub fn innerParse(...@@ -244,7 +244,7 @@ pub fn innerParse(
244 };244 };
245 return sliceToInt(T, slice);245 return sliceToInt(T, slice);
246 },246 },
247 .Optional => |optionalInfo| {247 .optional => |optionalInfo| {
248 switch (try source.peekNextTokenType()) {248 switch (try source.peekNextTokenType()) {
249 .null => {249 .null => {
250 _ = try source.next();250 _ = try source.next();
...@@ -255,7 +255,7 @@ pub fn innerParse(...@@ -255,7 +255,7 @@ pub fn innerParse(
255 },255 },
256 }256 }
257 },257 },
258 .Enum => {258 .@"enum" => {
259 if (std.meta.hasFn(T, "jsonParse")) {259 if (std.meta.hasFn(T, "jsonParse")) {
260 return T.jsonParse(allocator, source, options);260 return T.jsonParse(allocator, source, options);
261 }261 }
...@@ -268,7 +268,7 @@ pub fn innerParse(...@@ -268,7 +268,7 @@ pub fn innerParse(
268 };268 };
269 return sliceToEnum(T, slice);269 return sliceToEnum(T, slice);
270 },270 },
271 .Union => |unionInfo| {271 .@"union" => |unionInfo| {
272 if (std.meta.hasFn(T, "jsonParse")) {272 if (std.meta.hasFn(T, "jsonParse")) {
273 return T.jsonParse(allocator, source, options);273 return T.jsonParse(allocator, source, options);
274 }274 }
...@@ -313,7 +313,7 @@ pub fn innerParse(...@@ -313,7 +313,7 @@ pub fn innerParse(
313 return result.?;313 return result.?;
314 },314 },
315315
316 .Struct => |structInfo| {316 .@"struct" => |structInfo| {
317 if (structInfo.is_tuple) {317 if (structInfo.is_tuple) {
318 if (.array_begin != try source.next()) return error.UnexpectedToken;318 if (.array_begin != try source.next()) return error.UnexpectedToken;
319319
...@@ -385,7 +385,7 @@ pub fn innerParse(...@@ -385,7 +385,7 @@ pub fn innerParse(
385 return r;385 return r;
386 },386 },
387387
388 .Array => |arrayInfo| {388 .array => |arrayInfo| {
389 switch (try source.peekNextTokenType()) {389 switch (try source.peekNextTokenType()) {
390 .array_begin => {390 .array_begin => {
391 // Typical array.391 // Typical array.
...@@ -440,7 +440,7 @@ pub fn innerParse(...@@ -440,7 +440,7 @@ pub fn innerParse(
440 }440 }
441 },441 },
442442
443 .Vector => |vecInfo| {443 .vector => |vecInfo| {
444 switch (try source.peekNextTokenType()) {444 switch (try source.peekNextTokenType()) {
445 .array_begin => {445 .array_begin => {
446 return internalParseArray(T, vecInfo.child, vecInfo.len, allocator, source, options);446 return internalParseArray(T, vecInfo.child, vecInfo.len, allocator, source, options);
...@@ -449,7 +449,7 @@ pub fn innerParse(...@@ -449,7 +449,7 @@ pub fn innerParse(
449 }449 }
450 },450 },
451451
452 .Pointer => |ptrInfo| {452 .pointer => |ptrInfo| {
453 switch (ptrInfo.size) {453 switch (ptrInfo.size) {
454 .One => {454 .One => {
455 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);455 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
...@@ -550,13 +550,13 @@ pub fn innerParseFromValue(...@@ -550,13 +550,13 @@ pub fn innerParseFromValue(
550 options: ParseOptions,550 options: ParseOptions,
551) ParseFromValueError!T {551) ParseFromValueError!T {
552 switch (@typeInfo(T)) {552 switch (@typeInfo(T)) {
553 .Bool => {553 .bool => {
554 switch (source) {554 switch (source) {
555 .bool => |b| return b,555 .bool => |b| return b,
556 else => return error.UnexpectedToken,556 else => return error.UnexpectedToken,
557 }557 }
558 },558 },
559 .Float, .ComptimeFloat => {559 .float, .comptime_float => {
560 switch (source) {560 switch (source) {
561 .float => |f| return @as(T, @floatCast(f)),561 .float => |f| return @as(T, @floatCast(f)),
562 .integer => |i| return @as(T, @floatFromInt(i)),562 .integer => |i| return @as(T, @floatFromInt(i)),
...@@ -564,7 +564,7 @@ pub fn innerParseFromValue(...@@ -564,7 +564,7 @@ pub fn innerParseFromValue(
564 else => return error.UnexpectedToken,564 else => return error.UnexpectedToken,
565 }565 }
566 },566 },
567 .Int, .ComptimeInt => {567 .int, .comptime_int => {
568 switch (source) {568 switch (source) {
569 .float => |f| {569 .float => |f| {
570 if (@round(f) != f) return error.InvalidNumber;570 if (@round(f) != f) return error.InvalidNumber;
...@@ -583,13 +583,13 @@ pub fn innerParseFromValue(...@@ -583,13 +583,13 @@ pub fn innerParseFromValue(
583 else => return error.UnexpectedToken,583 else => return error.UnexpectedToken,
584 }584 }
585 },585 },
586 .Optional => |optionalInfo| {586 .optional => |optionalInfo| {
587 switch (source) {587 switch (source) {
588 .null => return null,588 .null => return null,
589 else => return try innerParseFromValue(optionalInfo.child, allocator, source, options),589 else => return try innerParseFromValue(optionalInfo.child, allocator, source, options),
590 }590 }
591 },591 },
592 .Enum => {592 .@"enum" => {
593 if (std.meta.hasFn(T, "jsonParseFromValue")) {593 if (std.meta.hasFn(T, "jsonParseFromValue")) {
594 return T.jsonParseFromValue(allocator, source, options);594 return T.jsonParseFromValue(allocator, source, options);
595 }595 }
...@@ -601,7 +601,7 @@ pub fn innerParseFromValue(...@@ -601,7 +601,7 @@ pub fn innerParseFromValue(
601 else => return error.UnexpectedToken,601 else => return error.UnexpectedToken,
602 }602 }
603 },603 },
604 .Union => |unionInfo| {604 .@"union" => |unionInfo| {
605 if (std.meta.hasFn(T, "jsonParseFromValue")) {605 if (std.meta.hasFn(T, "jsonParseFromValue")) {
606 return T.jsonParseFromValue(allocator, source, options);606 return T.jsonParseFromValue(allocator, source, options);
607 }607 }
...@@ -631,7 +631,7 @@ pub fn innerParseFromValue(...@@ -631,7 +631,7 @@ pub fn innerParseFromValue(
631 return error.UnknownField;631 return error.UnknownField;
632 },632 },
633633
634 .Struct => |structInfo| {634 .@"struct" => |structInfo| {
635 if (structInfo.is_tuple) {635 if (structInfo.is_tuple) {
636 if (source != .array) return error.UnexpectedToken;636 if (source != .array) return error.UnexpectedToken;
637 if (source.array.items.len != structInfo.fields.len) return error.UnexpectedToken;637 if (source.array.items.len != structInfo.fields.len) return error.UnexpectedToken;
...@@ -674,7 +674,7 @@ pub fn innerParseFromValue(...@@ -674,7 +674,7 @@ pub fn innerParseFromValue(
674 return r;674 return r;
675 },675 },
676676
677 .Array => |arrayInfo| {677 .array => |arrayInfo| {
678 switch (source) {678 switch (source) {
679 .array => |array| {679 .array => |array| {
680 // Typical array.680 // Typical array.
...@@ -695,7 +695,7 @@ pub fn innerParseFromValue(...@@ -695,7 +695,7 @@ pub fn innerParseFromValue(
695 }695 }
696 },696 },
697697
698 .Vector => |vecInfo| {698 .vector => |vecInfo| {
699 switch (source) {699 switch (source) {
700 .array => |array| {700 .array => |array| {
701 return innerParseArrayFromArrayValue(T, vecInfo.child, vecInfo.len, allocator, array, options);701 return innerParseArrayFromArrayValue(T, vecInfo.child, vecInfo.len, allocator, array, options);
...@@ -704,7 +704,7 @@ pub fn innerParseFromValue(...@@ -704,7 +704,7 @@ pub fn innerParseFromValue(
704 }704 }
705 },705 },
706706
707 .Pointer => |ptrInfo| {707 .pointer => |ptrInfo| {
708 switch (ptrInfo.size) {708 switch (ptrInfo.size) {
709 .One => {709 .One => {
710 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);710 const r: *ptrInfo.child = try allocator.create(ptrInfo.child);
...@@ -780,12 +780,12 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T {...@@ -780,12 +780,12 @@ fn sliceToEnum(comptime T: type, slice: []const u8) !T {
780 if (std.meta.stringToEnum(T, slice)) |value| return value;780 if (std.meta.stringToEnum(T, slice)) |value| return value;
781 // Check for a numeric value.781 // Check for a numeric value.
782 if (!isNumberFormattedLikeAnInteger(slice)) return error.InvalidEnumTag;782 if (!isNumberFormattedLikeAnInteger(slice)) return error.InvalidEnumTag;
783 const n = std.fmt.parseInt(@typeInfo(T).Enum.tag_type, slice, 10) catch return error.InvalidEnumTag;783 const n = std.fmt.parseInt(@typeInfo(T).@"enum".tag_type, slice, 10) catch return error.InvalidEnumTag;
784 return std.meta.intToEnum(T, n);784 return std.meta.intToEnum(T, n);
785}785}
786786
787fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).Struct.fields.len]bool) !void {787fn fillDefaultStructValues(comptime T: type, r: *T, fields_seen: *[@typeInfo(T).@"struct".fields.len]bool) !void {
788 inline for (@typeInfo(T).Struct.fields, 0..) |field, i| {788 inline for (@typeInfo(T).@"struct".fields, 0..) |field, i| {
789 if (!fields_seen[i]) {789 if (!fields_seen[i]) {
790 if (field.default_value) |default_ptr| {790 if (field.default_value) |default_ptr| {
791 const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*;791 const default = @as(*align(1) const field.type, @ptrCast(default_ptr)).*;
lib/std/json/stringify.zig+16-16
...@@ -493,7 +493,7 @@ pub fn WriteStream(...@@ -493,7 +493,7 @@ pub fn WriteStream(
493 if (build_mode_has_safety) assert(self.raw_streaming_mode == .none);493 if (build_mode_has_safety) assert(self.raw_streaming_mode == .none);
494 const T = @TypeOf(value);494 const T = @TypeOf(value);
495 switch (@typeInfo(T)) {495 switch (@typeInfo(T)) {
496 .Int => {496 .int => {
497 try self.valueStart();497 try self.valueStart();
498 if (self.options.emit_nonportable_numbers_as_strings and498 if (self.options.emit_nonportable_numbers_as_strings and
499 (value <= -(1 << 53) or value >= (1 << 53)))499 (value <= -(1 << 53) or value >= (1 << 53)))
...@@ -505,10 +505,10 @@ pub fn WriteStream(...@@ -505,10 +505,10 @@ pub fn WriteStream(
505 self.valueDone();505 self.valueDone();
506 return;506 return;
507 },507 },
508 .ComptimeInt => {508 .comptime_int => {
509 return self.write(@as(std.math.IntFittingRange(value, value), value));509 return self.write(@as(std.math.IntFittingRange(value, value), value));
510 },510 },
511 .Float, .ComptimeFloat => {511 .float, .comptime_float => {
512 if (@as(f64, @floatCast(value)) == value) {512 if (@as(f64, @floatCast(value)) == value) {
513 try self.valueStart();513 try self.valueStart();
514 try self.stream.print("{}", .{@as(f64, @floatCast(value))});514 try self.stream.print("{}", .{@as(f64, @floatCast(value))});
...@@ -521,38 +521,38 @@ pub fn WriteStream(...@@ -521,38 +521,38 @@ pub fn WriteStream(
521 return;521 return;
522 },522 },
523523
524 .Bool => {524 .bool => {
525 try self.valueStart();525 try self.valueStart();
526 try self.stream.writeAll(if (value) "true" else "false");526 try self.stream.writeAll(if (value) "true" else "false");
527 self.valueDone();527 self.valueDone();
528 return;528 return;
529 },529 },
530 .Null => {530 .null => {
531 try self.valueStart();531 try self.valueStart();
532 try self.stream.writeAll("null");532 try self.stream.writeAll("null");
533 self.valueDone();533 self.valueDone();
534 return;534 return;
535 },535 },
536 .Optional => {536 .optional => {
537 if (value) |payload| {537 if (value) |payload| {
538 return try self.write(payload);538 return try self.write(payload);
539 } else {539 } else {
540 return try self.write(null);540 return try self.write(null);
541 }541 }
542 },542 },
543 .Enum, .EnumLiteral => {543 .@"enum", .enum_literal => {
544 if (std.meta.hasFn(T, "jsonStringify")) {544 if (std.meta.hasFn(T, "jsonStringify")) {
545 return value.jsonStringify(self);545 return value.jsonStringify(self);
546 }546 }
547547
548 return self.stringValue(@tagName(value));548 return self.stringValue(@tagName(value));
549 },549 },
550 .Union => {550 .@"union" => {
551 if (std.meta.hasFn(T, "jsonStringify")) {551 if (std.meta.hasFn(T, "jsonStringify")) {
552 return value.jsonStringify(self);552 return value.jsonStringify(self);
553 }553 }
554554
555 const info = @typeInfo(T).Union;555 const info = @typeInfo(T).@"union";
556 if (info.tag_type) |UnionTagType| {556 if (info.tag_type) |UnionTagType| {
557 try self.beginObject();557 try self.beginObject();
558 inline for (info.fields) |u_field| {558 inline for (info.fields) |u_field| {
...@@ -576,7 +576,7 @@ pub fn WriteStream(...@@ -576,7 +576,7 @@ pub fn WriteStream(
576 @compileError("Unable to stringify untagged union '" ++ @typeName(T) ++ "'");576 @compileError("Unable to stringify untagged union '" ++ @typeName(T) ++ "'");
577 }577 }
578 },578 },
579 .Struct => |S| {579 .@"struct" => |S| {
580 if (std.meta.hasFn(T, "jsonStringify")) {580 if (std.meta.hasFn(T, "jsonStringify")) {
581 return value.jsonStringify(self);581 return value.jsonStringify(self);
582 }582 }
...@@ -593,7 +593,7 @@ pub fn WriteStream(...@@ -593,7 +593,7 @@ pub fn WriteStream(
593 var emit_field = true;593 var emit_field = true;
594594
595 // don't include optional fields that are null when emit_null_optional_fields is set to false595 // don't include optional fields that are null when emit_null_optional_fields is set to false
596 if (@typeInfo(Field.type) == .Optional) {596 if (@typeInfo(Field.type) == .optional) {
597 if (self.options.emit_null_optional_fields == false) {597 if (self.options.emit_null_optional_fields == false) {
598 if (@field(value, Field.name) == null) {598 if (@field(value, Field.name) == null) {
599 emit_field = false;599 emit_field = false;
...@@ -615,10 +615,10 @@ pub fn WriteStream(...@@ -615,10 +615,10 @@ pub fn WriteStream(
615 }615 }
616 return;616 return;
617 },617 },
618 .ErrorSet => return self.stringValue(@errorName(value)),618 .error_set => return self.stringValue(@errorName(value)),
619 .Pointer => |ptr_info| switch (ptr_info.size) {619 .pointer => |ptr_info| switch (ptr_info.size) {
620 .One => switch (@typeInfo(ptr_info.child)) {620 .One => switch (@typeInfo(ptr_info.child)) {
621 .Array => {621 .array => {
622 // Coerce `*[N]T` to `[]const T`.622 // Coerce `*[N]T` to `[]const T`.
623 const Slice = []const std.meta.Elem(ptr_info.child);623 const Slice = []const std.meta.Elem(ptr_info.child);
624 return self.write(@as(Slice, value));624 return self.write(@as(Slice, value));
...@@ -648,11 +648,11 @@ pub fn WriteStream(...@@ -648,11 +648,11 @@ pub fn WriteStream(
648 },648 },
649 else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),649 else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"),
650 },650 },
651 .Array => {651 .array => {
652 // Coerce `[N]T` to `*const [N]T` (and then to `[]const T`).652 // Coerce `[N]T` to `*const [N]T` (and then to `[]const T`).
653 return self.write(&value);653 return self.write(&value);
654 },654 },
655 .Vector => |info| {655 .vector => |info| {
656 const array: [info.len]info.child = value;656 const array: [info.len]info.child = value;
657 return self.write(&array);657 return self.write(&array);
658 },658 },
lib/std/leb128.zig+19-19
...@@ -4,10 +4,10 @@ const testing = std.testing;...@@ -4,10 +4,10 @@ const testing = std.testing;
4/// Read a single unsigned LEB128 value from the given reader as type T,4/// Read a single unsigned LEB128 value from the given reader as type T,
5/// or error.Overflow if the value cannot fit.5/// or error.Overflow if the value cannot fit.
6pub fn readUleb128(comptime T: type, reader: anytype) !T {6pub fn readUleb128(comptime T: type, reader: anytype) !T {
7 const U = if (@typeInfo(T).Int.bits < 8) u8 else T;7 const U = if (@typeInfo(T).int.bits < 8) u8 else T;
8 const ShiftT = std.math.Log2Int(U);8 const ShiftT = std.math.Log2Int(U);
99
10 const max_group = (@typeInfo(U).Int.bits + 6) / 7;10 const max_group = (@typeInfo(U).int.bits + 6) / 7;
1111
12 var value: U = 0;12 var value: U = 0;
13 var group: ShiftT = 0;13 var group: ShiftT = 0;
...@@ -42,7 +42,7 @@ pub fn writeUleb128(writer: anytype, arg: anytype) !void {...@@ -42,7 +42,7 @@ pub fn writeUleb128(writer: anytype, arg: anytype) !void {
42 comptime_int => std.math.IntFittingRange(arg, arg),42 comptime_int => std.math.IntFittingRange(arg, arg),
43 else => Arg,43 else => Arg,
44 };44 };
45 const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int;45 const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int;
46 var value: Value = arg;46 var value: Value = arg;
4747
48 while (true) {48 while (true) {
...@@ -63,11 +63,11 @@ pub const writeULEB128 = writeUleb128;...@@ -63,11 +63,11 @@ pub const writeULEB128 = writeUleb128;
63/// Read a single signed LEB128 value from the given reader as type T,63/// Read a single signed LEB128 value from the given reader as type T,
64/// or error.Overflow if the value cannot fit.64/// or error.Overflow if the value cannot fit.
65pub fn readIleb128(comptime T: type, reader: anytype) !T {65pub fn readIleb128(comptime T: type, reader: anytype) !T {
66 const S = if (@typeInfo(T).Int.bits < 8) i8 else T;66 const S = if (@typeInfo(T).int.bits < 8) i8 else T;
67 const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits);67 const U = std.meta.Int(.unsigned, @typeInfo(S).int.bits);
68 const ShiftU = std.math.Log2Int(U);68 const ShiftU = std.math.Log2Int(U);
6969
70 const max_group = (@typeInfo(U).Int.bits + 6) / 7;70 const max_group = (@typeInfo(U).int.bits + 6) / 7;
7171
72 var value = @as(U, 0);72 var value = @as(U, 0);
73 var group = @as(ShiftU, 0);73 var group = @as(ShiftU, 0);
...@@ -83,14 +83,14 @@ pub fn readIleb128(comptime T: type, reader: anytype) !T {...@@ -83,14 +83,14 @@ pub fn readIleb128(comptime T: type, reader: anytype) !T {
83 if (@as(S, @bitCast(ov[0])) >= 0) return error.Overflow;83 if (@as(S, @bitCast(ov[0])) >= 0) return error.Overflow;
8484
85 // and all the overflowed bits are 185 // and all the overflowed bits are 1
86 const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift)));86 const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift)));
87 const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift;87 const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift;
88 if (remaining_bits != -1) return error.Overflow;88 if (remaining_bits != -1) return error.Overflow;
89 } else {89 } else {
90 // If we don't overflow and this is the last byte and the number being decoded90 // If we don't overflow and this is the last byte and the number being decoded
91 // is negative, check that the remaining bits are 191 // is negative, check that the remaining bits are 1
92 if ((byte & 0x80 == 0) and (@as(S, @bitCast(ov[0])) < 0)) {92 if ((byte & 0x80 == 0) and (@as(S, @bitCast(ov[0])) < 0)) {
93 const remaining_shift = @as(u3, @intCast(@typeInfo(U).Int.bits - @as(u16, shift)));93 const remaining_shift = @as(u3, @intCast(@typeInfo(U).int.bits - @as(u16, shift)));
94 const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift;94 const remaining_bits = @as(i8, @bitCast(byte | 0x80)) >> remaining_shift;
95 if (remaining_bits != -1) return error.Overflow;95 if (remaining_bits != -1) return error.Overflow;
96 }96 }
...@@ -128,8 +128,8 @@ pub fn writeIleb128(writer: anytype, arg: anytype) !void {...@@ -128,8 +128,8 @@ pub fn writeIleb128(writer: anytype, arg: anytype) !void {
128 comptime_int => std.math.IntFittingRange(-@abs(arg), @abs(arg)),128 comptime_int => std.math.IntFittingRange(-@abs(arg), @abs(arg)),
129 else => Arg,129 else => Arg,
130 };130 };
131 const Signed = if (@typeInfo(Int).Int.bits < 8) i8 else Int;131 const Signed = if (@typeInfo(Int).int.bits < 8) i8 else Int;
132 const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).Int.bits);132 const Unsigned = std.meta.Int(.unsigned, @typeInfo(Signed).int.bits);
133 var value: Signed = arg;133 var value: Signed = arg;
134134
135 while (true) {135 while (true) {
...@@ -165,7 +165,7 @@ pub fn writeUnsignedExtended(slice: []u8, arg: anytype) void {...@@ -165,7 +165,7 @@ pub fn writeUnsignedExtended(slice: []u8, arg: anytype) void {
165 comptime_int => std.math.IntFittingRange(arg, arg),165 comptime_int => std.math.IntFittingRange(arg, arg),
166 else => Arg,166 else => Arg,
167 };167 };
168 const Value = if (@typeInfo(Int).Int.bits < 8) u8 else Int;168 const Value = if (@typeInfo(Int).int.bits < 8) u8 else Int;
169 var value: Value = arg;169 var value: Value = arg;
170170
171 for (slice[0 .. slice.len - 1]) |*byte| {171 for (slice[0 .. slice.len - 1]) |*byte| {
...@@ -210,7 +210,7 @@ test writeUnsignedFixed {...@@ -210,7 +210,7 @@ test writeUnsignedFixed {
210/// different value without shifting all the following code.210/// different value without shifting all the following code.
211pub fn writeSignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.signed, l * 7)) void {211pub fn writeSignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.signed, l * 7)) void {
212 const T = @TypeOf(int);212 const T = @TypeOf(int);
213 const U = if (@typeInfo(T).Int.bits < 8) u8 else T;213 const U = if (@typeInfo(T).int.bits < 8) u8 else T;
214 var value: U = @intCast(int);214 var value: U = @intCast(int);
215215
216 comptime var i = 0;216 comptime var i = 0;
...@@ -388,7 +388,7 @@ test "deserialize unsigned LEB128" {...@@ -388,7 +388,7 @@ test "deserialize unsigned LEB128" {
388388
389fn test_write_leb128(value: anytype) !void {389fn test_write_leb128(value: anytype) !void {
390 const T = @TypeOf(value);390 const T = @TypeOf(value);
391 const signedness = @typeInfo(T).Int.signedness;391 const signedness = @typeInfo(T).int.signedness;
392 const t_signed = signedness == .signed;392 const t_signed = signedness == .signed;
393393
394 const writeStream = if (t_signed) writeIleb128 else writeUleb128;394 const writeStream = if (t_signed) writeIleb128 else writeUleb128;
...@@ -396,19 +396,19 @@ fn test_write_leb128(value: anytype) !void {...@@ -396,19 +396,19 @@ fn test_write_leb128(value: anytype) !void {
396396
397 // decode to a larger bit size too, to ensure sign extension397 // decode to a larger bit size too, to ensure sign extension
398 // is working as expected398 // is working as expected
399 const larger_type_bits = ((@typeInfo(T).Int.bits + 8) / 8) * 8;399 const larger_type_bits = ((@typeInfo(T).int.bits + 8) / 8) * 8;
400 const B = std.meta.Int(signedness, larger_type_bits);400 const B = std.meta.Int(signedness, larger_type_bits);
401401
402 const bytes_needed = bn: {402 const bytes_needed = bn: {
403 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);403 if (@typeInfo(T).int.bits <= 7) break :bn @as(u16, 1);
404404
405 const unused_bits = if (value < 0) @clz(~value) else @clz(value);405 const unused_bits = if (value < 0) @clz(~value) else @clz(value);
406 const used_bits: u16 = (@typeInfo(T).Int.bits - unused_bits) + @intFromBool(t_signed);406 const used_bits: u16 = (@typeInfo(T).int.bits - unused_bits) + @intFromBool(t_signed);
407 if (used_bits <= 7) break :bn @as(u16, 1);407 if (used_bits <= 7) break :bn @as(u16, 1);
408 break :bn ((used_bits + 6) / 7);408 break :bn ((used_bits + 6) / 7);
409 };409 };
410410
411 const max_groups = if (@typeInfo(T).Int.bits == 0) 1 else (@typeInfo(T).Int.bits + 6) / 7;411 const max_groups = if (@typeInfo(T).int.bits == 0) 1 else (@typeInfo(T).int.bits + 6) / 7;
412412
413 var buf: [max_groups]u8 = undefined;413 var buf: [max_groups]u8 = undefined;
414 var fbs = std.io.fixedBufferStream(&buf);414 var fbs = std.io.fixedBufferStream(&buf);
...@@ -439,7 +439,7 @@ test "serialize unsigned LEB128" {...@@ -439,7 +439,7 @@ test "serialize unsigned LEB128" {
439 const T = std.meta.Int(.unsigned, t);439 const T = std.meta.Int(.unsigned, t);
440 const min = std.math.minInt(T);440 const min = std.math.minInt(T);
441 const max = std.math.maxInt(T);441 const max = std.math.maxInt(T);
442 var i = @as(std.meta.Int(.unsigned, @typeInfo(T).Int.bits + 1), min);442 var i = @as(std.meta.Int(.unsigned, @typeInfo(T).int.bits + 1), min);
443443
444 while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i)));444 while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i)));
445 }445 }
...@@ -457,7 +457,7 @@ test "serialize signed LEB128" {...@@ -457,7 +457,7 @@ test "serialize signed LEB128" {
457 const T = std.meta.Int(.signed, t);457 const T = std.meta.Int(.signed, t);
458 const min = std.math.minInt(T);458 const min = std.math.minInt(T);
459 const max = std.math.maxInt(T);459 const max = std.math.maxInt(T);
460 var i = @as(std.meta.Int(.signed, @typeInfo(T).Int.bits + 1), min);460 var i = @as(std.meta.Int(.signed, @typeInfo(T).int.bits + 1), min);
461461
462 while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i)));462 while (i <= max) : (i += 1) try test_write_leb128(@as(T, @intCast(i)));
463 }463 }
lib/std/log.zig+6-6
...@@ -28,7 +28,7 @@...@@ -28,7 +28,7 @@
28//!28//!
29//! pub fn myLogFn(29//! pub fn myLogFn(
30//! comptime level: std.log.Level,30//! comptime level: std.log.Level,
31//! comptime scope: @TypeOf(.EnumLiteral),31//! comptime scope: @Type(.enum_literal),
32//! comptime format: []const u8,32//! comptime format: []const u8,
33//! args: anytype,33//! args: anytype,
34//! ) void {34//! ) void {
...@@ -108,7 +108,7 @@ pub const default_level: Level = switch (builtin.mode) {...@@ -108,7 +108,7 @@ pub const default_level: Level = switch (builtin.mode) {
108const level = std.options.log_level;108const level = std.options.log_level;
109109
110pub const ScopeLevel = struct {110pub const ScopeLevel = struct {
111 scope: @Type(.EnumLiteral),111 scope: @Type(.enum_literal),
112 level: Level,112 level: Level,
113};113};
114114
...@@ -116,7 +116,7 @@ const scope_levels = std.options.log_scope_levels;...@@ -116,7 +116,7 @@ const scope_levels = std.options.log_scope_levels;
116116
117fn log(117fn log(
118 comptime message_level: Level,118 comptime message_level: Level,
119 comptime scope: @Type(.EnumLiteral),119 comptime scope: @Type(.enum_literal),
120 comptime format: []const u8,120 comptime format: []const u8,
121 args: anytype,121 args: anytype,
122) void {122) void {
...@@ -126,7 +126,7 @@ fn log(...@@ -126,7 +126,7 @@ fn log(
126}126}
127127
128/// Determine if a specific log message level and scope combination are enabled for logging.128/// Determine if a specific log message level and scope combination are enabled for logging.
129pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.EnumLiteral)) bool {129pub fn logEnabled(comptime message_level: Level, comptime scope: @Type(.enum_literal)) bool {
130 inline for (scope_levels) |scope_level| {130 inline for (scope_levels) |scope_level| {
131 if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level);131 if (scope_level.scope == scope) return @intFromEnum(message_level) <= @intFromEnum(scope_level.level);
132 }132 }
...@@ -142,7 +142,7 @@ pub fn defaultLogEnabled(comptime message_level: Level) bool {...@@ -142,7 +142,7 @@ pub fn defaultLogEnabled(comptime message_level: Level) bool {
142/// forward log messages to this function.142/// forward log messages to this function.
143pub fn defaultLog(143pub fn defaultLog(
144 comptime message_level: Level,144 comptime message_level: Level,
145 comptime scope: @Type(.EnumLiteral),145 comptime scope: @Type(.enum_literal),
146 comptime format: []const u8,146 comptime format: []const u8,
147 args: anytype,147 args: anytype,
148) void {148) void {
...@@ -162,7 +162,7 @@ pub fn defaultLog(...@@ -162,7 +162,7 @@ pub fn defaultLog(
162162
163/// Returns a scoped logging namespace that logs all messages using the scope163/// Returns a scoped logging namespace that logs all messages using the scope
164/// provided here.164/// provided here.
165pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {165pub fn scoped(comptime scope: @Type(.enum_literal)) type {
166 return struct {166 return struct {
167 /// Log an error message. This log level is intended to be used167 /// Log an error message. This log level is intended to be used
168 /// when something has gone wrong. This might be recoverable or might168 /// when something has gone wrong. This might be recoverable or might
lib/std/math.zig+98-98
...@@ -71,7 +71,7 @@ pub const snan = float.snan;...@@ -71,7 +71,7 @@ pub const snan = float.snan;
71///71///
72/// NaN values are never considered equal to any value.72/// NaN values are never considered equal to any value.
73pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool {73pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool {
74 assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat);74 assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float);
75 assert(tolerance >= 0);75 assert(tolerance >= 0);
7676
77 // Fast path for equal values (and signed zeros and infinites).77 // Fast path for equal values (and signed zeros and infinites).
...@@ -99,7 +99,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool {...@@ -99,7 +99,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool {
99///99///
100/// NaN values are never considered equal to any value.100/// NaN values are never considered equal to any value.
101pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool {101pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool {
102 assert(@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat);102 assert(@typeInfo(T) == .float or @typeInfo(T) == .comptime_float);
103 assert(tolerance > 0);103 assert(tolerance > 0);
104104
105 // Fast path for equal values (and signed zeros and infinites).105 // Fast path for equal values (and signed zeros and infinites).
...@@ -263,8 +263,8 @@ pub inline fn tan(value: anytype) @TypeOf(value) {...@@ -263,8 +263,8 @@ pub inline fn tan(value: anytype) @TypeOf(value) {
263pub fn radiansToDegrees(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) {263pub fn radiansToDegrees(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) {
264 const T = @TypeOf(ang);264 const T = @TypeOf(ang);
265 switch (@typeInfo(T)) {265 switch (@typeInfo(T)) {
266 .Float, .ComptimeFloat, .ComptimeInt => return ang * deg_per_rad,266 .float, .comptime_float, .comptime_int => return ang * deg_per_rad,
267 .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(deg_per_rad)),267 .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(deg_per_rad)),
268 else => {},268 else => {},
269 }269 }
270 @compileError("Input must be float or a comptime number, or a vector of floats.");270 @compileError("Input must be float or a comptime number, or a vector of floats.");
...@@ -298,8 +298,8 @@ test radiansToDegrees {...@@ -298,8 +298,8 @@ test radiansToDegrees {
298pub fn degreesToRadians(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) {298pub fn degreesToRadians(ang: anytype) if (@TypeOf(ang) == comptime_int) comptime_float else @TypeOf(ang) {
299 const T = @TypeOf(ang);299 const T = @TypeOf(ang);
300 switch (@typeInfo(T)) {300 switch (@typeInfo(T)) {
301 .Float, .ComptimeFloat, .ComptimeInt => return ang * rad_per_deg,301 .float, .comptime_float, .comptime_int => return ang * rad_per_deg,
302 .Vector => |V| if (@typeInfo(V.child) == .Float) return ang * @as(T, @splat(rad_per_deg)),302 .vector => |V| if (@typeInfo(V.child) == .float) return ang * @as(T, @splat(rad_per_deg)),
303 else => {},303 else => {},
304 }304 }
305 @compileError("Input must be float or a comptime number, or a vector of floats.");305 @compileError("Input must be float or a comptime number, or a vector of floats.");
...@@ -408,8 +408,8 @@ test {...@@ -408,8 +408,8 @@ test {
408/// full range of the minimum value.408/// full range of the minimum value.
409pub fn Min(comptime A: type, comptime B: type) type {409pub fn Min(comptime A: type, comptime B: type) type {
410 switch (@typeInfo(A)) {410 switch (@typeInfo(A)) {
411 .Int => |a_info| switch (@typeInfo(B)) {411 .int => |a_info| switch (@typeInfo(B)) {
412 .Int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) {412 .int => |b_info| if (a_info.signedness == .unsigned and b_info.signedness == .unsigned) {
413 if (a_info.bits < b_info.bits) {413 if (a_info.bits < b_info.bits) {
414 return A;414 return A;
415 } else {415 } else {
...@@ -437,21 +437,21 @@ pub fn Min(comptime A: type, comptime B: type) type {...@@ -437,21 +437,21 @@ pub fn Min(comptime A: type, comptime B: type) type {
437pub fn wrap(x: anytype, r: anytype) @TypeOf(x) {437pub fn wrap(x: anytype, r: anytype) @TypeOf(x) {
438 const info_x = @typeInfo(@TypeOf(x));438 const info_x = @typeInfo(@TypeOf(x));
439 const info_r = @typeInfo(@TypeOf(r));439 const info_r = @typeInfo(@TypeOf(r));
440 if (info_x == .Int and info_x.Int.signedness != .signed) {440 if (info_x == .int and info_x.int.signedness != .signed) {
441 @compileError("x must be floating point, comptime integer, or signed integer.");441 @compileError("x must be floating point, comptime integer, or signed integer.");
442 }442 }
443 switch (info_r) {443 switch (info_r) {
444 .Int => {444 .int => {
445 // in the rare usecase of r not being comptime_int or float,445 // in the rare usecase of r not being comptime_int or float,
446 // take the penalty of having an intermediary type conversion,446 // take the penalty of having an intermediary type conversion,
447 // otherwise the alternative is to unwind iteratively to avoid overflow447 // otherwise the alternative is to unwind iteratively to avoid overflow
448 const R = comptime do: {448 const R = comptime do: {
449 var info = info_r;449 var info = info_r;
450 info.Int.bits += 1;450 info.int.bits += 1;
451 info.Int.signedness = .signed;451 info.int.signedness = .signed;
452 break :do @Type(info);452 break :do @Type(info);
453 };453 };
454 const radius: if (info_r.Int.signedness == .signed) @TypeOf(r) else R = r;454 const radius: if (info_r.int.signedness == .signed) @TypeOf(r) else R = r;
455 return @intCast(@mod(x - radius, 2 * @as(R, r)) - r); // provably impossible to overflow455 return @intCast(@mod(x - radius, 2 * @as(R, r)) - r); // provably impossible to overflow
456 },456 },
457 else => {457 else => {
...@@ -520,9 +520,9 @@ test wrap {...@@ -520,9 +520,9 @@ test wrap {
520pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {520pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {
521 const T = @TypeOf(val, lower, upper);521 const T = @TypeOf(val, lower, upper);
522 switch (@typeInfo(T)) {522 switch (@typeInfo(T)) {
523 .Int, .Float, .ComptimeInt, .ComptimeFloat => assert(lower <= upper),523 .int, .float, .comptime_int, .comptime_float => assert(lower <= upper),
524 .Vector => |vinfo| switch (@typeInfo(vinfo.child)) {524 .vector => |vinfo| switch (@typeInfo(vinfo.child)) {
525 .Int, .Float => assert(@reduce(.And, lower <= upper)),525 .int, .float => assert(@reduce(.And, lower <= upper)),
526 else => @compileError("Expected vector of ints or floats, found " ++ @typeName(T)),526 else => @compileError("Expected vector of ints or floats, found " ++ @typeName(T)),
527 },527 },
528 else => @compileError("Expected an int, float or vector of one, found " ++ @typeName(T)),528 else => @compileError("Expected an int, float or vector of one, found " ++ @typeName(T)),
...@@ -593,18 +593,18 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T {...@@ -593,18 +593,18 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T {
593 const abs_shift_amt = @abs(shift_amt);593 const abs_shift_amt = @abs(shift_amt);
594594
595 const casted_shift_amt = blk: {595 const casted_shift_amt = blk: {
596 if (@typeInfo(T) == .Vector) {596 if (@typeInfo(T) == .vector) {
597 const C = @typeInfo(T).Vector.child;597 const C = @typeInfo(T).vector.child;
598 const len = @typeInfo(T).Vector.len;598 const len = @typeInfo(T).vector.len;
599 if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0);599 if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0);
600 break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt))));600 break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt))));
601 } else {601 } else {
602 if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0;602 if (abs_shift_amt >= @typeInfo(T).int.bits) return 0;
603 break :blk @as(Log2Int(T), @intCast(abs_shift_amt));603 break :blk @as(Log2Int(T), @intCast(abs_shift_amt));
604 }604 }
605 };605 };
606606
607 if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) {607 if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) {
608 if (shift_amt < 0) {608 if (shift_amt < 0) {
609 return a >> casted_shift_amt;609 return a >> casted_shift_amt;
610 }610 }
...@@ -633,18 +633,18 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T {...@@ -633,18 +633,18 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T {
633 const abs_shift_amt = @abs(shift_amt);633 const abs_shift_amt = @abs(shift_amt);
634634
635 const casted_shift_amt = blk: {635 const casted_shift_amt = blk: {
636 if (@typeInfo(T) == .Vector) {636 if (@typeInfo(T) == .vector) {
637 const C = @typeInfo(T).Vector.child;637 const C = @typeInfo(T).vector.child;
638 const len = @typeInfo(T).Vector.len;638 const len = @typeInfo(T).vector.len;
639 if (abs_shift_amt >= @typeInfo(C).Int.bits) return @splat(0);639 if (abs_shift_amt >= @typeInfo(C).int.bits) return @splat(0);
640 break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt))));640 break :blk @as(@Vector(len, Log2Int(C)), @splat(@as(Log2Int(C), @intCast(abs_shift_amt))));
641 } else {641 } else {
642 if (abs_shift_amt >= @typeInfo(T).Int.bits) return 0;642 if (abs_shift_amt >= @typeInfo(T).int.bits) return 0;
643 break :blk @as(Log2Int(T), @intCast(abs_shift_amt));643 break :blk @as(Log2Int(T), @intCast(abs_shift_amt));
644 }644 }
645 };645 };
646646
647 if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).Int.signedness == .signed) {647 if (@TypeOf(shift_amt) == comptime_int or @typeInfo(@TypeOf(shift_amt)).int.signedness == .signed) {
648 if (shift_amt < 0) {648 if (shift_amt < 0) {
649 return a << casted_shift_amt;649 return a << casted_shift_amt;
650 }650 }
...@@ -670,26 +670,26 @@ test shr {...@@ -670,26 +670,26 @@ test shr {
670/// Rotates right. Only unsigned values can be rotated. Negative shift670/// Rotates right. Only unsigned values can be rotated. Negative shift
671/// values result in shift modulo the bit count.671/// values result in shift modulo the bit count.
672pub fn rotr(comptime T: type, x: T, r: anytype) T {672pub fn rotr(comptime T: type, x: T, r: anytype) T {
673 if (@typeInfo(T) == .Vector) {673 if (@typeInfo(T) == .vector) {
674 const C = @typeInfo(T).Vector.child;674 const C = @typeInfo(T).vector.child;
675 if (C == u0) return 0;675 if (C == u0) return 0;
676676
677 if (@typeInfo(C).Int.signedness == .signed) {677 if (@typeInfo(C).int.signedness == .signed) {
678 @compileError("cannot rotate signed integers");678 @compileError("cannot rotate signed integers");
679 }679 }
680 const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits));680 const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits));
681 return (x >> @splat(ar)) | (x << @splat(1 + ~ar));681 return (x >> @splat(ar)) | (x << @splat(1 + ~ar));
682 } else if (@typeInfo(T).Int.signedness == .signed) {682 } else if (@typeInfo(T).int.signedness == .signed) {
683 @compileError("cannot rotate signed integer");683 @compileError("cannot rotate signed integer");
684 } else {684 } else {
685 if (T == u0) return 0;685 if (T == u0) return 0;
686686
687 if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) {687 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
688 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits));688 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
689 return x >> ar | x << (1 +% ~ar);689 return x >> ar | x << (1 +% ~ar);
690 } else {690 } else {
691 const ar = @mod(r, @typeInfo(T).Int.bits);691 const ar = @mod(r, @typeInfo(T).int.bits);
692 return shr(T, x, ar) | shl(T, x, @typeInfo(T).Int.bits - ar);692 return shr(T, x, ar) | shl(T, x, @typeInfo(T).int.bits - ar);
693 }693 }
694 }694 }
695}695}
...@@ -711,26 +711,26 @@ test rotr {...@@ -711,26 +711,26 @@ test rotr {
711/// Rotates left. Only unsigned values can be rotated. Negative shift711/// Rotates left. Only unsigned values can be rotated. Negative shift
712/// values result in shift modulo the bit count.712/// values result in shift modulo the bit count.
713pub fn rotl(comptime T: type, x: T, r: anytype) T {713pub fn rotl(comptime T: type, x: T, r: anytype) T {
714 if (@typeInfo(T) == .Vector) {714 if (@typeInfo(T) == .vector) {
715 const C = @typeInfo(T).Vector.child;715 const C = @typeInfo(T).vector.child;
716 if (C == u0) return 0;716 if (C == u0) return 0;
717717
718 if (@typeInfo(C).Int.signedness == .signed) {718 if (@typeInfo(C).int.signedness == .signed) {
719 @compileError("cannot rotate signed integers");719 @compileError("cannot rotate signed integers");
720 }720 }
721 const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).Int.bits));721 const ar: Log2Int(C) = @intCast(@mod(r, @typeInfo(C).int.bits));
722 return (x << @splat(ar)) | (x >> @splat(1 +% ~ar));722 return (x << @splat(ar)) | (x >> @splat(1 +% ~ar));
723 } else if (@typeInfo(T).Int.signedness == .signed) {723 } else if (@typeInfo(T).int.signedness == .signed) {
724 @compileError("cannot rotate signed integer");724 @compileError("cannot rotate signed integer");
725 } else {725 } else {
726 if (T == u0) return 0;726 if (T == u0) return 0;
727727
728 if (comptime isPowerOfTwo(@typeInfo(T).Int.bits)) {728 if (comptime isPowerOfTwo(@typeInfo(T).int.bits)) {
729 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits));729 const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).int.bits));
730 return x << ar | x >> 1 +% ~ar;730 return x << ar | x >> 1 +% ~ar;
731 } else {731 } else {
732 const ar = @mod(r, @typeInfo(T).Int.bits);732 const ar = @mod(r, @typeInfo(T).int.bits);
733 return shl(T, x, ar) | shr(T, x, @typeInfo(T).Int.bits - ar);733 return shl(T, x, ar) | shr(T, x, @typeInfo(T).int.bits - ar);
734 }734 }
735 }735 }
736}736}
...@@ -754,7 +754,7 @@ test rotl {...@@ -754,7 +754,7 @@ test rotl {
754pub fn Log2Int(comptime T: type) type {754pub fn Log2Int(comptime T: type) type {
755 // comptime ceil log2755 // comptime ceil log2
756 if (T == comptime_int) return comptime_int;756 if (T == comptime_int) return comptime_int;
757 const bits: u16 = @typeInfo(T).Int.bits;757 const bits: u16 = @typeInfo(T).int.bits;
758 const log2_bits = 16 - @clz(bits - 1);758 const log2_bits = 16 - @clz(bits - 1);
759 return std.meta.Int(.unsigned, log2_bits);759 return std.meta.Int(.unsigned, log2_bits);
760}760}
...@@ -763,7 +763,7 @@ pub fn Log2Int(comptime T: type) type {...@@ -763,7 +763,7 @@ pub fn Log2Int(comptime T: type) type {
763pub fn Log2IntCeil(comptime T: type) type {763pub fn Log2IntCeil(comptime T: type) type {
764 // comptime ceil log2764 // comptime ceil log2
765 if (T == comptime_int) return comptime_int;765 if (T == comptime_int) return comptime_int;
766 const bits: u16 = @typeInfo(T).Int.bits;766 const bits: u16 = @typeInfo(T).int.bits;
767 const log2_bits = 16 - @clz(bits);767 const log2_bits = 16 - @clz(bits);
768 return std.meta.Int(.unsigned, log2_bits);768 return std.meta.Int(.unsigned, log2_bits);
769}769}
...@@ -849,7 +849,7 @@ fn testOverflow() !void {...@@ -849,7 +849,7 @@ fn testOverflow() !void {
849pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {849pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T {
850 @setRuntimeSafety(false);850 @setRuntimeSafety(false);
851 if (denominator == 0) return error.DivisionByZero;851 if (denominator == 0) return error.DivisionByZero;
852 if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;852 if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
853 return @divTrunc(numerator, denominator);853 return @divTrunc(numerator, denominator);
854}854}
855855
...@@ -873,7 +873,7 @@ fn testDivTrunc() !void {...@@ -873,7 +873,7 @@ fn testDivTrunc() !void {
873pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {873pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T {
874 @setRuntimeSafety(false);874 @setRuntimeSafety(false);
875 if (denominator == 0) return error.DivisionByZero;875 if (denominator == 0) return error.DivisionByZero;
876 if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;876 if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
877 return @divFloor(numerator, denominator);877 return @divFloor(numerator, denominator);
878}878}
879879
...@@ -899,10 +899,10 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {...@@ -899,10 +899,10 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T {
899 if (denominator == 0) return error.DivisionByZero;899 if (denominator == 0) return error.DivisionByZero;
900 const info = @typeInfo(T);900 const info = @typeInfo(T);
901 switch (info) {901 switch (info) {
902 .ComptimeFloat, .Float => return @ceil(numerator / denominator),902 .comptime_float, .float => return @ceil(numerator / denominator),
903 .ComptimeInt, .Int => {903 .comptime_int, .int => {
904 if (numerator < 0 and denominator < 0) {904 if (numerator < 0 and denominator < 0) {
905 if (info == .Int and numerator == minInt(T) and denominator == -1)905 if (info == .int and numerator == minInt(T) and denominator == -1)
906 return error.Overflow;906 return error.Overflow;
907 return @divFloor(numerator + 1, denominator) + 1;907 return @divFloor(numerator + 1, denominator) + 1;
908 }908 }
...@@ -952,7 +952,7 @@ fn testDivCeil() !void {...@@ -952,7 +952,7 @@ fn testDivCeil() !void {
952pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {952pub fn divExact(comptime T: type, numerator: T, denominator: T) !T {
953 @setRuntimeSafety(false);953 @setRuntimeSafety(false);
954 if (denominator == 0) return error.DivisionByZero;954 if (denominator == 0) return error.DivisionByZero;
955 if (@typeInfo(T) == .Int and @typeInfo(T).Int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;955 if (@typeInfo(T) == .int and @typeInfo(T).int.signedness == .signed and numerator == minInt(T) and denominator == -1) return error.Overflow;
956 const result = @divTrunc(numerator, denominator);956 const result = @divTrunc(numerator, denominator);
957 if (result * denominator != numerator) return error.UnexpectedRemainder;957 if (result * denominator != numerator) return error.UnexpectedRemainder;
958 return result;958 return result;
...@@ -1029,7 +1029,7 @@ fn testRem() !void {...@@ -1029,7 +1029,7 @@ fn testRem() !void {
1029/// Returns the negation of the integer parameter.1029/// Returns the negation of the integer parameter.
1030/// Result is a signed integer.1030/// Result is a signed integer.
1031pub fn negateCast(x: anytype) !std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))) {1031pub fn negateCast(x: anytype) !std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))) {
1032 if (@typeInfo(@TypeOf(x)).Int.signedness == .signed) return negate(x);1032 if (@typeInfo(@TypeOf(x)).int.signedness == .signed) return negate(x);
10331033
1034 const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x)));1034 const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x)));
1035 if (x > -minInt(int)) return error.Overflow;1035 if (x > -minInt(int)) return error.Overflow;
...@@ -1052,9 +1052,9 @@ test negateCast {...@@ -1052,9 +1052,9 @@ test negateCast {
1052/// Cast an integer to a different integer type. If the value doesn't fit,1052/// Cast an integer to a different integer type. If the value doesn't fit,
1053/// return null.1053/// return null.
1054pub fn cast(comptime T: type, x: anytype) ?T {1054pub fn cast(comptime T: type, x: anytype) ?T {
1055 comptime assert(@typeInfo(T) == .Int); // must pass an integer1055 comptime assert(@typeInfo(T) == .int); // must pass an integer
1056 const is_comptime = @TypeOf(x) == comptime_int;1056 const is_comptime = @TypeOf(x) == comptime_int;
1057 comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .Int); // must pass an integer1057 comptime assert(is_comptime or @typeInfo(@TypeOf(x)) == .int); // must pass an integer
1058 if ((is_comptime or maxInt(@TypeOf(x)) > maxInt(T)) and x > maxInt(T)) {1058 if ((is_comptime or maxInt(@TypeOf(x)) > maxInt(T)) and x > maxInt(T)) {
1059 return null;1059 return null;
1060 } else if ((is_comptime or minInt(@TypeOf(x)) < minInt(T)) and x < minInt(T)) {1060 } else if ((is_comptime or minInt(@TypeOf(x)) < minInt(T)) and x < minInt(T)) {
...@@ -1084,7 +1084,7 @@ pub const AlignCastError = error{UnalignedMemory};...@@ -1084,7 +1084,7 @@ pub const AlignCastError = error{UnalignedMemory};
10841084
1085fn AlignCastResult(comptime alignment: u29, comptime Ptr: type) type {1085fn AlignCastResult(comptime alignment: u29, comptime Ptr: type) type {
1086 var ptr_info = @typeInfo(Ptr);1086 var ptr_info = @typeInfo(Ptr);
1087 ptr_info.Pointer.alignment = alignment;1087 ptr_info.pointer.alignment = alignment;
1088 return @Type(ptr_info);1088 return @Type(ptr_info);
1089}1089}
10901090
...@@ -1117,7 +1117,7 @@ test isPowerOfTwo {...@@ -1117,7 +1117,7 @@ test isPowerOfTwo {
11171117
1118/// Aligns the given integer type bit width to a width divisible by 8.1118/// Aligns the given integer type bit width to a width divisible by 8.
1119pub fn ByteAlignedInt(comptime T: type) type {1119pub fn ByteAlignedInt(comptime T: type) type {
1120 const info = @typeInfo(T).Int;1120 const info = @typeInfo(T).int;
1121 const bits = (info.bits + 7) / 8 * 8;1121 const bits = (info.bits + 7) / 8 * 8;
1122 const extended_type = std.meta.Int(info.signedness, bits);1122 const extended_type = std.meta.Int(info.signedness, bits);
1123 return extended_type;1123 return extended_type;
...@@ -1157,7 +1157,7 @@ pub inline fn floor(value: anytype) @TypeOf(value) {...@@ -1157,7 +1157,7 @@ pub inline fn floor(value: anytype) @TypeOf(value) {
1157/// Returns the nearest power of two less than or equal to value, or1157/// Returns the nearest power of two less than or equal to value, or
1158/// zero if value is less than or equal to zero.1158/// zero if value is less than or equal to zero.
1159pub fn floorPowerOfTwo(comptime T: type, value: T) T {1159pub fn floorPowerOfTwo(comptime T: type, value: T) T {
1160 const uT = std.meta.Int(.unsigned, @typeInfo(T).Int.bits);1160 const uT = std.meta.Int(.unsigned, @typeInfo(T).int.bits);
1161 if (value <= 0) return 0;1161 if (value <= 0) return 0;
1162 return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value)));1162 return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value)));
1163}1163}
...@@ -1192,21 +1192,21 @@ pub inline fn ceil(value: anytype) @TypeOf(value) {...@@ -1192,21 +1192,21 @@ pub inline fn ceil(value: anytype) @TypeOf(value) {
1192/// Returns the next power of two (if the value is not already a power of two).1192/// Returns the next power of two (if the value is not already a power of two).
1193/// Only unsigned integers can be used. Zero is not an allowed input.1193/// Only unsigned integers can be used. Zero is not an allowed input.
1194/// Result is a type with 1 more bit than the input type.1194/// Result is a type with 1 more bit than the input type.
1195pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1) {1195pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1) {
1196 comptime assert(@typeInfo(T) == .Int);1196 comptime assert(@typeInfo(T) == .int);
1197 comptime assert(@typeInfo(T).Int.signedness == .unsigned);1197 comptime assert(@typeInfo(T).int.signedness == .unsigned);
1198 assert(value != 0);1198 assert(value != 0);
1199 const PromotedType = std.meta.Int(@typeInfo(T).Int.signedness, @typeInfo(T).Int.bits + 1);1199 const PromotedType = std.meta.Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1);
1200 const ShiftType = std.math.Log2Int(PromotedType);1200 const ShiftType = std.math.Log2Int(PromotedType);
1201 return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).Int.bits - @clz(value - 1)));1201 return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1)));
1202}1202}
12031203
1204/// Returns the next power of two (if the value is not already a power of two).1204/// Returns the next power of two (if the value is not already a power of two).
1205/// Only unsigned integers can be used. Zero is not an allowed input.1205/// Only unsigned integers can be used. Zero is not an allowed input.
1206/// If the value doesn't fit, returns an error.1206/// If the value doesn't fit, returns an error.
1207pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {1207pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
1208 comptime assert(@typeInfo(T) == .Int);1208 comptime assert(@typeInfo(T) == .int);
1209 const info = @typeInfo(T).Int;1209 const info = @typeInfo(T).int;
1210 comptime assert(info.signedness == .unsigned);1210 comptime assert(info.signedness == .unsigned);
1211 const PromotedType = std.meta.Int(info.signedness, info.bits + 1);1211 const PromotedType = std.meta.Int(info.signedness, info.bits + 1);
1212 const overflowBit = @as(PromotedType, 1) << info.bits;1212 const overflowBit = @as(PromotedType, 1) << info.bits;
...@@ -1261,16 +1261,16 @@ fn testCeilPowerOfTwo() !void {...@@ -1261,16 +1261,16 @@ fn testCeilPowerOfTwo() !void {
1261/// Return the log base 2 of integer value x, rounding down to the1261/// Return the log base 2 of integer value x, rounding down to the
1262/// nearest integer.1262/// nearest integer.
1263pub fn log2_int(comptime T: type, x: T) Log2Int(T) {1263pub fn log2_int(comptime T: type, x: T) Log2Int(T) {
1264 if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned)1264 if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned)
1265 @compileError("log2_int requires an unsigned integer, found " ++ @typeName(T));1265 @compileError("log2_int requires an unsigned integer, found " ++ @typeName(T));
1266 assert(x != 0);1266 assert(x != 0);
1267 return @as(Log2Int(T), @intCast(@typeInfo(T).Int.bits - 1 - @clz(x)));1267 return @as(Log2Int(T), @intCast(@typeInfo(T).int.bits - 1 - @clz(x)));
1268}1268}
12691269
1270/// Return the log base 2 of integer value x, rounding up to the1270/// Return the log base 2 of integer value x, rounding up to the
1271/// nearest integer.1271/// nearest integer.
1272pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) {1272pub fn log2_int_ceil(comptime T: type, x: T) Log2IntCeil(T) {
1273 if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned)1273 if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned)
1274 @compileError("log2_int_ceil requires an unsigned integer, found " ++ @typeName(T));1274 @compileError("log2_int_ceil requires an unsigned integer, found " ++ @typeName(T));
1275 assert(x != 0);1275 assert(x != 0);
1276 if (x == 1) return 0;1276 if (x == 1) return 0;
...@@ -1296,35 +1296,35 @@ test log2_int_ceil {...@@ -1296,35 +1296,35 @@ test log2_int_ceil {
1296/// converted to the closest possible representation.1296/// converted to the closest possible representation.
1297pub fn lossyCast(comptime T: type, value: anytype) T {1297pub fn lossyCast(comptime T: type, value: anytype) T {
1298 switch (@typeInfo(T)) {1298 switch (@typeInfo(T)) {
1299 .Float => {1299 .float => {
1300 switch (@typeInfo(@TypeOf(value))) {1300 switch (@typeInfo(@TypeOf(value))) {
1301 .Int => return @as(T, @floatFromInt(value)),1301 .int => return @floatFromInt(value),
1302 .Float => return @as(T, @floatCast(value)),1302 .float => return @floatCast(value),
1303 .ComptimeInt => return @as(T, value),1303 .comptime_int => return value,
1304 .ComptimeFloat => return @as(T, value),1304 .comptime_float => return value,
1305 else => @compileError("bad type"),1305 else => @compileError("bad type"),
1306 }1306 }
1307 },1307 },
1308 .Int => {1308 .int => {
1309 switch (@typeInfo(@TypeOf(value))) {1309 switch (@typeInfo(@TypeOf(value))) {
1310 .Int, .ComptimeInt => {1310 .int, .comptime_int => {
1311 if (value >= maxInt(T)) {1311 if (value >= maxInt(T)) {
1312 return @as(T, maxInt(T));1312 return maxInt(T);
1313 } else if (value <= minInt(T)) {1313 } else if (value <= minInt(T)) {
1314 return @as(T, minInt(T));1314 return minInt(T);
1315 } else {1315 } else {
1316 return @as(T, @intCast(value));1316 return @intCast(value);
1317 }1317 }
1318 },1318 },
1319 .Float, .ComptimeFloat => {1319 .float, .comptime_float => {
1320 if (isNan(value)) {1320 if (isNan(value)) {
1321 return 0;1321 return 0;
1322 } else if (value >= maxInt(T)) {1322 } else if (value >= maxInt(T)) {
1323 return @as(T, maxInt(T));1323 return maxInt(T);
1324 } else if (value <= minInt(T)) {1324 } else if (value <= minInt(T)) {
1325 return @as(T, minInt(T));1325 return minInt(T);
1326 } else {1326 } else {
1327 return @as(T, @intFromFloat(value));1327 return @intFromFloat(value);
1328 }1328 }
1329 },1329 },
1330 else => @compileError("bad type"),1330 else => @compileError("bad type"),
...@@ -1405,16 +1405,16 @@ test lerp {...@@ -1405,16 +1405,16 @@ test lerp {
1405/// Returns the maximum value of integer type T.1405/// Returns the maximum value of integer type T.
1406pub fn maxInt(comptime T: type) comptime_int {1406pub fn maxInt(comptime T: type) comptime_int {
1407 const info = @typeInfo(T);1407 const info = @typeInfo(T);
1408 const bit_count = info.Int.bits;1408 const bit_count = info.int.bits;
1409 if (bit_count == 0) return 0;1409 if (bit_count == 0) return 0;
1410 return (1 << (bit_count - @intFromBool(info.Int.signedness == .signed))) - 1;1410 return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1;
1411}1411}
14121412
1413/// Returns the minimum value of integer type T.1413/// Returns the minimum value of integer type T.
1414pub fn minInt(comptime T: type) comptime_int {1414pub fn minInt(comptime T: type) comptime_int {
1415 const info = @typeInfo(T);1415 const info = @typeInfo(T);
1416 const bit_count = info.Int.bits;1416 const bit_count = info.int.bits;
1417 if (info.Int.signedness == .unsigned) return 0;1417 if (info.int.signedness == .unsigned) return 0;
1418 if (bit_count == 0) return 0;1418 if (bit_count == 0) return 0;
1419 return -(1 << (bit_count - 1));1419 return -(1 << (bit_count - 1));
1420}1420}
...@@ -1466,12 +1466,12 @@ test "max value type" {...@@ -1466,12 +1466,12 @@ test "max value type" {
1466/// Multiply a and b. Return type is wide enough to guarantee no1466/// Multiply a and b. Return type is wide enough to guarantee no
1467/// overflow.1467/// overflow.
1468pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(1468pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(
1469 @typeInfo(T).Int.signedness,1469 @typeInfo(T).int.signedness,
1470 @typeInfo(T).Int.bits * 2,1470 @typeInfo(T).int.bits * 2,
1471) {1471) {
1472 const ResultInt = std.meta.Int(1472 const ResultInt = std.meta.Int(
1473 @typeInfo(T).Int.signedness,1473 @typeInfo(T).int.signedness,
1474 @typeInfo(T).Int.bits * 2,1474 @typeInfo(T).int.bits * 2,
1475 );1475 );
1476 return @as(ResultInt, a) * @as(ResultInt, b);1476 return @as(ResultInt, a) * @as(ResultInt, b);
1477}1477}
...@@ -1616,7 +1616,7 @@ pub const CompareOperator = enum {...@@ -1616,7 +1616,7 @@ pub const CompareOperator = enum {
1616 }1616 }
16171617
1618 test reverse {1618 test reverse {
1619 inline for (@typeInfo(CompareOperator).Enum.fields) |op_field| {1619 inline for (@typeInfo(CompareOperator).@"enum".fields) |op_field| {
1620 const op = @as(CompareOperator, @enumFromInt(op_field.value));1620 const op = @as(CompareOperator, @enumFromInt(op_field.value));
1621 try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2));1621 try testing.expect(compare(2, op, 3) == compare(3, op.reverse(), 2));
1622 try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3));1622 try testing.expect(compare(3, op, 3) == compare(3, op.reverse(), 3));
...@@ -1669,7 +1669,7 @@ test order {...@@ -1669,7 +1669,7 @@ test order {
1669/// and a mask of all zeroes if value is false.1669/// and a mask of all zeroes if value is false.
1670/// Compiles to one instruction for register sized integers.1670/// Compiles to one instruction for register sized integers.
1671pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {1671pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {
1672 if (@typeInfo(MaskInt) != .Int)1672 if (@typeInfo(MaskInt) != .int)
1673 @compileError("boolMask requires an integer mask type.");1673 @compileError("boolMask requires an integer mask type.");
16741674
1675 if (MaskInt == u0 or MaskInt == i0)1675 if (MaskInt == u0 or MaskInt == i0)
...@@ -1742,11 +1742,11 @@ pub fn break_f80(x: f80) F80 {...@@ -1742,11 +1742,11 @@ pub fn break_f80(x: f80) F80 {
1742pub inline fn sign(i: anytype) @TypeOf(i) {1742pub inline fn sign(i: anytype) @TypeOf(i) {
1743 const T = @TypeOf(i);1743 const T = @TypeOf(i);
1744 return switch (@typeInfo(T)) {1744 return switch (@typeInfo(T)) {
1745 .Int, .ComptimeInt => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)),1745 .int, .comptime_int => @as(T, @intFromBool(i > 0)) - @as(T, @intFromBool(i < 0)),
1746 .Float, .ComptimeFloat => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))),1746 .float, .comptime_float => @as(T, @floatFromInt(@intFromBool(i > 0))) - @as(T, @floatFromInt(@intFromBool(i < 0))),
1747 .Vector => |vinfo| blk: {1747 .vector => |vinfo| blk: {
1748 switch (@typeInfo(vinfo.child)) {1748 switch (@typeInfo(vinfo.child)) {
1749 .Int, .Float => {1749 .int, .float => {
1750 const zero: T = @splat(0);1750 const zero: T = @splat(0);
1751 const one: T = @splat(1);1751 const one: T = @splat(1);
1752 break :blk @select(vinfo.child, i > zero, one, zero) - @select(vinfo.child, i < zero, one, zero);1752 break :blk @select(vinfo.child, i > zero, one, zero) - @select(vinfo.child, i < zero, one, zero);
lib/std/math/big.zig+1-1
...@@ -4,7 +4,7 @@ const assert = std.debug.assert;...@@ -4,7 +4,7 @@ const assert = std.debug.assert;
4pub const Rational = @import("big/rational.zig").Rational;4pub const Rational = @import("big/rational.zig").Rational;
5pub const int = @import("big/int.zig");5pub const int = @import("big/int.zig");
6pub const Limb = usize;6pub const Limb = usize;
7const limb_info = @typeInfo(Limb).Int;7const limb_info = @typeInfo(Limb).int;
8pub const SignedLimb = std.meta.Int(.signed, limb_info.bits);8pub const SignedLimb = std.meta.Int(.signed, limb_info.bits);
9pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits);9pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits);
10pub const HalfLimb = std.meta.Int(.unsigned, limb_info.bits / 2);10pub const HalfLimb = std.meta.Int(.unsigned, limb_info.bits / 2);
lib/std/math/big/int.zig+12-12
...@@ -2,9 +2,9 @@ const std = @import("../../std.zig");...@@ -2,9 +2,9 @@ const std = @import("../../std.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
3const math = std.math;3const math = std.math;
4const Limb = std.math.big.Limb;4const Limb = std.math.big.Limb;
5const limb_bits = @typeInfo(Limb).Int.bits;5const limb_bits = @typeInfo(Limb).int.bits;
6const HalfLimb = std.math.big.HalfLimb;6const HalfLimb = std.math.big.HalfLimb;
7const half_limb_bits = @typeInfo(HalfLimb).Int.bits;7const half_limb_bits = @typeInfo(HalfLimb).int.bits;
8const DoubleLimb = std.math.big.DoubleLimb;8const DoubleLimb = std.math.big.DoubleLimb;
9const SignedDoubleLimb = std.math.big.SignedDoubleLimb;9const SignedDoubleLimb = std.math.big.SignedDoubleLimb;
10const Log2Limb = std.math.big.Log2Limb;10const Log2Limb = std.math.big.Log2Limb;
...@@ -23,7 +23,7 @@ const debug_safety = false;...@@ -23,7 +23,7 @@ const debug_safety = false;
23/// primitive integer value.23/// primitive integer value.
24/// Note: A comptime-known upper bound of this value that may be used24/// Note: A comptime-known upper bound of this value that may be used
25/// instead if `scalar` is not already comptime-known is25/// instead if `scalar` is not already comptime-known is
26/// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).Int.bits)`26/// `calcTwosCompLimbCount(@typeInfo(@TypeOf(scalar)).int.bits)`
27pub fn calcLimbLen(scalar: anytype) usize {27pub fn calcLimbLen(scalar: anytype) usize {
28 if (scalar == 0) {28 if (scalar == 0) {
29 return 1;29 return 1;
...@@ -236,7 +236,7 @@ pub const Mutable = struct {...@@ -236,7 +236,7 @@ pub const Mutable = struct {
236 self.positive = value >= 0;236 self.positive = value >= 0;
237237
238 switch (@typeInfo(T)) {238 switch (@typeInfo(T)) {
239 .Int => |info| {239 .int => |info| {
240 var w_value = @abs(value);240 var w_value = @abs(value);
241241
242 if (info.bits <= limb_bits) {242 if (info.bits <= limb_bits) {
...@@ -251,7 +251,7 @@ pub const Mutable = struct {...@@ -251,7 +251,7 @@ pub const Mutable = struct {
251 }251 }
252 }252 }
253 },253 },
254 .ComptimeInt => {254 .comptime_int => {
255 comptime var w_value = @abs(value);255 comptime var w_value = @abs(value);
256256
257 if (w_value <= maxInt(Limb)) {257 if (w_value <= maxInt(Limb)) {
...@@ -405,8 +405,8 @@ pub const Mutable = struct {...@@ -405,8 +405,8 @@ pub const Mutable = struct {
405 // is well worth being able to use the stack and not needing an allocator passed in.405 // is well worth being able to use the stack and not needing an allocator passed in.
406 // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.406 // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
407 const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {407 const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
408 .ComptimeInt => calcLimbLen(scalar),408 .comptime_int => calcLimbLen(scalar),
409 .Int => |info| calcTwosCompLimbCount(info.bits),409 .int => |info| calcTwosCompLimbCount(info.bits),
410 else => @compileError("expected scalar to be an int"),410 else => @compileError("expected scalar to be an int"),
411 };411 };
412 var limbs: [limb_len]Limb = undefined;412 var limbs: [limb_len]Limb = undefined;
...@@ -2158,7 +2158,7 @@ pub const Const = struct {...@@ -2158,7 +2158,7 @@ pub const Const = struct {
21582158
2159 /// Returns whether self can fit into an integer of the requested type.2159 /// Returns whether self can fit into an integer of the requested type.
2160 pub fn fits(self: Const, comptime T: type) bool {2160 pub fn fits(self: Const, comptime T: type) bool {
2161 const info = @typeInfo(T).Int;2161 const info = @typeInfo(T).int;
2162 return self.fitsInTwosComp(info.signedness, info.bits);2162 return self.fitsInTwosComp(info.signedness, info.bits);
2163 }2163 }
21642164
...@@ -2181,7 +2181,7 @@ pub const Const = struct {...@@ -2181,7 +2181,7 @@ pub const Const = struct {
2181 /// Returns an error if self cannot be narrowed into the requested type without truncation.2181 /// Returns an error if self cannot be narrowed into the requested type without truncation.
2182 pub fn to(self: Const, comptime T: type) ConvertError!T {2182 pub fn to(self: Const, comptime T: type) ConvertError!T {
2183 switch (@typeInfo(T)) {2183 switch (@typeInfo(T)) {
2184 .Int => |info| {2184 .int => |info| {
2185 // Make sure -0 is handled correctly.2185 // Make sure -0 is handled correctly.
2186 if (self.eqlZero()) return 0;2186 if (self.eqlZero()) return 0;
21872187
...@@ -2495,8 +2495,8 @@ pub const Const = struct {...@@ -2495,8 +2495,8 @@ pub const Const = struct {
2495 // is well worth being able to use the stack and not needing an allocator passed in.2495 // is well worth being able to use the stack and not needing an allocator passed in.
2496 // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.2496 // Note that Mutable.init still sets len to calcLimbLen(scalar) in any case.
2497 const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {2497 const limb_len = comptime switch (@typeInfo(@TypeOf(scalar))) {
2498 .ComptimeInt => calcLimbLen(scalar),2498 .comptime_int => calcLimbLen(scalar),
2499 .Int => |info| calcTwosCompLimbCount(info.bits),2499 .int => |info| calcTwosCompLimbCount(info.bits),
2500 else => @compileError("expected scalar to be an int"),2500 else => @compileError("expected scalar to be an int"),
2501 };2501 };
2502 var limbs: [limb_len]Limb = undefined;2502 var limbs: [limb_len]Limb = undefined;
...@@ -2555,7 +2555,7 @@ pub const Const = struct {...@@ -2555,7 +2555,7 @@ pub const Const = struct {
2555/// Memory is allocated as needed to ensure operations never overflow. The range2555/// Memory is allocated as needed to ensure operations never overflow. The range
2556/// is bounded only by available memory.2556/// is bounded only by available memory.
2557pub const Managed = struct {2557pub const Managed = struct {
2558 pub const sign_bit: usize = 1 << (@typeInfo(usize).Int.bits - 1);2558 pub const sign_bit: usize = 1 << (@typeInfo(usize).int.bits - 1);
25592559
2560 /// Default number of limbs to allocate on creation of a `Managed`.2560 /// Default number of limbs to allocate on creation of a `Managed`.
2561 pub const default_capacity = 4;2561 pub const default_capacity = 4;
lib/std/math/big/int_test.zig+13-13
...@@ -22,13 +22,13 @@ test "comptime_int set" {...@@ -22,13 +22,13 @@ test "comptime_int set" {
22 var a = try Managed.initSet(testing.allocator, s);22 var a = try Managed.initSet(testing.allocator, s);
23 defer a.deinit();23 defer a.deinit();
2424
25 const s_limb_count = 128 / @typeInfo(Limb).Int.bits;25 const s_limb_count = 128 / @typeInfo(Limb).int.bits;
2626
27 comptime var i: usize = 0;27 comptime var i: usize = 0;
28 inline while (i < s_limb_count) : (i += 1) {28 inline while (i < s_limb_count) : (i += 1) {
29 const result = @as(Limb, s & maxInt(Limb));29 const result = @as(Limb, s & maxInt(Limb));
30 s >>= @typeInfo(Limb).Int.bits / 2;30 s >>= @typeInfo(Limb).int.bits / 2;
31 s >>= @typeInfo(Limb).Int.bits / 2;31 s >>= @typeInfo(Limb).int.bits / 2;
32 try testing.expect(a.limbs[i] == result);32 try testing.expect(a.limbs[i] == result);
33 }33 }
34}34}
...@@ -299,7 +299,7 @@ test "twos complement limit set" {...@@ -299,7 +299,7 @@ test "twos complement limit set" {
299}299}
300300
301fn testTwosComplementLimit(comptime T: type) !void {301fn testTwosComplementLimit(comptime T: type) !void {
302 const int_info = @typeInfo(T).Int;302 const int_info = @typeInfo(T).int;
303303
304 var a = try Managed.init(testing.allocator);304 var a = try Managed.init(testing.allocator);
305 defer a.deinit();305 defer a.deinit();
...@@ -1893,7 +1893,7 @@ test "truncate multi to single signed" {...@@ -1893,7 +1893,7 @@ test "truncate multi to single signed" {
1893}1893}
18941894
1895test "truncate multi to multi unsigned" {1895test "truncate multi to multi unsigned" {
1896 const bits = @typeInfo(SignedDoubleLimb).Int.bits;1896 const bits = @typeInfo(SignedDoubleLimb).int.bits;
1897 const Int = std.meta.Int(.unsigned, bits - 1);1897 const Int = std.meta.Int(.unsigned, bits - 1);
18981898
1899 var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));1899 var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));
...@@ -2239,11 +2239,11 @@ test "bitNotWrap more than two limbs" {...@@ -2239,11 +2239,11 @@ test "bitNotWrap more than two limbs" {
2239 const bits = @bitSizeOf(Limb) * 4 + 2;2239 const bits = @bitSizeOf(Limb) * 4 + 2;
22402240
2241 try res.bitNotWrap(&a, .unsigned, bits);2241 try res.bitNotWrap(&a, .unsigned, bits);
2242 const Unsigned = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = bits } });2242 const Unsigned = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits } });
2243 try testing.expectEqual((try res.to(Unsigned)), ~@as(Unsigned, maxInt(Limb)));2243 try testing.expectEqual((try res.to(Unsigned)), ~@as(Unsigned, maxInt(Limb)));
22442244
2245 try res.bitNotWrap(&a, .signed, bits);2245 try res.bitNotWrap(&a, .signed, bits);
2246 const Signed = @Type(.{ .Int = .{ .signedness = .signed, .bits = bits } });2246 const Signed = @Type(.{ .int = .{ .signedness = .signed, .bits = bits } });
2247 try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb)));2247 try testing.expectEqual((try res.to(Signed)), ~@as(Signed, maxInt(Limb)));
2248}2248}
22492249
...@@ -3037,8 +3037,8 @@ test "big int conversion write twos complement zero" {...@@ -3037,8 +3037,8 @@ test "big int conversion write twos complement zero" {
3037}3037}
30383038
3039fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void {3039fn bitReverseTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void {
3040 const bit_count = @typeInfo(T).Int.bits;3040 const bit_count = @typeInfo(T).int.bits;
3041 const signedness = @typeInfo(T).Int.signedness;3041 const signedness = @typeInfo(T).int.signedness;
30423042
3043 var a = try Managed.initSet(testing.allocator, input);3043 var a = try Managed.initSet(testing.allocator, input);
3044 defer a.deinit();3044 defer a.deinit();
...@@ -3084,8 +3084,8 @@ test "big int bit reverse" {...@@ -3084,8 +3084,8 @@ test "big int bit reverse" {
3084}3084}
30853085
3086fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void {3086fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expected_output: comptime_int) !void {
3087 const byte_count = @typeInfo(T).Int.bits / 8;3087 const byte_count = @typeInfo(T).int.bits / 8;
3088 const signedness = @typeInfo(T).Int.signedness;3088 const signedness = @typeInfo(T).int.signedness;
30893089
3090 var a = try Managed.initSet(testing.allocator, input);3090 var a = try Managed.initSet(testing.allocator, input);
3091 defer a.deinit();3091 defer a.deinit();
...@@ -3151,7 +3151,7 @@ test "mul multi-multi alias r with a and b" {...@@ -3151,7 +3151,7 @@ test "mul multi-multi alias r with a and b" {
31513151
3152 try testing.expect(a.eql(want));3152 try testing.expect(a.eql(want));
31533153
3154 if (@typeInfo(Limb).Int.bits == 64) {3154 if (@typeInfo(Limb).int.bits == 64) {
3155 try testing.expectEqual(@as(usize, 5), a.limbs.len);3155 try testing.expectEqual(@as(usize, 5), a.limbs.len);
3156 }3156 }
3157}3157}
...@@ -3167,7 +3167,7 @@ test "sqr multi alias r with a" {...@@ -3167,7 +3167,7 @@ test "sqr multi alias r with a" {
31673167
3168 try testing.expect(a.eql(want));3168 try testing.expect(a.eql(want));
31693169
3170 if (@typeInfo(Limb).Int.bits == 64) {3170 if (@typeInfo(Limb).int.bits == 64) {
3171 try testing.expectEqual(@as(usize, 5), a.limbs.len);3171 try testing.expectEqual(@as(usize, 5), a.limbs.len);
3172 }3172 }
3173}3173}
lib/std/math/big/rational.zig+7-7
...@@ -135,9 +135,9 @@ pub const Rational = struct {...@@ -135,9 +135,9 @@ pub const Rational = struct {
135 /// completely represent the provided float.135 /// completely represent the provided float.
136 pub fn setFloat(self: *Rational, comptime T: type, f: T) !void {136 pub fn setFloat(self: *Rational, comptime T: type, f: T) !void {
137 // Translated from golang.go/src/math/big/rat.go.137 // Translated from golang.go/src/math/big/rat.go.
138 debug.assert(@typeInfo(T) == .Float);138 debug.assert(@typeInfo(T) == .float);
139139
140 const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);140 const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
141 const f_bits = @as(UnsignedInt, @bitCast(f));141 const f_bits = @as(UnsignedInt, @bitCast(f));
142142
143 const exponent_bits = math.floatExponentBits(T);143 const exponent_bits = math.floatExponentBits(T);
...@@ -193,9 +193,9 @@ pub const Rational = struct {...@@ -193,9 +193,9 @@ pub const Rational = struct {
193 pub fn toFloat(self: Rational, comptime T: type) !T {193 pub fn toFloat(self: Rational, comptime T: type) !T {
194 // Translated from golang.go/src/math/big/rat.go.194 // Translated from golang.go/src/math/big/rat.go.
195 // TODO: Indicate whether the result is not exact.195 // TODO: Indicate whether the result is not exact.
196 debug.assert(@typeInfo(T) == .Float);196 debug.assert(@typeInfo(T) == .float);
197197
198 const fsize = @typeInfo(T).Float.bits;198 const fsize = @typeInfo(T).float.bits;
199 const BitReprType = std.meta.Int(.unsigned, fsize);199 const BitReprType = std.meta.Int(.unsigned, fsize);
200200
201 const msize = math.floatMantissaBits(T);201 const msize = math.floatMantissaBits(T);
...@@ -473,10 +473,10 @@ pub const Rational = struct {...@@ -473,10 +473,10 @@ pub const Rational = struct {
473};473};
474474
475fn extractLowBits(a: Int, comptime T: type) T {475fn extractLowBits(a: Int, comptime T: type) T {
476 debug.assert(@typeInfo(T) == .Int);476 debug.assert(@typeInfo(T) == .int);
477477
478 const t_bits = @typeInfo(T).Int.bits;478 const t_bits = @typeInfo(T).int.bits;
479 const limb_bits = @typeInfo(Limb).Int.bits;479 const limb_bits = @typeInfo(Limb).int.bits;
480 if (t_bits <= limb_bits) {480 if (t_bits <= limb_bits) {
481 return @as(T, @truncate(a.limbs[0]));481 return @as(T, @truncate(a.limbs[0]));
482 } else {482 } else {
lib/std/math/copysign.zig+1-1
...@@ -5,7 +5,7 @@ const expect = std.testing.expect;...@@ -5,7 +5,7 @@ const expect = std.testing.expect;
5/// Returns a value with the magnitude of `magnitude` and the sign of `sign`.5/// Returns a value with the magnitude of `magnitude` and the sign of `sign`.
6pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) {6pub fn copysign(magnitude: anytype, sign: @TypeOf(magnitude)) @TypeOf(magnitude) {
7 const T = @TypeOf(magnitude);7 const T = @TypeOf(magnitude);
8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
9 const sign_bit_mask = @as(TBits, 1) << (@bitSizeOf(T) - 1);9 const sign_bit_mask = @as(TBits, 1) << (@bitSizeOf(T) - 1);
10 const mag = @as(TBits, @bitCast(magnitude)) & ~sign_bit_mask;10 const mag = @as(TBits, @bitCast(magnitude)) & ~sign_bit_mask;
11 const sgn = @as(TBits, @bitCast(sign)) & sign_bit_mask;11 const sgn = @as(TBits, @bitCast(sign)) & sign_bit_mask;
lib/std/math/float.zig+10-10
...@@ -6,21 +6,21 @@ const expectEqual = std.testing.expectEqual;...@@ -6,21 +6,21 @@ const expectEqual = std.testing.expectEqual;
66
7/// Creates a raw "1.0" mantissa for floating point type T. Used to dedupe f80 logic.7/// Creates a raw "1.0" mantissa for floating point type T. Used to dedupe f80 logic.
8inline fn mantissaOne(comptime T: type) comptime_int {8inline fn mantissaOne(comptime T: type) comptime_int {
9 return if (@typeInfo(T).Float.bits == 80) 1 << floatFractionalBits(T) else 0;9 return if (@typeInfo(T).float.bits == 80) 1 << floatFractionalBits(T) else 0;
10}10}
1111
12/// Creates floating point type T from an unbiased exponent and raw mantissa.12/// Creates floating point type T from an unbiased exponent and raw mantissa.
13inline fn reconstructFloat(comptime T: type, comptime exponent: comptime_int, comptime mantissa: comptime_int) T {13inline fn reconstructFloat(comptime T: type, comptime exponent: comptime_int, comptime mantissa: comptime_int) T {
14 const TBits = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });14 const TBits = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @bitSizeOf(T) } });
15 const biased_exponent = @as(TBits, exponent + floatExponentMax(T));15 const biased_exponent = @as(TBits, exponent + floatExponentMax(T));
16 return @as(T, @bitCast((biased_exponent << floatMantissaBits(T)) | @as(TBits, mantissa)));16 return @as(T, @bitCast((biased_exponent << floatMantissaBits(T)) | @as(TBits, mantissa)));
17}17}
1818
19/// Returns the number of bits in the exponent of floating point type T.19/// Returns the number of bits in the exponent of floating point type T.
20pub inline fn floatExponentBits(comptime T: type) comptime_int {20pub inline fn floatExponentBits(comptime T: type) comptime_int {
21 comptime assert(@typeInfo(T) == .Float);21 comptime assert(@typeInfo(T) == .float);
2222
23 return switch (@typeInfo(T).Float.bits) {23 return switch (@typeInfo(T).float.bits) {
24 16 => 5,24 16 => 5,
25 32 => 8,25 32 => 8,
26 64 => 11,26 64 => 11,
...@@ -32,9 +32,9 @@ pub inline fn floatExponentBits(comptime T: type) comptime_int {...@@ -32,9 +32,9 @@ pub inline fn floatExponentBits(comptime T: type) comptime_int {
3232
33/// Returns the number of bits in the mantissa of floating point type T.33/// Returns the number of bits in the mantissa of floating point type T.
34pub inline fn floatMantissaBits(comptime T: type) comptime_int {34pub inline fn floatMantissaBits(comptime T: type) comptime_int {
35 comptime assert(@typeInfo(T) == .Float);35 comptime assert(@typeInfo(T) == .float);
3636
37 return switch (@typeInfo(T).Float.bits) {37 return switch (@typeInfo(T).float.bits) {
38 16 => 10,38 16 => 10,
39 32 => 23,39 32 => 23,
40 64 => 52,40 64 => 52,
...@@ -46,12 +46,12 @@ pub inline fn floatMantissaBits(comptime T: type) comptime_int {...@@ -46,12 +46,12 @@ pub inline fn floatMantissaBits(comptime T: type) comptime_int {
4646
47/// Returns the number of fractional bits in the mantissa of floating point type T.47/// Returns the number of fractional bits in the mantissa of floating point type T.
48pub inline fn floatFractionalBits(comptime T: type) comptime_int {48pub inline fn floatFractionalBits(comptime T: type) comptime_int {
49 comptime assert(@typeInfo(T) == .Float);49 comptime assert(@typeInfo(T) == .float);
5050
51 // standard IEEE floats have an implicit 0.m or 1.m integer part51 // standard IEEE floats have an implicit 0.m or 1.m integer part
52 // f80 is special and has an explicitly stored bit in the MSB52 // f80 is special and has an explicitly stored bit in the MSB
53 // this function corresponds to `MANT_DIG - 1' from C53 // this function corresponds to `MANT_DIG - 1' from C
54 return switch (@typeInfo(T).Float.bits) {54 return switch (@typeInfo(T).float.bits) {
55 16 => 10,55 16 => 10,
56 32 => 23,56 32 => 23,
57 64 => 52,57 64 => 52,
...@@ -97,8 +97,8 @@ pub inline fn floatEps(comptime T: type) T {...@@ -97,8 +97,8 @@ pub inline fn floatEps(comptime T: type) T {
97/// Returns the local epsilon of floating point type T.97/// Returns the local epsilon of floating point type T.
98pub inline fn floatEpsAt(comptime T: type, x: T) T {98pub inline fn floatEpsAt(comptime T: type, x: T) T {
99 switch (@typeInfo(T)) {99 switch (@typeInfo(T)) {
100 .Float => |F| {100 .float => |F| {
101 const U: type = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = F.bits } });101 const U: type = @Type(.{ .int = .{ .signedness = .unsigned, .bits = F.bits } });
102 const u: U = @bitCast(x);102 const u: U = @bitCast(x);
103 const y: T = @bitCast(u ^ 1);103 const y: T = @bitCast(u ^ 1);
104 return @abs(x - y);104 return @abs(x - y);
lib/std/math/frexp.zig+1-1
...@@ -21,7 +21,7 @@ pub fn Frexp(comptime T: type) type {...@@ -21,7 +21,7 @@ pub fn Frexp(comptime T: type) type {
21pub fn frexp(x: anytype) Frexp(@TypeOf(x)) {21pub fn frexp(x: anytype) Frexp(@TypeOf(x)) {
22 const T: type = @TypeOf(x);22 const T: type = @TypeOf(x);
2323
24 const bits: comptime_int = @typeInfo(T).Float.bits;24 const bits: comptime_int = @typeInfo(T).float.bits;
25 const Int: type = std.meta.Int(.unsigned, bits);25 const Int: type = std.meta.Int(.unsigned, bits);
2626
27 const exp_bits: comptime_int = math.floatExponentBits(T);27 const exp_bits: comptime_int = math.floatExponentBits(T);
lib/std/math/gcd.zig+2-2
...@@ -8,8 +8,8 @@ pub fn gcd(a: anytype, b: anytype) @TypeOf(a, b) {...@@ -8,8 +8,8 @@ pub fn gcd(a: anytype, b: anytype) @TypeOf(a, b) {
88
9 // only unsigned integers are allowed and not both must be zero9 // only unsigned integers are allowed and not both must be zero
10 comptime switch (@typeInfo(@TypeOf(a, b))) {10 comptime switch (@typeInfo(@TypeOf(a, b))) {
11 .Int => |int| std.debug.assert(int.signedness == .unsigned),11 .int => |int| std.debug.assert(int.signedness == .unsigned),
12 .ComptimeInt => {12 .comptime_int => {
13 std.debug.assert(a >= 0);13 std.debug.assert(a >= 0);
14 std.debug.assert(b >= 0);14 std.debug.assert(b >= 0);
15 },15 },
lib/std/math/hypot.zig+2-2
...@@ -23,8 +23,8 @@ const floatMax = math.floatMax;...@@ -23,8 +23,8 @@ const floatMax = math.floatMax;
23pub fn hypot(x: anytype, y: anytype) @TypeOf(x, y) {23pub fn hypot(x: anytype, y: anytype) @TypeOf(x, y) {
24 const T = @TypeOf(x, y);24 const T = @TypeOf(x, y);
25 switch (@typeInfo(T)) {25 switch (@typeInfo(T)) {
26 .Float => {},26 .float => {},
27 .ComptimeFloat => return @sqrt(x * x + y * y),27 .comptime_float => return @sqrt(x * x + y * y),
28 else => @compileError("hypot not implemented for " ++ @typeName(T)),28 else => @compileError("hypot not implemented for " ++ @typeName(T)),
29 }29 }
30 const lower = @sqrt(floatMin(T));30 const lower = @sqrt(floatMin(T));
lib/std/math/ilogb.zig+1-1
...@@ -26,7 +26,7 @@ pub const fp_ilogbnan = minInt(i32);...@@ -26,7 +26,7 @@ pub const fp_ilogbnan = minInt(i32);
26pub const fp_ilogb0 = minInt(i32);26pub const fp_ilogb0 = minInt(i32);
2727
28fn ilogbX(comptime T: type, x: T) i32 {28fn ilogbX(comptime T: type, x: T) i32 {
29 const typeWidth = @typeInfo(T).Float.bits;29 const typeWidth = @typeInfo(T).float.bits;
30 const significandBits = math.floatMantissaBits(T);30 const significandBits = math.floatMantissaBits(T);
31 const exponentBits = math.floatExponentBits(T);31 const exponentBits = math.floatExponentBits(T);
3232
lib/std/math/isfinite.zig+1-1
...@@ -5,7 +5,7 @@ const expect = std.testing.expect;...@@ -5,7 +5,7 @@ const expect = std.testing.expect;
5/// Returns whether x is a finite value.5/// Returns whether x is a finite value.
6pub fn isFinite(x: anytype) bool {6pub fn isFinite(x: anytype) bool {
7 const T = @TypeOf(x);7 const T = @TypeOf(x);
8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
9 const remove_sign = ~@as(TBits, 0) >> 1;9 const remove_sign = ~@as(TBits, 0) >> 1;
10 return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T)));10 return @as(TBits, @bitCast(x)) & remove_sign < @as(TBits, @bitCast(math.inf(T)));
11}11}
lib/std/math/isinf.zig+1-1
...@@ -5,7 +5,7 @@ const expect = std.testing.expect;...@@ -5,7 +5,7 @@ const expect = std.testing.expect;
5/// Returns whether x is an infinity, ignoring sign.5/// Returns whether x is an infinity, ignoring sign.
6pub inline fn isInf(x: anytype) bool {6pub inline fn isInf(x: anytype) bool {
7 const T = @TypeOf(x);7 const T = @TypeOf(x);
8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
9 const remove_sign = ~@as(TBits, 0) >> 1;9 const remove_sign = ~@as(TBits, 0) >> 1;
10 return @as(TBits, @bitCast(x)) & remove_sign == @as(TBits, @bitCast(math.inf(T)));10 return @as(TBits, @bitCast(x)) & remove_sign == @as(TBits, @bitCast(math.inf(T)));
11}11}
lib/std/math/isnormal.zig+1-1
...@@ -5,7 +5,7 @@ const expect = std.testing.expect;...@@ -5,7 +5,7 @@ const expect = std.testing.expect;
5/// Returns whether x is neither zero, subnormal, infinity, or NaN.5/// Returns whether x is neither zero, subnormal, infinity, or NaN.
6pub fn isNormal(x: anytype) bool {6pub fn isNormal(x: anytype) bool {
7 const T = @TypeOf(x);7 const T = @TypeOf(x);
8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
99
10 const increment_exp = 1 << math.floatMantissaBits(T);10 const increment_exp = 1 << math.floatMantissaBits(T);
11 const remove_sign = ~@as(TBits, 0) >> 1;11 const remove_sign = ~@as(TBits, 0) >> 1;
lib/std/math/iszero.zig+2-2
...@@ -5,7 +5,7 @@ const expect = std.testing.expect;...@@ -5,7 +5,7 @@ const expect = std.testing.expect;
5/// Returns whether x is positive zero.5/// Returns whether x is positive zero.
6pub inline fn isPositiveZero(x: anytype) bool {6pub inline fn isPositiveZero(x: anytype) bool {
7 const T = @TypeOf(x);7 const T = @TypeOf(x);
8 const bit_count = @typeInfo(T).Float.bits;8 const bit_count = @typeInfo(T).float.bits;
9 const TBits = std.meta.Int(.unsigned, bit_count);9 const TBits = std.meta.Int(.unsigned, bit_count);
10 return @as(TBits, @bitCast(x)) == @as(TBits, 0);10 return @as(TBits, @bitCast(x)) == @as(TBits, 0);
11}11}
...@@ -13,7 +13,7 @@ pub inline fn isPositiveZero(x: anytype) bool {...@@ -13,7 +13,7 @@ pub inline fn isPositiveZero(x: anytype) bool {
13/// Returns whether x is negative zero.13/// Returns whether x is negative zero.
14pub inline fn isNegativeZero(x: anytype) bool {14pub inline fn isNegativeZero(x: anytype) bool {
15 const T = @TypeOf(x);15 const T = @TypeOf(x);
16 const bit_count = @typeInfo(T).Float.bits;16 const bit_count = @typeInfo(T).float.bits;
17 const TBits = std.meta.Int(.unsigned, bit_count);17 const TBits = std.meta.Int(.unsigned, bit_count);
18 return @as(TBits, @bitCast(x)) == @as(TBits, 1) << (bit_count - 1);18 return @as(TBits, @bitCast(x)) == @as(TBits, 1) << (bit_count - 1);
19}19}
lib/std/math/ldexp.zig+1-1
...@@ -7,7 +7,7 @@ const expect = std.testing.expect;...@@ -7,7 +7,7 @@ const expect = std.testing.expect;
7/// Returns x * 2^n.7/// Returns x * 2^n.
8pub fn ldexp(x: anytype, n: i32) @TypeOf(x) {8pub fn ldexp(x: anytype, n: i32) @TypeOf(x) {
9 const T = @TypeOf(x);9 const T = @TypeOf(x);
10 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);10 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
1111
12 const exponent_bits = math.floatExponentBits(T);12 const exponent_bits = math.floatExponentBits(T);
13 const mantissa_bits = math.floatMantissaBits(T);13 const mantissa_bits = math.floatMantissaBits(T);
lib/std/math/log.zig+5-5
...@@ -14,26 +14,26 @@ pub fn log(comptime T: type, base: T, x: T) T {...@@ -14,26 +14,26 @@ pub fn log(comptime T: type, base: T, x: T) T {
14 return math.log2(x);14 return math.log2(x);
15 } else if (base == 10) {15 } else if (base == 10) {
16 return math.log10(x);16 return math.log10(x);
17 } else if ((@typeInfo(T) == .Float or @typeInfo(T) == .ComptimeFloat) and base == math.e) {17 } else if ((@typeInfo(T) == .float or @typeInfo(T) == .comptime_float) and base == math.e) {
18 return @log(x);18 return @log(x);
19 }19 }
2020
21 const float_base = math.lossyCast(f64, base);21 const float_base = math.lossyCast(f64, base);
22 switch (@typeInfo(T)) {22 switch (@typeInfo(T)) {
23 .ComptimeFloat => {23 .comptime_float => {
24 return @as(comptime_float, @log(@as(f64, x)) / @log(float_base));24 return @as(comptime_float, @log(@as(f64, x)) / @log(float_base));
25 },25 },
2626
27 .ComptimeInt => {27 .comptime_int => {
28 return @as(comptime_int, math.log_int(comptime_int, base, x));28 return @as(comptime_int, math.log_int(comptime_int, base, x));
29 },29 },
3030
31 .Int => |IntType| switch (IntType.signedness) {31 .int => |IntType| switch (IntType.signedness) {
32 .signed => @compileError("log not implemented for signed integers"),32 .signed => @compileError("log not implemented for signed integers"),
33 .unsigned => return @as(T, math.log_int(T, base, x)),33 .unsigned => return @as(T, math.log_int(T, base, x)),
34 },34 },
3535
36 .Float => {36 .float => {
37 switch (T) {37 switch (T) {
38 f32 => return @as(f32, @floatCast(@log(@as(f64, x)) / @log(float_base))),38 f32 => return @as(f32, @floatCast(@log(@as(f64, x)) / @log(float_base))),
39 f64 => return @log(x) / @log(float_base),39 f64 => return @log(x) / @log(float_base),
lib/std/math/log10.zig+6-6
...@@ -12,14 +12,14 @@ const testing = std.testing;...@@ -12,14 +12,14 @@ const testing = std.testing;
12pub fn log10(x: anytype) @TypeOf(x) {12pub fn log10(x: anytype) @TypeOf(x) {
13 const T = @TypeOf(x);13 const T = @TypeOf(x);
14 switch (@typeInfo(T)) {14 switch (@typeInfo(T)) {
15 .ComptimeFloat => {15 .comptime_float => {
16 return @as(comptime_float, @log10(x));16 return @as(comptime_float, @log10(x));
17 },17 },
18 .Float => return @log10(x),18 .float => return @log10(x),
19 .ComptimeInt => {19 .comptime_int => {
20 return @as(comptime_int, @floor(@log10(@as(f64, x))));20 return @as(comptime_int, @floor(@log10(@as(f64, x))));
21 },21 },
22 .Int => |IntType| switch (IntType.signedness) {22 .int => |IntType| switch (IntType.signedness) {
23 .signed => @compileError("log10 not implemented for signed integers"),23 .signed => @compileError("log10 not implemented for signed integers"),
24 .unsigned => return log10_int(x),24 .unsigned => return log10_int(x),
25 },25 },
...@@ -37,12 +37,12 @@ pub fn log10(x: anytype) @TypeOf(x) {...@@ -37,12 +37,12 @@ pub fn log10(x: anytype) @TypeOf(x) {
37pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) {37pub fn log10_int(x: anytype) std.math.Log2Int(@TypeOf(x)) {
38 const T = @TypeOf(x);38 const T = @TypeOf(x);
39 const OutT = std.math.Log2Int(T);39 const OutT = std.math.Log2Int(T);
40 if (@typeInfo(T) != .Int or @typeInfo(T).Int.signedness != .unsigned)40 if (@typeInfo(T) != .int or @typeInfo(T).int.signedness != .unsigned)
41 @compileError("log10_int requires an unsigned integer, found " ++ @typeName(T));41 @compileError("log10_int requires an unsigned integer, found " ++ @typeName(T));
4242
43 std.debug.assert(x != 0);43 std.debug.assert(x != 0);
4444
45 const bit_size = @typeInfo(T).Int.bits;45 const bit_size = @typeInfo(T).int.bits;
4646
47 if (bit_size <= 8) {47 if (bit_size <= 8) {
48 return @as(OutT, @intCast(log10_int_u8(x)));48 return @as(OutT, @intCast(log10_int_u8(x)));
lib/std/math/log2.zig+4-4
...@@ -13,11 +13,11 @@ const expect = std.testing.expect;...@@ -13,11 +13,11 @@ const expect = std.testing.expect;
13pub fn log2(x: anytype) @TypeOf(x) {13pub fn log2(x: anytype) @TypeOf(x) {
14 const T = @TypeOf(x);14 const T = @TypeOf(x);
15 switch (@typeInfo(T)) {15 switch (@typeInfo(T)) {
16 .ComptimeFloat => {16 .comptime_float => {
17 return @as(comptime_float, @log2(x));17 return @as(comptime_float, @log2(x));
18 },18 },
19 .Float => return @log2(x),19 .float => return @log2(x),
20 .ComptimeInt => comptime {20 .comptime_int => comptime {
21 var x_shifted = x;21 var x_shifted = x;
22 // First, calculate floorPowerOfTwo(x)22 // First, calculate floorPowerOfTwo(x)
23 var shift_amt = 1;23 var shift_amt = 1;
...@@ -34,7 +34,7 @@ pub fn log2(x: anytype) @TypeOf(x) {...@@ -34,7 +34,7 @@ pub fn log2(x: anytype) @TypeOf(x) {
34 }34 }
35 return result;35 return result;
36 },36 },
37 .Int => |IntType| switch (IntType.signedness) {37 .int => |IntType| switch (IntType.signedness) {
38 .signed => @compileError("log2 not implemented for signed integers"),38 .signed => @compileError("log2 not implemented for signed integers"),
39 .unsigned => return math.log2_int(T, x),39 .unsigned => return math.log2_int(T, x),
40 },40 },
lib/std/math/log_int.zig+3-5
...@@ -8,8 +8,8 @@ const Log2Int = math.Log2Int;...@@ -8,8 +8,8 @@ const Log2Int = math.Log2Int;
8/// Asserts that `base > 1` and `x > 0`.8/// Asserts that `base > 1` and `x > 0`.
9pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) {9pub fn log_int(comptime T: type, base: T, x: T) Log2Int(T) {
10 const valid = switch (@typeInfo(T)) {10 const valid = switch (@typeInfo(T)) {
11 .ComptimeInt => true,11 .comptime_int => true,
12 .Int => |IntType| IntType.signedness == .unsigned,12 .int => |IntType| IntType.signedness == .unsigned,
13 else => false,13 else => false,
14 };14 };
15 if (!valid) @compileError("log_int requires an unsigned integer, found " ++ @typeName(T));15 if (!valid) @compileError("log_int requires an unsigned integer, found " ++ @typeName(T));
...@@ -64,9 +64,7 @@ test "log_int" {...@@ -64,9 +64,7 @@ test "log_int" {
64 // Test all unsigned integers with 2, 3, ..., 64 bits.64 // Test all unsigned integers with 2, 3, ..., 64 bits.
65 // We cannot test 0 or 1 bits since base must be > 1.65 // We cannot test 0 or 1 bits since base must be > 1.
66 inline for (2..64 + 1) |bits| {66 inline for (2..64 + 1) |bits| {
67 const T = @Type(std.builtin.Type{67 const T = @Type(.{ .int = .{ .signedness = .unsigned, .bits = @intCast(bits) } });
68 .Int = std.builtin.Type.Int{ .signedness = .unsigned, .bits = @intCast(bits) },
69 });
7068
71 // for base = 2, 3, ..., min(maxInt(T),1024)69 // for base = 2, 3, ..., min(maxInt(T),1024)
72 var base: T = 1;70 var base: T = 1;
lib/std/math/nextafter.zig+6-6
...@@ -14,15 +14,15 @@ const expect = std.testing.expect;...@@ -14,15 +14,15 @@ const expect = std.testing.expect;
14///14///
15pub fn nextAfter(comptime T: type, x: T, y: T) T {15pub fn nextAfter(comptime T: type, x: T, y: T) T {
16 return switch (@typeInfo(T)) {16 return switch (@typeInfo(T)) {
17 .Int, .ComptimeInt => nextAfterInt(T, x, y),17 .int, .comptime_int => nextAfterInt(T, x, y),
18 .Float => nextAfterFloat(T, x, y),18 .float => nextAfterFloat(T, x, y),
19 else => @compileError("expected int or non-comptime float, found '" ++ @typeName(T) ++ "'"),19 else => @compileError("expected int or non-comptime float, found '" ++ @typeName(T) ++ "'"),
20 };20 };
21}21}
2222
23fn nextAfterInt(comptime T: type, x: T, y: T) T {23fn nextAfterInt(comptime T: type, x: T, y: T) T {
24 comptime assert(@typeInfo(T) == .Int or @typeInfo(T) == .ComptimeInt);24 comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int);
25 return if (@typeInfo(T) == .Int and @bitSizeOf(T) < 2)25 return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2)
26 // Special case for `i0`, `u0`, `i1`, and `u1`.26 // Special case for `i0`, `u0`, `i1`, and `u1`.
27 y27 y
28 else if (y > x)28 else if (y > x)
...@@ -38,7 +38,7 @@ fn nextAfterInt(comptime T: type, x: T, y: T) T {...@@ -38,7 +38,7 @@ fn nextAfterInt(comptime T: type, x: T, y: T) T {
38// <https://github.com/mingw-w64/mingw-w64/blob/e89de847dd3e05bb8e46344378ce3e124f4e7d1c/mingw-w64-crt/math/nextafterl.c>38// <https://github.com/mingw-w64/mingw-w64/blob/e89de847dd3e05bb8e46344378ce3e124f4e7d1c/mingw-w64-crt/math/nextafterl.c>
3939
40fn nextAfterFloat(comptime T: type, x: T, y: T) T {40fn nextAfterFloat(comptime T: type, x: T, y: T) T {
41 comptime assert(@typeInfo(T) == .Float);41 comptime assert(@typeInfo(T) == .float);
42 if (x == y) {42 if (x == y) {
43 // Returning `y` ensures that (0.0, -0.0) returns -0.0 and that (-0.0, 0.0) returns 0.0.43 // Returning `y` ensures that (0.0, -0.0) returns -0.0 and that (-0.0, 0.0) returns 0.0.
44 return y;44 return y;
...@@ -320,7 +320,7 @@ test "float" {...@@ -320,7 +320,7 @@ test "float" {
320320
321/// Helps ensure that 0.0 doesn't compare equal to -0.0.321/// Helps ensure that 0.0 doesn't compare equal to -0.0.
322fn bitwiseEqual(comptime T: type, x: T, y: T) bool {322fn bitwiseEqual(comptime T: type, x: T, y: T) bool {
323 comptime assert(@typeInfo(T) == .Float);323 comptime assert(@typeInfo(T) == .float);
324 const Bits = std.meta.Int(.unsigned, @bitSizeOf(T));324 const Bits = std.meta.Int(.unsigned, @bitSizeOf(T));
325 return @as(Bits, @bitCast(x)) == @as(Bits, @bitCast(y));325 return @as(Bits, @bitCast(x)) == @as(Bits, @bitCast(y));
326}326}
lib/std/math/pow.zig+3-3
...@@ -31,7 +31,7 @@ const expect = std.testing.expect;...@@ -31,7 +31,7 @@ const expect = std.testing.expect;
31/// - pow(-inf, y) = pow(-0, -y)31/// - pow(-inf, y) = pow(-0, -y)
32/// - pow(x, y) = nan for finite x < 0 and finite non-integer y32/// - pow(x, y) = nan for finite x < 0 and finite non-integer y
33pub fn pow(comptime T: type, x: T, y: T) T {33pub fn pow(comptime T: type, x: T, y: T) T {
34 if (@typeInfo(T) == .Int) {34 if (@typeInfo(T) == .int) {
35 return math.powi(T, x, y) catch unreachable;35 return math.powi(T, x, y) catch unreachable;
36 }36 }
3737
...@@ -122,7 +122,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {...@@ -122,7 +122,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
122 if (yf != 0 and x < 0) {122 if (yf != 0 and x < 0) {
123 return math.nan(T);123 return math.nan(T);
124 }124 }
125 if (yi >= 1 << (@typeInfo(T).Float.bits - 1)) {125 if (yi >= 1 << (@typeInfo(T).float.bits - 1)) {
126 return @exp(y * @log(x));126 return @exp(y * @log(x));
127 }127 }
128128
...@@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {...@@ -144,7 +144,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
144 var xe = r2.exponent;144 var xe = r2.exponent;
145 var x1 = r2.significand;145 var x1 = r2.significand;
146146
147 var i = @as(std.meta.Int(.signed, @typeInfo(T).Float.bits), @intFromFloat(yi));147 var i = @as(std.meta.Int(.signed, @typeInfo(T).float.bits), @intFromFloat(yi));
148 while (i != 0) : (i >>= 1) {148 while (i != 0) : (i >>= 1) {
149 const overflow_shift = math.floatExponentBits(T) + 1;149 const overflow_shift = math.floatExponentBits(T) + 1;
150 if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {150 if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {
lib/std/math/powi.zig+1-1
...@@ -27,7 +27,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{...@@ -27,7 +27,7 @@ pub fn powi(comptime T: type, x: T, y: T) (error{
27 Overflow,27 Overflow,
28 Underflow,28 Underflow,
29}!T) {29}!T) {
30 const bit_size = @typeInfo(T).Int.bits;30 const bit_size = @typeInfo(T).int.bits;
3131
32 // `y & 1 == 0` won't compile when `does_one_overflow`.32 // `y & 1 == 0` won't compile when `does_one_overflow`.
33 const does_one_overflow = math.maxInt(T) < 1;33 const does_one_overflow = math.maxInt(T) < 1;
lib/std/math/signbit.zig+1-1
...@@ -5,7 +5,7 @@ const expect = std.testing.expect;...@@ -5,7 +5,7 @@ const expect = std.testing.expect;
5/// Returns whether x is negative or negative 0.5/// Returns whether x is negative or negative 0.
6pub fn signbit(x: anytype) bool {6pub fn signbit(x: anytype) bool {
7 const T = @TypeOf(x);7 const T = @TypeOf(x);
8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);8 const TBits = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
9 return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0;9 return @as(TBits, @bitCast(x)) >> (@bitSizeOf(T) - 1) != 0;
10}10}
1111
lib/std/math/sqrt.zig+6-6
...@@ -15,8 +15,8 @@ const maxInt = std.math.maxInt;...@@ -15,8 +15,8 @@ const maxInt = std.math.maxInt;
15pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {15pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
16 const T = @TypeOf(x);16 const T = @TypeOf(x);
17 switch (@typeInfo(T)) {17 switch (@typeInfo(T)) {
18 .Float, .ComptimeFloat => return @sqrt(x),18 .float, .comptime_float => return @sqrt(x),
19 .ComptimeInt => comptime {19 .comptime_int => comptime {
20 if (x > maxInt(u128)) {20 if (x > maxInt(u128)) {
21 @compileError("sqrt not implemented for comptime_int greater than 128 bits");21 @compileError("sqrt not implemented for comptime_int greater than 128 bits");
22 }22 }
...@@ -25,7 +25,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {...@@ -25,7 +25,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
25 }25 }
26 return @as(T, sqrt_int(u128, x));26 return @as(T, sqrt_int(u128, x));
27 },27 },
28 .Int => |IntType| switch (IntType.signedness) {28 .int => |IntType| switch (IntType.signedness) {
29 .signed => @compileError("sqrt not implemented for signed integers"),29 .signed => @compileError("sqrt not implemented for signed integers"),
30 .unsigned => return sqrt_int(T, x),30 .unsigned => return sqrt_int(T, x),
31 },31 },
...@@ -34,10 +34,10 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {...@@ -34,10 +34,10 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
34}34}
3535
36fn sqrt_int(comptime T: type, value: T) Sqrt(T) {36fn sqrt_int(comptime T: type, value: T) Sqrt(T) {
37 if (@typeInfo(T).Int.bits <= 2) {37 if (@typeInfo(T).int.bits <= 2) {
38 return if (value == 0) 0 else 1; // shortcut for small number of bits to simplify general case38 return if (value == 0) 0 else 1; // shortcut for small number of bits to simplify general case
39 } else {39 } else {
40 const bits = @typeInfo(T).Int.bits;40 const bits = @typeInfo(T).int.bits;
41 const max = math.maxInt(T);41 const max = math.maxInt(T);
42 const minustwo = (@as(T, 2) ^ max) + 1; // unsigned int cannot represent -242 const minustwo = (@as(T, 2) ^ max) + 1; // unsigned int cannot represent -2
43 var op = value;43 var op = value;
...@@ -80,7 +80,7 @@ test sqrt_int {...@@ -80,7 +80,7 @@ test sqrt_int {
80/// Returns the return type `sqrt` will return given an operand of type `T`.80/// Returns the return type `sqrt` will return given an operand of type `T`.
81pub fn Sqrt(comptime T: type) type {81pub fn Sqrt(comptime T: type) type {
82 return switch (@typeInfo(T)) {82 return switch (@typeInfo(T)) {
83 .Int => |int| std.meta.Int(.unsigned, (int.bits + 1) / 2),83 .int => |int| @Type(.{ .int = .{ .signedness = .unsigned, .bits = (int.bits + 1) / 2 } }),
84 else => T,84 else => T,
85 };85 };
86}86}
lib/std/mem.zig+89-89
...@@ -229,22 +229,22 @@ pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void {...@@ -229,22 +229,22 @@ pub fn copyBackwards(comptime T: type, dest: []T, source: []const T) void {
229/// This can be used to zero-initialize any type for which it makes sense. Structs will be initialized recursively.229/// This can be used to zero-initialize any type for which it makes sense. Structs will be initialized recursively.
230pub fn zeroes(comptime T: type) T {230pub fn zeroes(comptime T: type) T {
231 switch (@typeInfo(T)) {231 switch (@typeInfo(T)) {
232 .ComptimeInt, .Int, .ComptimeFloat, .Float => {232 .comptime_int, .int, .comptime_float, .float => {
233 return @as(T, 0);233 return @as(T, 0);
234 },234 },
235 .Enum => {235 .@"enum" => {
236 return @as(T, @enumFromInt(0));236 return @as(T, @enumFromInt(0));
237 },237 },
238 .Void => {238 .void => {
239 return {};239 return {};
240 },240 },
241 .Bool => {241 .bool => {
242 return false;242 return false;
243 },243 },
244 .Optional, .Null => {244 .optional, .null => {
245 return null;245 return null;
246 },246 },
247 .Struct => |struct_info| {247 .@"struct" => |struct_info| {
248 if (@sizeOf(T) == 0) return undefined;248 if (@sizeOf(T) == 0) return undefined;
249 if (struct_info.layout == .@"extern") {249 if (struct_info.layout == .@"extern") {
250 var item: T = undefined;250 var item: T = undefined;
...@@ -260,7 +260,7 @@ pub fn zeroes(comptime T: type) T {...@@ -260,7 +260,7 @@ pub fn zeroes(comptime T: type) T {
260 return structure;260 return structure;
261 }261 }
262 },262 },
263 .Pointer => |ptr_info| {263 .pointer => |ptr_info| {
264 switch (ptr_info.size) {264 switch (ptr_info.size) {
265 .Slice => {265 .Slice => {
266 if (ptr_info.sentinel) |sentinel| {266 if (ptr_info.sentinel) |sentinel| {
...@@ -281,17 +281,17 @@ pub fn zeroes(comptime T: type) T {...@@ -281,17 +281,17 @@ pub fn zeroes(comptime T: type) T {
281 },281 },
282 }282 }
283 },283 },
284 .Array => |info| {284 .array => |info| {
285 if (info.sentinel) |sentinel_ptr| {285 if (info.sentinel) |sentinel_ptr| {
286 const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;286 const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
287 return [_:sentinel]info.child{zeroes(info.child)} ** info.len;287 return [_:sentinel]info.child{zeroes(info.child)} ** info.len;
288 }288 }
289 return [_]info.child{zeroes(info.child)} ** info.len;289 return [_]info.child{zeroes(info.child)} ** info.len;
290 },290 },
291 .Vector => |info| {291 .vector => |info| {
292 return @splat(zeroes(info.child));292 return @splat(zeroes(info.child));
293 },293 },
294 .Union => |info| {294 .@"union" => |info| {
295 if (info.layout == .@"extern") {295 if (info.layout == .@"extern") {
296 var item: T = undefined;296 var item: T = undefined;
297 @memset(asBytes(&item), 0);297 @memset(asBytes(&item), 0);
...@@ -299,16 +299,16 @@ pub fn zeroes(comptime T: type) T {...@@ -299,16 +299,16 @@ pub fn zeroes(comptime T: type) T {
299 }299 }
300 @compileError("Can't set a " ++ @typeName(T) ++ " to zero.");300 @compileError("Can't set a " ++ @typeName(T) ++ " to zero.");
301 },301 },
302 .EnumLiteral,302 .enum_literal,
303 .ErrorUnion,303 .error_union,
304 .ErrorSet,304 .error_set,
305 .Fn,305 .@"fn",
306 .Type,306 .type,
307 .NoReturn,307 .noreturn,
308 .Undefined,308 .undefined,
309 .Opaque,309 .@"opaque",
310 .Frame,310 .frame,
311 .AnyFrame,311 .@"anyframe",
312 => {312 => {
313 @compileError("Can't set a " ++ @typeName(T) ++ " to zero.");313 @compileError("Can't set a " ++ @typeName(T) ++ " to zero.");
314 },314 },
...@@ -423,9 +423,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T {...@@ -423,9 +423,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
423 const Init = @TypeOf(init);423 const Init = @TypeOf(init);
424424
425 switch (@typeInfo(T)) {425 switch (@typeInfo(T)) {
426 .Struct => |struct_info| {426 .@"struct" => |struct_info| {
427 switch (@typeInfo(Init)) {427 switch (@typeInfo(Init)) {
428 .Struct => |init_info| {428 .@"struct" => |init_info| {
429 if (init_info.is_tuple) {429 if (init_info.is_tuple) {
430 if (init_info.fields.len > struct_info.fields.len) {430 if (init_info.fields.len > struct_info.fields.len) {
431 @compileError("Tuple initializer has more elements than there are fields in `" ++ @typeName(T) ++ "`");431 @compileError("Tuple initializer has more elements than there are fields in `" ++ @typeName(T) ++ "`");
...@@ -449,7 +449,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {...@@ -449,7 +449,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
449 @field(value, field.name) = @field(init, init_info.fields[i].name);449 @field(value, field.name) = @field(init, init_info.fields[i].name);
450 } else if (@hasField(@TypeOf(init), field.name)) {450 } else if (@hasField(@TypeOf(init), field.name)) {
451 switch (@typeInfo(field.type)) {451 switch (@typeInfo(field.type)) {
452 .Struct => {452 .@"struct" => {
453 @field(value, field.name) = zeroInit(field.type, @field(init, field.name));453 @field(value, field.name) = zeroInit(field.type, @field(init, field.name));
454 },454 },
455 else => {455 else => {
...@@ -461,7 +461,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {...@@ -461,7 +461,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
461 @field(value, field.name) = default_value;461 @field(value, field.name) = default_value;
462 } else {462 } else {
463 switch (@typeInfo(field.type)) {463 switch (@typeInfo(field.type)) {
464 .Struct => {464 .@"struct" => {
465 @field(value, field.name) = std.mem.zeroInit(field.type, .{});465 @field(value, field.name) = std.mem.zeroInit(field.type, .{});
466 },466 },
467 else => {467 else => {
...@@ -752,10 +752,10 @@ test indexOfDiff {...@@ -752,10 +752,10 @@ test indexOfDiff {
752/// `[*c]` pointers are assumed to be 0-terminated and assumed to not be allowzero.752/// `[*c]` pointers are assumed to be 0-terminated and assumed to not be allowzero.
753fn Span(comptime T: type) type {753fn Span(comptime T: type) type {
754 switch (@typeInfo(T)) {754 switch (@typeInfo(T)) {
755 .Optional => |optional_info| {755 .optional => |optional_info| {
756 return ?Span(optional_info.child);756 return ?Span(optional_info.child);
757 },757 },
758 .Pointer => |ptr_info| {758 .pointer => |ptr_info| {
759 var new_ptr_info = ptr_info;759 var new_ptr_info = ptr_info;
760 switch (ptr_info.size) {760 switch (ptr_info.size) {
761 .C => {761 .C => {
...@@ -766,7 +766,7 @@ fn Span(comptime T: type) type {...@@ -766,7 +766,7 @@ fn Span(comptime T: type) type {
766 .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),766 .One, .Slice => @compileError("invalid type given to std.mem.span: " ++ @typeName(T)),
767 }767 }
768 new_ptr_info.size = .Slice;768 new_ptr_info.size = .Slice;
769 return @Type(.{ .Pointer = new_ptr_info });769 return @Type(.{ .pointer = new_ptr_info });
770 },770 },
771 else => {},771 else => {},
772 }772 }
...@@ -789,7 +789,7 @@ test Span {...@@ -789,7 +789,7 @@ test Span {
789/// Pointer attributes such as const are preserved.789/// Pointer attributes such as const are preserved.
790/// `[*c]` pointers are assumed to be non-null and 0-terminated.790/// `[*c]` pointers are assumed to be non-null and 0-terminated.
791pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {791pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
792 if (@typeInfo(@TypeOf(ptr)) == .Optional) {792 if (@typeInfo(@TypeOf(ptr)) == .optional) {
793 if (ptr) |non_null| {793 if (ptr) |non_null| {
794 return span(non_null);794 return span(non_null);
795 } else {795 } else {
...@@ -798,7 +798,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {...@@ -798,7 +798,7 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
798 }798 }
799 const Result = Span(@TypeOf(ptr));799 const Result = Span(@TypeOf(ptr));
800 const l = len(ptr);800 const l = len(ptr);
801 const ptr_info = @typeInfo(Result).Pointer;801 const ptr_info = @typeInfo(Result).pointer;
802 if (ptr_info.sentinel) |s_ptr| {802 if (ptr_info.sentinel) |s_ptr| {
803 const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;803 const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;
804 return ptr[0..l :s];804 return ptr[0..l :s];
...@@ -817,15 +817,15 @@ test span {...@@ -817,15 +817,15 @@ test span {
817/// Helper for the return type of sliceTo()817/// Helper for the return type of sliceTo()
818fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {818fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
819 switch (@typeInfo(T)) {819 switch (@typeInfo(T)) {
820 .Optional => |optional_info| {820 .optional => |optional_info| {
821 return ?SliceTo(optional_info.child, end);821 return ?SliceTo(optional_info.child, end);
822 },822 },
823 .Pointer => |ptr_info| {823 .pointer => |ptr_info| {
824 var new_ptr_info = ptr_info;824 var new_ptr_info = ptr_info;
825 new_ptr_info.size = .Slice;825 new_ptr_info.size = .Slice;
826 switch (ptr_info.size) {826 switch (ptr_info.size) {
827 .One => switch (@typeInfo(ptr_info.child)) {827 .One => switch (@typeInfo(ptr_info.child)) {
828 .Array => |array_info| {828 .array => |array_info| {
829 new_ptr_info.child = array_info.child;829 new_ptr_info.child = array_info.child;
830 // The return type must only be sentinel terminated if we are guaranteed830 // The return type must only be sentinel terminated if we are guaranteed
831 // to find the value searched for, which is only the case if it matches831 // to find the value searched for, which is only the case if it matches
...@@ -861,7 +861,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {...@@ -861,7 +861,7 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
861 new_ptr_info.is_allowzero = false;861 new_ptr_info.is_allowzero = false;
862 },862 },
863 }863 }
864 return @Type(.{ .Pointer = new_ptr_info });864 return @Type(.{ .pointer = new_ptr_info });
865 },865 },
866 else => {},866 else => {},
867 }867 }
...@@ -876,13 +876,13 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {...@@ -876,13 +876,13 @@ fn SliceTo(comptime T: type, comptime end: std.meta.Elem(T)) type {
876/// Pointer properties such as mutability and alignment are preserved.876/// Pointer properties such as mutability and alignment are preserved.
877/// C pointers are assumed to be non-null.877/// C pointers are assumed to be non-null.
878pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) {878pub fn sliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) {
879 if (@typeInfo(@TypeOf(ptr)) == .Optional) {879 if (@typeInfo(@TypeOf(ptr)) == .optional) {
880 const non_null = ptr orelse return null;880 const non_null = ptr orelse return null;
881 return sliceTo(non_null, end);881 return sliceTo(non_null, end);
882 }882 }
883 const Result = SliceTo(@TypeOf(ptr), end);883 const Result = SliceTo(@TypeOf(ptr), end);
884 const length = lenSliceTo(ptr, end);884 const length = lenSliceTo(ptr, end);
885 const ptr_info = @typeInfo(Result).Pointer;885 const ptr_info = @typeInfo(Result).pointer;
886 if (ptr_info.sentinel) |s_ptr| {886 if (ptr_info.sentinel) |s_ptr| {
887 const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;887 const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*;
888 return ptr[0..length :s];888 return ptr[0..length :s];
...@@ -933,9 +933,9 @@ test sliceTo {...@@ -933,9 +933,9 @@ test sliceTo {
933/// Private helper for sliceTo(). If you want the length, use sliceTo(foo, x).len933/// Private helper for sliceTo(). If you want the length, use sliceTo(foo, x).len
934fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {934fn lenSliceTo(ptr: anytype, comptime end: std.meta.Elem(@TypeOf(ptr))) usize {
935 switch (@typeInfo(@TypeOf(ptr))) {935 switch (@typeInfo(@TypeOf(ptr))) {
936 .Pointer => |ptr_info| switch (ptr_info.size) {936 .pointer => |ptr_info| switch (ptr_info.size) {
937 .One => switch (@typeInfo(ptr_info.child)) {937 .One => switch (@typeInfo(ptr_info.child)) {
938 .Array => |array_info| {938 .array => |array_info| {
939 if (array_info.sentinel) |sentinel_ptr| {939 if (array_info.sentinel) |sentinel_ptr| {
940 const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;940 const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
941 if (sentinel == end) {941 if (sentinel == end) {
...@@ -1015,7 +1015,7 @@ test lenSliceTo {...@@ -1015,7 +1015,7 @@ test lenSliceTo {
1015/// `[*c]` pointers are assumed to be non-null and 0-terminated.1015/// `[*c]` pointers are assumed to be non-null and 0-terminated.
1016pub fn len(value: anytype) usize {1016pub fn len(value: anytype) usize {
1017 switch (@typeInfo(@TypeOf(value))) {1017 switch (@typeInfo(@TypeOf(value))) {
1018 .Pointer => |info| switch (info.size) {1018 .pointer => |info| switch (info.size) {
1019 .Many => {1019 .Many => {
1020 const sentinel_ptr = info.sentinel orelse1020 const sentinel_ptr = info.sentinel orelse
1021 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));1021 @compileError("invalid type given to std.mem.len: " ++ @typeName(@TypeOf(value)));
...@@ -1051,7 +1051,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co...@@ -1051,7 +1051,7 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
1051 if (backend_supports_vectors and1051 if (backend_supports_vectors and
1052 !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/177171052 !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717
1053 !@inComptime() and1053 !@inComptime() and
1054 (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T)))1054 (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T)))
1055 {1055 {
1056 switch (@import("builtin").cpu.arch) {1056 switch (@import("builtin").cpu.arch) {
1057 // The below branch assumes that reading past the end of the buffer is valid, as long1057 // The below branch assumes that reading past the end of the buffer is valid, as long
...@@ -1202,7 +1202,7 @@ pub fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize,...@@ -1202,7 +1202,7 @@ pub fn indexOfScalarPos(comptime T: type, slice: []const T, start_index: usize,
1202 if (backend_supports_vectors and1202 if (backend_supports_vectors and
1203 !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/177171203 !std.debug.inValgrind() and // https://github.com/ziglang/zig/issues/17717
1204 !@inComptime() and1204 !@inComptime() and
1205 (@typeInfo(T) == .Int or @typeInfo(T) == .Float) and std.math.isPowerOfTwo(@bitSizeOf(T)))1205 (@typeInfo(T) == .int or @typeInfo(T) == .float) and std.math.isPowerOfTwo(@bitSizeOf(T)))
1206 {1206 {
1207 if (std.simd.suggestVectorLength(T)) |block_len| {1207 if (std.simd.suggestVectorLength(T)) |block_len| {
1208 // For Intel Nehalem (2009) and AMD Bulldozer (2012) or later, unaligned loads on aligned data result1208 // For Intel Nehalem (2009) and AMD Bulldozer (2012) or later, unaligned loads on aligned data result
...@@ -1602,8 +1602,8 @@ test containsAtLeast {...@@ -1602,8 +1602,8 @@ test containsAtLeast {
1602/// T specifies the return type, which must be large enough to store1602/// T specifies the return type, which must be large enough to store
1603/// the result.1603/// the result.
1604pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType {1604pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian) ReturnType {
1605 const bits = @typeInfo(ReturnType).Int.bits;1605 const bits = @typeInfo(ReturnType).int.bits;
1606 const signedness = @typeInfo(ReturnType).Int.signedness;1606 const signedness = @typeInfo(ReturnType).int.signedness;
1607 const WorkType = std.meta.Int(signedness, @max(16, bits));1607 const WorkType = std.meta.Int(signedness, @max(16, bits));
1608 var result: WorkType = 0;1608 var result: WorkType = 0;
1609 switch (endian) {1609 switch (endian) {
...@@ -1635,7 +1635,7 @@ test readVarInt {...@@ -1635,7 +1635,7 @@ test readVarInt {
1635 try testing.expect(readVarInt(i16, &[_]u8{ 0xff, 0xfd }, .big) == -3);1635 try testing.expect(readVarInt(i16, &[_]u8{ 0xff, 0xfd }, .big) == -3);
1636 try testing.expect(readVarInt(i16, &[_]u8{ 0xfc, 0xff }, .little) == -4);1636 try testing.expect(readVarInt(i16, &[_]u8{ 0xfc, 0xff }, .little) == -4);
16371637
1638 // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).Int.bits)1638 // Return type can be oversized (bytes.len * 8 < @typeInfo(ReturnType).int.bits)
1639 try testing.expect(readVarInt(u9, &[_]u8{0x12}, .little) == 0x12);1639 try testing.expect(readVarInt(u9, &[_]u8{0x12}, .little) == 0x12);
1640 try testing.expect(readVarInt(u9, &[_]u8{0xde}, .big) == 0xde);1640 try testing.expect(readVarInt(u9, &[_]u8{0xde}, .big) == 0xde);
1641 try testing.expect(readVarInt(u80, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }, .big) == 0x123456789abcdef024);1641 try testing.expect(readVarInt(u80, &[_]u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }, .big) == 0x123456789abcdef024);
...@@ -1719,7 +1719,7 @@ test readVarPackedInt {...@@ -1719,7 +1719,7 @@ test readVarPackedInt {
1719/// Reads an integer from memory with bit count specified by T.1719/// Reads an integer from memory with bit count specified by T.
1720/// The bit count of T must be evenly divisible by 8.1720/// The bit count of T must be evenly divisible by 8.
1721/// This function cannot fail and cannot cause undefined behavior.1721/// This function cannot fail and cannot cause undefined behavior.
1722pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).Int.bits, 8)]u8, endian: Endian) T {1722pub inline fn readInt(comptime T: type, buffer: *const [@divExact(@typeInfo(T).int.bits, 8)]u8, endian: Endian) T {
1723 const value: T = @bitCast(buffer.*);1723 const value: T = @bitCast(buffer.*);
1724 return if (endian == native_endian) value else @byteSwap(value);1724 return if (endian == native_endian) value else @byteSwap(value);
1725}1725}
...@@ -1844,7 +1844,7 @@ test "comptime read/write int" {...@@ -1844,7 +1844,7 @@ test "comptime read/write int" {
1844/// Writes an integer to memory, storing it in twos-complement.1844/// Writes an integer to memory, storing it in twos-complement.
1845/// This function always succeeds, has defined behavior for all inputs, but1845/// This function always succeeds, has defined behavior for all inputs, but
1846/// the integer bit width must be divisible by 8.1846/// the integer bit width must be divisible by 8.
1847pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).Int.bits, 8)]u8, value: T, endian: Endian) void {1847pub inline fn writeInt(comptime T: type, buffer: *[@divExact(@typeInfo(T).int.bits, 8)]u8, value: T, endian: Endian) void {
1848 buffer.* = @bitCast(if (endian == native_endian) value else @byteSwap(value));1848 buffer.* = @bitCast(if (endian == native_endian) value else @byteSwap(value));
1849}1849}
18501850
...@@ -2047,20 +2047,20 @@ test writeVarPackedInt {...@@ -2047,20 +2047,20 @@ test writeVarPackedInt {
2047/// (Changing their endianness)2047/// (Changing their endianness)
2048pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {2048pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
2049 switch (@typeInfo(S)) {2049 switch (@typeInfo(S)) {
2050 .Struct => {2050 .@"struct" => {
2051 inline for (std.meta.fields(S)) |f| {2051 inline for (std.meta.fields(S)) |f| {
2052 switch (@typeInfo(f.type)) {2052 switch (@typeInfo(f.type)) {
2053 .Struct => |struct_info| if (struct_info.backing_integer) |Int| {2053 .@"struct" => |struct_info| if (struct_info.backing_integer) |Int| {
2054 @field(ptr, f.name) = @bitCast(@byteSwap(@as(Int, @bitCast(@field(ptr, f.name)))));2054 @field(ptr, f.name) = @bitCast(@byteSwap(@as(Int, @bitCast(@field(ptr, f.name)))));
2055 } else {2055 } else {
2056 byteSwapAllFields(f.type, &@field(ptr, f.name));2056 byteSwapAllFields(f.type, &@field(ptr, f.name));
2057 },2057 },
2058 .Array => byteSwapAllFields(f.type, &@field(ptr, f.name)),2058 .array => byteSwapAllFields(f.type, &@field(ptr, f.name)),
2059 .Enum => {2059 .@"enum" => {
2060 @field(ptr, f.name) = @enumFromInt(@byteSwap(@intFromEnum(@field(ptr, f.name))));2060 @field(ptr, f.name) = @enumFromInt(@byteSwap(@intFromEnum(@field(ptr, f.name))));
2061 },2061 },
2062 .Bool => {},2062 .bool => {},
2063 .Float => |float_info| {2063 .float => |float_info| {
2064 @field(ptr, f.name) = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name)))));2064 @field(ptr, f.name) = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name)))));
2065 },2065 },
2066 else => {2066 else => {
...@@ -2069,15 +2069,15 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {...@@ -2069,15 +2069,15 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
2069 }2069 }
2070 }2070 }
2071 },2071 },
2072 .Array => {2072 .array => {
2073 for (ptr) |*item| {2073 for (ptr) |*item| {
2074 switch (@typeInfo(@TypeOf(item.*))) {2074 switch (@typeInfo(@TypeOf(item.*))) {
2075 .Struct, .Array => byteSwapAllFields(@TypeOf(item.*), item),2075 .@"struct", .array => byteSwapAllFields(@TypeOf(item.*), item),
2076 .Enum => {2076 .@"enum" => {
2077 item.* = @enumFromInt(@byteSwap(@intFromEnum(item.*)));2077 item.* = @enumFromInt(@byteSwap(@intFromEnum(item.*)));
2078 },2078 },
2079 .Bool => {},2079 .bool => {},
2080 .Float => |float_info| {2080 .float => |float_info| {
2081 item.* = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(item.*))));2081 item.* = @bitCast(@byteSwap(@as(std.meta.Int(.unsigned, float_info.bits), @bitCast(item.*))));
2082 },2082 },
2083 else => {2083 else => {
...@@ -3560,21 +3560,21 @@ test reverse {...@@ -3560,21 +3560,21 @@ test reverse {
3560fn ReverseIterator(comptime T: type) type {3560fn ReverseIterator(comptime T: type) type {
3561 const Pointer = blk: {3561 const Pointer = blk: {
3562 switch (@typeInfo(T)) {3562 switch (@typeInfo(T)) {
3563 .Pointer => |ptr_info| switch (ptr_info.size) {3563 .pointer => |ptr_info| switch (ptr_info.size) {
3564 .One => switch (@typeInfo(ptr_info.child)) {3564 .One => switch (@typeInfo(ptr_info.child)) {
3565 .Array => |array_info| {3565 .array => |array_info| {
3566 var new_ptr_info = ptr_info;3566 var new_ptr_info = ptr_info;
3567 new_ptr_info.size = .Many;3567 new_ptr_info.size = .Many;
3568 new_ptr_info.child = array_info.child;3568 new_ptr_info.child = array_info.child;
3569 new_ptr_info.sentinel = array_info.sentinel;3569 new_ptr_info.sentinel = array_info.sentinel;
3570 break :blk @Type(.{ .Pointer = new_ptr_info });3570 break :blk @Type(.{ .pointer = new_ptr_info });
3571 },3571 },
3572 else => {},3572 else => {},
3573 },3573 },
3574 .Slice => {3574 .Slice => {
3575 var new_ptr_info = ptr_info;3575 var new_ptr_info = ptr_info;
3576 new_ptr_info.size = .Many;3576 new_ptr_info.size = .Many;
3577 break :blk @Type(.{ .Pointer = new_ptr_info });3577 break :blk @Type(.{ .pointer = new_ptr_info });
3578 },3578 },
3579 else => {},3579 else => {},
3580 },3580 },
...@@ -3583,8 +3583,8 @@ fn ReverseIterator(comptime T: type) type {...@@ -3583,8 +3583,8 @@ fn ReverseIterator(comptime T: type) type {
3583 @compileError("expected slice or pointer to array, found '" ++ @typeName(T) ++ "'");3583 @compileError("expected slice or pointer to array, found '" ++ @typeName(T) ++ "'");
3584 };3584 };
3585 const Element = std.meta.Elem(Pointer);3585 const Element = std.meta.Elem(Pointer);
3586 const ElementPointer = @Type(.{ .Pointer = ptr: {3586 const ElementPointer = @Type(.{ .pointer = ptr: {
3587 var ptr = @typeInfo(Pointer).Pointer;3587 var ptr = @typeInfo(Pointer).pointer;
3588 ptr.size = .One;3588 ptr.size = .One;
3589 ptr.child = Element;3589 ptr.child = Element;
3590 ptr.sentinel = null;3590 ptr.sentinel = null;
...@@ -3891,11 +3891,11 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {...@@ -3891,11 +3891,11 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
38913891
3892 const T = @TypeOf(ptr);3892 const T = @TypeOf(ptr);
3893 const info = @typeInfo(T);3893 const info = @typeInfo(T);
3894 if (info != .Pointer or info.Pointer.size != .Many)3894 if (info != .pointer or info.pointer.size != .Many)
3895 @compileError("expected many item pointer, got " ++ @typeName(T));3895 @compileError("expected many item pointer, got " ++ @typeName(T));
38963896
3897 // Do nothing if the pointer is already well-aligned.3897 // Do nothing if the pointer is already well-aligned.
3898 if (align_to <= info.Pointer.alignment)3898 if (align_to <= info.pointer.alignment)
3899 return 0;3899 return 0;
39003900
3901 // Calculate the aligned base address with an eye out for overflow.3901 // Calculate the aligned base address with an eye out for overflow.
...@@ -3907,7 +3907,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {...@@ -3907,7 +3907,7 @@ pub fn alignPointerOffset(ptr: anytype, align_to: usize) ?usize {
3907 // The delta is expressed in terms of bytes, turn it into a number of child3907 // The delta is expressed in terms of bytes, turn it into a number of child
3908 // type elements.3908 // type elements.
3909 const delta = ov[0] - addr;3909 const delta = ov[0] - addr;
3910 const pointee_size = @sizeOf(info.Pointer.child);3910 const pointee_size = @sizeOf(info.pointer.child);
3911 if (delta % pointee_size != 0) return null;3911 if (delta % pointee_size != 0) return null;
3912 return delta / pointee_size;3912 return delta / pointee_size;
3913}3913}
...@@ -3948,9 +3948,9 @@ fn CopyPtrAttrs(...@@ -3948,9 +3948,9 @@ fn CopyPtrAttrs(
3948 comptime size: std.builtin.Type.Pointer.Size,3948 comptime size: std.builtin.Type.Pointer.Size,
3949 comptime child: type,3949 comptime child: type,
3950) type {3950) type {
3951 const info = @typeInfo(source).Pointer;3951 const info = @typeInfo(source).pointer;
3952 return @Type(.{3952 return @Type(.{
3953 .Pointer = .{3953 .pointer = .{
3954 .size = size,3954 .size = size,
3955 .is_const = info.is_const,3955 .is_const = info.is_const,
3956 .is_volatile = info.is_volatile,3956 .is_volatile = info.is_volatile,
...@@ -4019,8 +4019,8 @@ test "asBytes preserves pointer attributes" {...@@ -4019,8 +4019,8 @@ test "asBytes preserves pointer attributes" {
4019 const inPtr = @as(*align(16) const volatile u32, @ptrCast(&inArr));4019 const inPtr = @as(*align(16) const volatile u32, @ptrCast(&inArr));
4020 const outSlice = asBytes(inPtr);4020 const outSlice = asBytes(inPtr);
40214021
4022 const in = @typeInfo(@TypeOf(inPtr)).Pointer;4022 const in = @typeInfo(@TypeOf(inPtr)).pointer;
4023 const out = @typeInfo(@TypeOf(outSlice)).Pointer;4023 const out = @typeInfo(@TypeOf(outSlice)).pointer;
40244024
4025 try testing.expectEqual(in.is_const, out.is_const);4025 try testing.expectEqual(in.is_const, out.is_const);
4026 try testing.expectEqual(in.is_volatile, out.is_volatile);4026 try testing.expectEqual(in.is_volatile, out.is_volatile);
...@@ -4102,8 +4102,8 @@ test "bytesAsValue preserves pointer attributes" {...@@ -4102,8 +4102,8 @@ test "bytesAsValue preserves pointer attributes" {
4102 const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..];4102 const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..];
4103 const outPtr = bytesAsValue(u32, inSlice);4103 const outPtr = bytesAsValue(u32, inSlice);
41044104
4105 const in = @typeInfo(@TypeOf(inSlice)).Pointer;4105 const in = @typeInfo(@TypeOf(inSlice)).pointer;
4106 const out = @typeInfo(@TypeOf(outPtr)).Pointer;4106 const out = @typeInfo(@TypeOf(outPtr)).pointer;
41074107
4108 try testing.expectEqual(in.is_const, out.is_const);4108 try testing.expectEqual(in.is_const, out.is_const);
4109 try testing.expectEqual(in.is_volatile, out.is_volatile);4109 try testing.expectEqual(in.is_volatile, out.is_volatile);
...@@ -4204,8 +4204,8 @@ test "bytesAsSlice preserves pointer attributes" {...@@ -4204,8 +4204,8 @@ test "bytesAsSlice preserves pointer attributes" {
4204 const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..];4204 const inSlice = @as(*align(16) const volatile [4]u8, @ptrCast(&inArr))[0..];
4205 const outSlice = bytesAsSlice(u16, inSlice);4205 const outSlice = bytesAsSlice(u16, inSlice);
42064206
4207 const in = @typeInfo(@TypeOf(inSlice)).Pointer;4207 const in = @typeInfo(@TypeOf(inSlice)).pointer;
4208 const out = @typeInfo(@TypeOf(outSlice)).Pointer;4208 const out = @typeInfo(@TypeOf(outSlice)).pointer;
42094209
4210 try testing.expectEqual(in.is_const, out.is_const);4210 try testing.expectEqual(in.is_const, out.is_const);
4211 try testing.expectEqual(in.is_volatile, out.is_volatile);4211 try testing.expectEqual(in.is_volatile, out.is_volatile);
...@@ -4303,8 +4303,8 @@ test "sliceAsBytes preserves pointer attributes" {...@@ -4303,8 +4303,8 @@ test "sliceAsBytes preserves pointer attributes" {
4303 const inSlice = @as(*align(16) const volatile [2]u16, @ptrCast(&inArr))[0..];4303 const inSlice = @as(*align(16) const volatile [2]u16, @ptrCast(&inArr))[0..];
4304 const outSlice = sliceAsBytes(inSlice);4304 const outSlice = sliceAsBytes(inSlice);
43054305
4306 const in = @typeInfo(@TypeOf(inSlice)).Pointer;4306 const in = @typeInfo(@TypeOf(inSlice)).pointer;
4307 const out = @typeInfo(@TypeOf(outSlice)).Pointer;4307 const out = @typeInfo(@TypeOf(outSlice)).pointer;
43084308
4309 try testing.expectEqual(in.is_const, out.is_const);4309 try testing.expectEqual(in.is_const, out.is_const);
4310 try testing.expectEqual(in.is_volatile, out.is_volatile);4310 try testing.expectEqual(in.is_volatile, out.is_volatile);
...@@ -4346,14 +4346,14 @@ pub fn doNotOptimizeAway(val: anytype) void {...@@ -4346,14 +4346,14 @@ pub fn doNotOptimizeAway(val: anytype) void {
4346 const max_gp_register_bits = @bitSizeOf(c_long);4346 const max_gp_register_bits = @bitSizeOf(c_long);
4347 const t = @typeInfo(@TypeOf(val));4347 const t = @typeInfo(@TypeOf(val));
4348 switch (t) {4348 switch (t) {
4349 .Void, .Null, .ComptimeInt, .ComptimeFloat => return,4349 .void, .null, .comptime_int, .comptime_float => return,
4350 .Enum => doNotOptimizeAway(@intFromEnum(val)),4350 .@"enum" => doNotOptimizeAway(@intFromEnum(val)),
4351 .Bool => doNotOptimizeAway(@intFromBool(val)),4351 .bool => doNotOptimizeAway(@intFromBool(val)),
4352 .Int => {4352 .int => {
4353 const bits = t.Int.bits;4353 const bits = t.int.bits;
4354 if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) {4354 if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) {
4355 const val2 = @as(4355 const val2 = @as(
4356 std.meta.Int(t.Int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))),4356 std.meta.Int(t.int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))),
4357 val,4357 val,
4358 );4358 );
4359 asm volatile (""4359 asm volatile (""
...@@ -4362,15 +4362,15 @@ pub fn doNotOptimizeAway(val: anytype) void {...@@ -4362,15 +4362,15 @@ pub fn doNotOptimizeAway(val: anytype) void {
4362 );4362 );
4363 } else doNotOptimizeAway(&val);4363 } else doNotOptimizeAway(&val);
4364 },4364 },
4365 .Float => {4365 .float => {
4366 if ((t.Float.bits == 32 or t.Float.bits == 64) and builtin.zig_backend != .stage2_c) {4366 if ((t.float.bits == 32 or t.float.bits == 64) and builtin.zig_backend != .stage2_c) {
4367 asm volatile (""4367 asm volatile (""
4368 :4368 :
4369 : [val] "rm" (val),4369 : [val] "rm" (val),
4370 );4370 );
4371 } else doNotOptimizeAway(&val);4371 } else doNotOptimizeAway(&val);
4372 },4372 },
4373 .Pointer => {4373 .pointer => {
4374 if (builtin.zig_backend == .stage2_c) {4374 if (builtin.zig_backend == .stage2_c) {
4375 doNotOptimizeAwayC(val);4375 doNotOptimizeAwayC(val);
4376 } else {4376 } else {
...@@ -4381,8 +4381,8 @@ pub fn doNotOptimizeAway(val: anytype) void {...@@ -4381,8 +4381,8 @@ pub fn doNotOptimizeAway(val: anytype) void {
4381 );4381 );
4382 }4382 }
4383 },4383 },
4384 .Array => {4384 .array => {
4385 if (t.Array.len * @sizeOf(t.Array.child) <= 64) {4385 if (t.array.len * @sizeOf(t.array.child) <= 64) {
4386 for (val) |v| doNotOptimizeAway(v);4386 for (val) |v| doNotOptimizeAway(v);
4387 } else doNotOptimizeAway(&val);4387 } else doNotOptimizeAway(&val);
4388 },4388 },
...@@ -4518,9 +4518,9 @@ test "freeing empty string with null-terminated sentinel" {...@@ -4518,9 +4518,9 @@ test "freeing empty string with null-terminated sentinel" {
4518/// Returns a slice with the given new alignment,4518/// Returns a slice with the given new alignment,
4519/// all other pointer attributes copied from `AttributeSource`.4519/// all other pointer attributes copied from `AttributeSource`.
4520fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) type {4520fn AlignedSlice(comptime AttributeSource: type, comptime new_alignment: usize) type {
4521 const info = @typeInfo(AttributeSource).Pointer;4521 const info = @typeInfo(AttributeSource).pointer;
4522 return @Type(.{4522 return @Type(.{
4523 .Pointer = .{4523 .pointer = .{
4524 .size = .Slice,4524 .size = .Slice,
4525 .is_const = info.is_const,4525 .is_const = info.is_const,
4526 .is_volatile = info.is_volatile,4526 .is_volatile = info.is_volatile,
...@@ -4659,7 +4659,7 @@ test "read/write(Var)PackedInt" {...@@ -4659,7 +4659,7 @@ test "read/write(Var)PackedInt" {
4659 try expect(diff_bits << @as(Log2T, @intCast(@bitSizeOf(BackingType) - offset)) == 0);4659 try expect(diff_bits << @as(Log2T, @intCast(@bitSizeOf(BackingType) - offset)) == 0);
4660 }4660 }
46614661
4662 const signedness = @typeInfo(PackedType).Int.signedness;4662 const signedness = @typeInfo(PackedType).int.signedness;
4663 const NextPowerOfTwoInt = std.meta.Int(signedness, try comptime std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType)));4663 const NextPowerOfTwoInt = std.meta.Int(signedness, try comptime std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType)));
4664 const ui64 = std.meta.Int(signedness, 64);4664 const ui64 = std.meta.Int(signedness, 64);
4665 inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| {4665 inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| {
lib/std/mem/Allocator.zig+10-10
...@@ -109,7 +109,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {...@@ -109,7 +109,7 @@ pub fn create(self: Allocator, comptime T: type) Error!*T {
109/// `ptr` should be the return value of `create`, or otherwise109/// `ptr` should be the return value of `create`, or otherwise
110/// have the same address and alignment property.110/// have the same address and alignment property.
111pub fn destroy(self: Allocator, ptr: anytype) void {111pub fn destroy(self: Allocator, ptr: anytype) void {
112 const info = @typeInfo(@TypeOf(ptr)).Pointer;112 const info = @typeInfo(@TypeOf(ptr)).pointer;
113 if (info.size != .One) @compileError("ptr must be a single item pointer");113 if (info.size != .One) @compileError("ptr must be a single item pointer");
114 const T = info.child;114 const T = info.child;
115 if (@sizeOf(T) == 0) return;115 if (@sizeOf(T) == 0) return;
...@@ -232,7 +232,7 @@ fn allocBytesWithAlignment(self: Allocator, comptime alignment: u29, byte_count:...@@ -232,7 +232,7 @@ fn allocBytesWithAlignment(self: Allocator, comptime alignment: u29, byte_count:
232/// the pointer, however the allocator implementation may refuse the resize232/// the pointer, however the allocator implementation may refuse the resize
233/// request by returning `false`.233/// request by returning `false`.
234pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool {234pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool {
235 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;235 const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
236 const T = Slice.child;236 const T = Slice.child;
237 if (new_n == 0) {237 if (new_n == 0) {
238 self.free(old_mem);238 self.free(old_mem);
...@@ -253,7 +253,7 @@ pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool {...@@ -253,7 +253,7 @@ pub fn resize(self: Allocator, old_mem: anytype, new_n: usize) bool {
253/// can be larger, smaller, or the same size as the old memory allocation.253/// can be larger, smaller, or the same size as the old memory allocation.
254/// If `new_n` is 0, this is the same as `free` and it always succeeds.254/// If `new_n` is 0, this is the same as `free` and it always succeeds.
255pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) t: {255pub fn realloc(self: Allocator, old_mem: anytype, new_n: usize) t: {
256 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;256 const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
257 break :t Error![]align(Slice.alignment) Slice.child;257 break :t Error![]align(Slice.alignment) Slice.child;
258} {258} {
259 return self.reallocAdvanced(old_mem, new_n, @returnAddress());259 return self.reallocAdvanced(old_mem, new_n, @returnAddress());
...@@ -265,10 +265,10 @@ pub fn reallocAdvanced(...@@ -265,10 +265,10 @@ pub fn reallocAdvanced(
265 new_n: usize,265 new_n: usize,
266 return_address: usize,266 return_address: usize,
267) t: {267) t: {
268 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;268 const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
269 break :t Error![]align(Slice.alignment) Slice.child;269 break :t Error![]align(Slice.alignment) Slice.child;
270} {270} {
271 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;271 const Slice = @typeInfo(@TypeOf(old_mem)).pointer;
272 const T = Slice.child;272 const T = Slice.child;
273 if (old_mem.len == 0) {273 if (old_mem.len == 0) {
274 return self.allocAdvancedWithRetAddr(T, Slice.alignment, new_n, return_address);274 return self.allocAdvancedWithRetAddr(T, Slice.alignment, new_n, return_address);
...@@ -304,7 +304,7 @@ pub fn reallocAdvanced(...@@ -304,7 +304,7 @@ pub fn reallocAdvanced(
304/// Free an array allocated with `alloc`. To free a single item,304/// Free an array allocated with `alloc`. To free a single item,
305/// see `destroy`.305/// see `destroy`.
306pub fn free(self: Allocator, memory: anytype) void {306pub fn free(self: Allocator, memory: anytype) void {
307 const Slice = @typeInfo(@TypeOf(memory)).Pointer;307 const Slice = @typeInfo(@TypeOf(memory)).pointer;
308 const bytes = mem.sliceAsBytes(memory);308 const bytes = mem.sliceAsBytes(memory);
309 const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;309 const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;
310 if (bytes_len == 0) return;310 if (bytes_len == 0) return;
...@@ -332,13 +332,13 @@ pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T {...@@ -332,13 +332,13 @@ pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T {
332/// TODO replace callsites with `@log2` after this proposal is implemented:332/// TODO replace callsites with `@log2` after this proposal is implemented:
333/// https://github.com/ziglang/zig/issues/13642333/// https://github.com/ziglang/zig/issues/13642
334inline fn log2a(x: anytype) switch (@typeInfo(@TypeOf(x))) {334inline fn log2a(x: anytype) switch (@typeInfo(@TypeOf(x))) {
335 .Int => math.Log2Int(@TypeOf(x)),335 .int => math.Log2Int(@TypeOf(x)),
336 .ComptimeInt => comptime_int,336 .comptime_int => comptime_int,
337 else => @compileError("int please"),337 else => @compileError("int please"),
338} {338} {
339 switch (@typeInfo(@TypeOf(x))) {339 switch (@typeInfo(@TypeOf(x))) {
340 .Int => return math.log2_int(@TypeOf(x), x),340 .int => return math.log2_int(@TypeOf(x), x),
341 .ComptimeInt => return math.log2(x),341 .comptime_int => return math.log2(x),
342 else => @compileError("bad"),342 else => @compileError("bad"),
343 }343 }
344}344}
lib/std/meta.zig+95-95
...@@ -21,11 +21,11 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {...@@ -21,11 +21,11 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
21 // TODO The '100' here is arbitrary and should be increased when possible:21 // TODO The '100' here is arbitrary and should be increased when possible:
22 // - https://github.com/ziglang/zig/issues/405522 // - https://github.com/ziglang/zig/issues/4055
23 // - https://github.com/ziglang/zig/issues/386323 // - https://github.com/ziglang/zig/issues/3863
24 if (@typeInfo(T).Enum.fields.len <= 100) {24 if (@typeInfo(T).@"enum".fields.len <= 100) {
25 const kvs = comptime build_kvs: {25 const kvs = comptime build_kvs: {
26 const EnumKV = struct { []const u8, T };26 const EnumKV = struct { []const u8, T };
27 var kvs_array: [@typeInfo(T).Enum.fields.len]EnumKV = undefined;27 var kvs_array: [@typeInfo(T).@"enum".fields.len]EnumKV = undefined;
28 for (@typeInfo(T).Enum.fields, 0..) |enumField, i| {28 for (@typeInfo(T).@"enum".fields, 0..) |enumField, i| {
29 kvs_array[i] = .{ enumField.name, @field(T, enumField.name) };29 kvs_array[i] = .{ enumField.name, @field(T, enumField.name) };
30 }30 }
31 break :build_kvs kvs_array[0..];31 break :build_kvs kvs_array[0..];
...@@ -33,7 +33,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {...@@ -33,7 +33,7 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
33 const map = std.StaticStringMap(T).initComptime(kvs);33 const map = std.StaticStringMap(T).initComptime(kvs);
34 return map.get(str);34 return map.get(str);
35 } else {35 } else {
36 inline for (@typeInfo(T).Enum.fields) |enumField| {36 inline for (@typeInfo(T).@"enum".fields) |enumField| {
37 if (mem.eql(u8, str, enumField.name)) {37 if (mem.eql(u8, str, enumField.name)) {
38 return @field(T, enumField.name);38 return @field(T, enumField.name);
39 }39 }
...@@ -58,11 +58,11 @@ test stringToEnum {...@@ -58,11 +58,11 @@ test stringToEnum {
58/// If T is a pointer type the alignment of the type it points to is returned.58/// If T is a pointer type the alignment of the type it points to is returned.
59pub fn alignment(comptime T: type) comptime_int {59pub fn alignment(comptime T: type) comptime_int {
60 return switch (@typeInfo(T)) {60 return switch (@typeInfo(T)) {
61 .Optional => |info| switch (@typeInfo(info.child)) {61 .optional => |info| switch (@typeInfo(info.child)) {
62 .Pointer, .Fn => alignment(info.child),62 .pointer, .@"fn" => alignment(info.child),
63 else => @alignOf(T),63 else => @alignOf(T),
64 },64 },
65 .Pointer => |info| info.alignment,65 .pointer => |info| info.alignment,
66 else => @alignOf(T),66 else => @alignOf(T),
67 };67 };
68}68}
...@@ -81,10 +81,10 @@ test alignment {...@@ -81,10 +81,10 @@ test alignment {
81/// Given a parameterized type (array, vector, pointer, optional), returns the "child type".81/// Given a parameterized type (array, vector, pointer, optional), returns the "child type".
82pub fn Child(comptime T: type) type {82pub fn Child(comptime T: type) type {
83 return switch (@typeInfo(T)) {83 return switch (@typeInfo(T)) {
84 .Array => |info| info.child,84 .array => |info| info.child,
85 .Vector => |info| info.child,85 .vector => |info| info.child,
86 .Pointer => |info| info.child,86 .pointer => |info| info.child,
87 .Optional => |info| info.child,87 .optional => |info| info.child,
88 else => @compileError("Expected pointer, optional, array or vector type, found '" ++ @typeName(T) ++ "'"),88 else => @compileError("Expected pointer, optional, array or vector type, found '" ++ @typeName(T) ++ "'"),
89 };89 };
90}90}
...@@ -100,17 +100,17 @@ test Child {...@@ -100,17 +100,17 @@ test Child {
100/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".100/// Given a "memory span" type (array, slice, vector, or pointer to such), returns the "element type".
101pub fn Elem(comptime T: type) type {101pub fn Elem(comptime T: type) type {
102 switch (@typeInfo(T)) {102 switch (@typeInfo(T)) {
103 .Array => |info| return info.child,103 .array => |info| return info.child,
104 .Vector => |info| return info.child,104 .vector => |info| return info.child,
105 .Pointer => |info| switch (info.size) {105 .pointer => |info| switch (info.size) {
106 .One => switch (@typeInfo(info.child)) {106 .One => switch (@typeInfo(info.child)) {
107 .Array => |array_info| return array_info.child,107 .array => |array_info| return array_info.child,
108 .Vector => |vector_info| return vector_info.child,108 .vector => |vector_info| return vector_info.child,
109 else => {},109 else => {},
110 },110 },
111 .Many, .C, .Slice => return info.child,111 .Many, .C, .Slice => return info.child,
112 },112 },
113 .Optional => |info| return Elem(info.child),113 .optional => |info| return Elem(info.child),
114 else => {},114 else => {},
115 }115 }
116 @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'");116 @compileError("Expected pointer, slice, array or vector type, found '" ++ @typeName(T) ++ "'");
...@@ -132,18 +132,18 @@ test Elem {...@@ -132,18 +132,18 @@ test Elem {
132/// Result is always comptime-known.132/// Result is always comptime-known.
133pub inline fn sentinel(comptime T: type) ?Elem(T) {133pub inline fn sentinel(comptime T: type) ?Elem(T) {
134 switch (@typeInfo(T)) {134 switch (@typeInfo(T)) {
135 .Array => |info| {135 .array => |info| {
136 const sentinel_ptr = info.sentinel orelse return null;136 const sentinel_ptr = info.sentinel orelse return null;
137 return @as(*const info.child, @ptrCast(sentinel_ptr)).*;137 return @as(*const info.child, @ptrCast(sentinel_ptr)).*;
138 },138 },
139 .Pointer => |info| {139 .pointer => |info| {
140 switch (info.size) {140 switch (info.size) {
141 .Many, .Slice => {141 .Many, .Slice => {
142 const sentinel_ptr = info.sentinel orelse return null;142 const sentinel_ptr = info.sentinel orelse return null;
143 return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;143 return @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*;
144 },144 },
145 .One => switch (@typeInfo(info.child)) {145 .One => switch (@typeInfo(info.child)) {
146 .Array => |array_info| {146 .array => |array_info| {
147 const sentinel_ptr = array_info.sentinel orelse return null;147 const sentinel_ptr = array_info.sentinel orelse return null;
148 return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;148 return @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*;
149 },149 },
...@@ -177,17 +177,17 @@ fn testSentinel() !void {...@@ -177,17 +177,17 @@ fn testSentinel() !void {
177/// Given a "memory span" type, returns the same type except with the given sentinel value.177/// Given a "memory span" type, returns the same type except with the given sentinel value.
178pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {178pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
179 switch (@typeInfo(T)) {179 switch (@typeInfo(T)) {
180 .Pointer => |info| switch (info.size) {180 .pointer => |info| switch (info.size) {
181 .One => switch (@typeInfo(info.child)) {181 .One => switch (@typeInfo(info.child)) {
182 .Array => |array_info| return @Type(.{182 .array => |array_info| return @Type(.{
183 .Pointer = .{183 .pointer = .{
184 .size = info.size,184 .size = info.size,
185 .is_const = info.is_const,185 .is_const = info.is_const,
186 .is_volatile = info.is_volatile,186 .is_volatile = info.is_volatile,
187 .alignment = info.alignment,187 .alignment = info.alignment,
188 .address_space = info.address_space,188 .address_space = info.address_space,
189 .child = @Type(.{189 .child = @Type(.{
190 .Array = .{190 .array = .{
191 .len = array_info.len,191 .len = array_info.len,
192 .child = array_info.child,192 .child = array_info.child,
193 .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),193 .sentinel = @as(?*const anyopaque, @ptrCast(&sentinel_val)),
...@@ -200,7 +200,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {...@@ -200,7 +200,7 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
200 else => {},200 else => {},
201 },201 },
202 .Many, .Slice => return @Type(.{202 .Many, .Slice => return @Type(.{
203 .Pointer = .{203 .pointer = .{
204 .size = info.size,204 .size = info.size,
205 .is_const = info.is_const,205 .is_const = info.is_const,
206 .is_volatile = info.is_volatile,206 .is_volatile = info.is_volatile,
...@@ -213,12 +213,12 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {...@@ -213,12 +213,12 @@ pub fn Sentinel(comptime T: type, comptime sentinel_val: Elem(T)) type {
213 }),213 }),
214 else => {},214 else => {},
215 },215 },
216 .Optional => |info| switch (@typeInfo(info.child)) {216 .optional => |info| switch (@typeInfo(info.child)) {
217 .Pointer => |ptr_info| switch (ptr_info.size) {217 .pointer => |ptr_info| switch (ptr_info.size) {
218 .Many => return @Type(.{218 .Many => return @Type(.{
219 .Optional = .{219 .optional = .{
220 .child = @Type(.{220 .child = @Type(.{
221 .Pointer = .{221 .pointer = .{
222 .size = ptr_info.size,222 .size = ptr_info.size,
223 .is_const = ptr_info.is_const,223 .is_const = ptr_info.is_const,
224 .is_volatile = ptr_info.is_volatile,224 .is_volatile = ptr_info.is_volatile,
...@@ -244,8 +244,8 @@ pub const assumeSentinel = @compileError("This function has been removed, consid...@@ -244,8 +244,8 @@ pub const assumeSentinel = @compileError("This function has been removed, consid
244244
245pub fn containerLayout(comptime T: type) Type.ContainerLayout {245pub fn containerLayout(comptime T: type) Type.ContainerLayout {
246 return switch (@typeInfo(T)) {246 return switch (@typeInfo(T)) {
247 .Struct => |info| info.layout,247 .@"struct" => |info| info.layout,
248 .Union => |info| info.layout,248 .@"union" => |info| info.layout,
249 else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"),249 else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"),
250 };250 };
251}251}
...@@ -276,10 +276,10 @@ test containerLayout {...@@ -276,10 +276,10 @@ test containerLayout {
276/// directly when you know what kind of type it is.276/// directly when you know what kind of type it is.
277pub fn declarations(comptime T: type) []const Type.Declaration {277pub fn declarations(comptime T: type) []const Type.Declaration {
278 return switch (@typeInfo(T)) {278 return switch (@typeInfo(T)) {
279 .Struct => |info| info.decls,279 .@"struct" => |info| info.decls,
280 .Enum => |info| info.decls,280 .@"enum" => |info| info.decls,
281 .Union => |info| info.decls,281 .@"union" => |info| info.decls,
282 .Opaque => |info| info.decls,282 .@"opaque" => |info| info.decls,
283 else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"),283 else => @compileError("Expected struct, enum, union, or opaque type, found '" ++ @typeName(T) ++ "'"),
284 };284 };
285}285}
...@@ -350,17 +350,17 @@ test declarationInfo {...@@ -350,17 +350,17 @@ test declarationInfo {
350 }350 }
351}351}
352pub fn fields(comptime T: type) switch (@typeInfo(T)) {352pub fn fields(comptime T: type) switch (@typeInfo(T)) {
353 .Struct => []const Type.StructField,353 .@"struct" => []const Type.StructField,
354 .Union => []const Type.UnionField,354 .@"union" => []const Type.UnionField,
355 .ErrorSet => []const Type.Error,355 .@"enum" => []const Type.EnumField,
356 .Enum => []const Type.EnumField,356 .error_set => []const Type.Error,
357 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),357 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
358} {358} {
359 return switch (@typeInfo(T)) {359 return switch (@typeInfo(T)) {
360 .Struct => |info| info.fields,360 .@"struct" => |info| info.fields,
361 .Union => |info| info.fields,361 .@"union" => |info| info.fields,
362 .Enum => |info| info.fields,362 .@"enum" => |info| info.fields,
363 .ErrorSet => |errors| errors.?, // must be non global error set363 .error_set => |errors| errors.?, // must be non global error set
364 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),364 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
365 };365 };
366}366}
...@@ -395,10 +395,10 @@ test fields {...@@ -395,10 +395,10 @@ test fields {
395}395}
396396
397pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {397pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
398 .Struct => Type.StructField,398 .@"struct" => Type.StructField,
399 .Union => Type.UnionField,399 .@"union" => Type.UnionField,
400 .ErrorSet => Type.Error,400 .@"enum" => Type.EnumField,
401 .Enum => Type.EnumField,401 .error_set => Type.Error,
402 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),402 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
403} {403} {
404 return fields(T)[@intFromEnum(field)];404 return fields(T)[@intFromEnum(field)];
...@@ -430,7 +430,7 @@ test fieldInfo {...@@ -430,7 +430,7 @@ test fieldInfo {
430}430}
431431
432pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {432pub fn FieldType(comptime T: type, comptime field: FieldEnum(T)) type {
433 if (@typeInfo(T) != .Struct and @typeInfo(T) != .Union) {433 if (@typeInfo(T) != .@"struct" and @typeInfo(T) != .@"union") {
434 @compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'");434 @compileError("Expected struct or union, found '" ++ @typeName(T) ++ "'");
435 }435 }
436436
...@@ -528,7 +528,7 @@ pub fn FieldEnum(comptime T: type) type {...@@ -528,7 +528,7 @@ pub fn FieldEnum(comptime T: type) type {
528528
529 if (field_infos.len == 0) {529 if (field_infos.len == 0) {
530 return @Type(.{530 return @Type(.{
531 .Enum = .{531 .@"enum" = .{
532 .tag_type = u0,532 .tag_type = u0,
533 .fields = &.{},533 .fields = &.{},
534 .decls = &.{},534 .decls = &.{},
...@@ -537,8 +537,8 @@ pub fn FieldEnum(comptime T: type) type {...@@ -537,8 +537,8 @@ pub fn FieldEnum(comptime T: type) type {
537 });537 });
538 }538 }
539539
540 if (@typeInfo(T) == .Union) {540 if (@typeInfo(T) == .@"union") {
541 if (@typeInfo(T).Union.tag_type) |tag_type| {541 if (@typeInfo(T).@"union".tag_type) |tag_type| {
542 for (std.enums.values(tag_type), 0..) |v, i| {542 for (std.enums.values(tag_type), 0..) |v, i| {
543 if (@intFromEnum(v) != i) break; // enum values not consecutive543 if (@intFromEnum(v) != i) break; // enum values not consecutive
544 if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order544 if (!std.mem.eql(u8, @tagName(v), field_infos[i].name)) break; // fields out of order
...@@ -557,7 +557,7 @@ pub fn FieldEnum(comptime T: type) type {...@@ -557,7 +557,7 @@ pub fn FieldEnum(comptime T: type) type {
557 };557 };
558 }558 }
559 return @Type(.{559 return @Type(.{
560 .Enum = .{560 .@"enum" = .{
561 .tag_type = std.math.IntFittingRange(0, field_infos.len - 1),561 .tag_type = std.math.IntFittingRange(0, field_infos.len - 1),
562 .fields = &enumFields,562 .fields = &enumFields,
563 .decls = &decls,563 .decls = &decls,
...@@ -568,17 +568,17 @@ pub fn FieldEnum(comptime T: type) type {...@@ -568,17 +568,17 @@ pub fn FieldEnum(comptime T: type) type {
568568
569fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {569fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
570 // TODO: https://github.com/ziglang/zig/issues/7419570 // TODO: https://github.com/ziglang/zig/issues/7419
571 // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum);571 // testing.expectEqual(@typeInfo(expected).@"enum", @typeInfo(actual).@"enum");
572 try testing.expectEqual(572 try testing.expectEqual(
573 @typeInfo(expected).Enum.tag_type,573 @typeInfo(expected).@"enum".tag_type,
574 @typeInfo(actual).Enum.tag_type,574 @typeInfo(actual).@"enum".tag_type,
575 );575 );
576 // For comparing decls and fields, we cannot use the meta eql function here576 // For comparing decls and fields, we cannot use the meta eql function here
577 // because the language does not guarantee that the slice pointers for field names577 // because the language does not guarantee that the slice pointers for field names
578 // and decl names will be the same.578 // and decl names will be the same.
579 comptime {579 comptime {
580 const expected_fields = @typeInfo(expected).Enum.fields;580 const expected_fields = @typeInfo(expected).@"enum".fields;
581 const actual_fields = @typeInfo(actual).Enum.fields;581 const actual_fields = @typeInfo(actual).@"enum".fields;
582 if (expected_fields.len != actual_fields.len) return error.FailedTest;582 if (expected_fields.len != actual_fields.len) return error.FailedTest;
583 for (expected_fields, 0..) |expected_field, i| {583 for (expected_fields, 0..) |expected_field, i| {
584 const actual_field = actual_fields[i];584 const actual_field = actual_fields[i];
...@@ -587,8 +587,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {...@@ -587,8 +587,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
587 }587 }
588 }588 }
589 comptime {589 comptime {
590 const expected_decls = @typeInfo(expected).Enum.decls;590 const expected_decls = @typeInfo(expected).@"enum".decls;
591 const actual_decls = @typeInfo(actual).Enum.decls;591 const actual_decls = @typeInfo(actual).@"enum".decls;
592 if (expected_decls.len != actual_decls.len) return error.FailedTest;592 if (expected_decls.len != actual_decls.len) return error.FailedTest;
593 for (expected_decls, 0..) |expected_decl, i| {593 for (expected_decls, 0..) |expected_decl, i| {
594 const actual_decl = actual_decls[i];594 const actual_decl = actual_decls[i];
...@@ -596,8 +596,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {...@@ -596,8 +596,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
596 }596 }
597 }597 }
598 try testing.expectEqual(598 try testing.expectEqual(
599 @typeInfo(expected).Enum.is_exhaustive,599 @typeInfo(expected).@"enum".is_exhaustive,
600 @typeInfo(actual).Enum.is_exhaustive,600 @typeInfo(actual).@"enum".is_exhaustive,
601 );601 );
602}602}
603603
...@@ -627,7 +627,7 @@ pub fn DeclEnum(comptime T: type) type {...@@ -627,7 +627,7 @@ pub fn DeclEnum(comptime T: type) type {
627 enumDecls[i] = .{ .name = field.name ++ "", .value = i };627 enumDecls[i] = .{ .name = field.name ++ "", .value = i };
628 }628 }
629 return @Type(.{629 return @Type(.{
630 .Enum = .{630 .@"enum" = .{
631 .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1),631 .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1),
632 .fields = &enumDecls,632 .fields = &enumDecls,
633 .decls = &decls,633 .decls = &decls,
...@@ -661,8 +661,8 @@ test DeclEnum {...@@ -661,8 +661,8 @@ test DeclEnum {
661661
662pub fn Tag(comptime T: type) type {662pub fn Tag(comptime T: type) type {
663 return switch (@typeInfo(T)) {663 return switch (@typeInfo(T)) {
664 .Enum => |info| info.tag_type,664 .@"enum" => |info| info.tag_type,
665 .Union => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"),665 .@"union" => |info| info.tag_type orelse @compileError(@typeName(T) ++ " has no tag type"),
666 else => @compileError("expected enum or union type, found '" ++ @typeName(T) ++ "'"),666 else => @compileError("expected enum or union type, found '" ++ @typeName(T) ++ "'"),
667 };667 };
668}668}
...@@ -708,7 +708,7 @@ test activeTag {...@@ -708,7 +708,7 @@ test activeTag {
708const TagPayloadType = TagPayload;708const TagPayloadType = TagPayload;
709709
710pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {710pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
711 const info = @typeInfo(U).Union;711 const info = @typeInfo(U).@"union";
712712
713 inline for (info.fields) |field_info| {713 inline for (info.fields) |field_info| {
714 if (comptime mem.eql(u8, field_info.name, tag_name))714 if (comptime mem.eql(u8, field_info.name, tag_name))
...@@ -742,20 +742,20 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {...@@ -742,20 +742,20 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
742 const T = @TypeOf(a);742 const T = @TypeOf(a);
743743
744 switch (@typeInfo(T)) {744 switch (@typeInfo(T)) {
745 .Struct => |info| {745 .@"struct" => |info| {
746 inline for (info.fields) |field_info| {746 inline for (info.fields) |field_info| {
747 if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false;747 if (!eql(@field(a, field_info.name), @field(b, field_info.name))) return false;
748 }748 }
749 return true;749 return true;
750 },750 },
751 .ErrorUnion => {751 .error_union => {
752 if (a) |a_p| {752 if (a) |a_p| {
753 if (b) |b_p| return eql(a_p, b_p) else |_| return false;753 if (b) |b_p| return eql(a_p, b_p) else |_| return false;
754 } else |a_e| {754 } else |a_e| {
755 if (b) |_| return false else |b_e| return a_e == b_e;755 if (b) |_| return false else |b_e| return a_e == b_e;
756 }756 }
757 },757 },
758 .Union => |info| {758 .@"union" => |info| {
759 if (info.tag_type) |UnionTag| {759 if (info.tag_type) |UnionTag| {
760 const tag_a: UnionTag = a;760 const tag_a: UnionTag = a;
761 const tag_b: UnionTag = b;761 const tag_b: UnionTag = b;
...@@ -768,26 +768,26 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {...@@ -768,26 +768,26 @@ pub fn eql(a: anytype, b: @TypeOf(a)) bool {
768768
769 @compileError("cannot compare untagged union type " ++ @typeName(T));769 @compileError("cannot compare untagged union type " ++ @typeName(T));
770 },770 },
771 .Array => {771 .array => {
772 if (a.len != b.len) return false;772 if (a.len != b.len) return false;
773 for (a, 0..) |e, i|773 for (a, 0..) |e, i|
774 if (!eql(e, b[i])) return false;774 if (!eql(e, b[i])) return false;
775 return true;775 return true;
776 },776 },
777 .Vector => |info| {777 .vector => |info| {
778 var i: usize = 0;778 var i: usize = 0;
779 while (i < info.len) : (i += 1) {779 while (i < info.len) : (i += 1) {
780 if (!eql(a[i], b[i])) return false;780 if (!eql(a[i], b[i])) return false;
781 }781 }
782 return true;782 return true;
783 },783 },
784 .Pointer => |info| {784 .pointer => |info| {
785 return switch (info.size) {785 return switch (info.size) {
786 .One, .Many, .C => a == b,786 .One, .Many, .C => a == b,
787 .Slice => a.ptr == b.ptr and a.len == b.len,787 .Slice => a.ptr == b.ptr and a.len == b.len,
788 };788 };
789 },789 },
790 .Optional => {790 .optional => {
791 if (a == null and b == null) return true;791 if (a == null and b == null) return true;
792 if (a == null or b == null) return false;792 if (a == null or b == null) return false;
793 return eql(a.?, b.?);793 return eql(a.?, b.?);
...@@ -893,7 +893,7 @@ test intToEnum {...@@ -893,7 +893,7 @@ test intToEnum {
893pub const IntToEnumError = error{InvalidEnumTag};893pub const IntToEnumError = error{InvalidEnumTag};
894894
895pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag {895pub fn intToEnum(comptime EnumTag: type, tag_int: anytype) IntToEnumError!EnumTag {
896 const enum_info = @typeInfo(EnumTag).Enum;896 const enum_info = @typeInfo(EnumTag).@"enum";
897897
898 if (!enum_info.is_exhaustive) {898 if (!enum_info.is_exhaustive) {
899 if (std.math.cast(enum_info.tag_type, tag_int)) |tag| {899 if (std.math.cast(enum_info.tag_type, tag_int)) |tag| {
...@@ -955,7 +955,7 @@ pub const IntType = @compileError("replaced by std.meta.Int");...@@ -955,7 +955,7 @@ pub const IntType = @compileError("replaced by std.meta.Int");
955955
956pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type {956pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type {
957 return @Type(.{957 return @Type(.{
958 .Int = .{958 .int = .{
959 .signedness = signedness,959 .signedness = signedness,
960 .bits = bit_count,960 .bits = bit_count,
961 },961 },
...@@ -964,7 +964,7 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16)...@@ -964,7 +964,7 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16)
964964
965pub fn Float(comptime bit_count: u8) type {965pub fn Float(comptime bit_count: u8) type {
966 return @Type(.{966 return @Type(.{
967 .Float = .{ .bits = bit_count },967 .float = .{ .bits = bit_count },
968 });968 });
969}969}
970970
...@@ -984,10 +984,10 @@ test Float {...@@ -984,10 +984,10 @@ test Float {
984/// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }`984/// - `ArgsTuple(fn (a: u32, b: f16) noreturn)` ⇒ `tuple { u32, f16 }`
985pub fn ArgsTuple(comptime Function: type) type {985pub fn ArgsTuple(comptime Function: type) type {
986 const info = @typeInfo(Function);986 const info = @typeInfo(Function);
987 if (info != .Fn)987 if (info != .@"fn")
988 @compileError("ArgsTuple expects a function type");988 @compileError("ArgsTuple expects a function type");
989989
990 const function_info = info.Fn;990 const function_info = info.@"fn";
991 if (function_info.is_var_args)991 if (function_info.is_var_args)
992 @compileError("Cannot create ArgsTuple for variadic function");992 @compileError("Cannot create ArgsTuple for variadic function");
993993
...@@ -1026,7 +1026,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {...@@ -1026,7 +1026,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {
1026 }1026 }
10271027
1028 return @Type(.{1028 return @Type(.{
1029 .Struct = .{1029 .@"struct" = .{
1030 .is_tuple = true,1030 .is_tuple = true,
1031 .layout = .auto,1031 .layout = .auto,
1032 .decls = &.{},1032 .decls = &.{},
...@@ -1043,9 +1043,9 @@ const TupleTester = struct {...@@ -1043,9 +1043,9 @@ const TupleTester = struct {
10431043
1044 fn assertTuple(comptime expected: anytype, comptime Actual: type) void {1044 fn assertTuple(comptime expected: anytype, comptime Actual: type) void {
1045 const info = @typeInfo(Actual);1045 const info = @typeInfo(Actual);
1046 if (info != .Struct)1046 if (info != .@"struct")
1047 @compileError("Expected struct type");1047 @compileError("Expected struct type");
1048 if (!info.Struct.is_tuple)1048 if (!info.@"struct".is_tuple)
1049 @compileError("Struct type must be a tuple type");1049 @compileError("Struct type must be a tuple type");
10501050
1051 const fields_list = std.meta.fields(Actual);1051 const fields_list = std.meta.fields(Actual);
...@@ -1115,13 +1115,13 @@ test isError {...@@ -1115,13 +1115,13 @@ test isError {
1115/// `false` otherwise. Result is always comptime-known.1115/// `false` otherwise. Result is always comptime-known.
1116pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool {1116pub inline fn hasFn(comptime T: type, comptime name: []const u8) bool {
1117 switch (@typeInfo(T)) {1117 switch (@typeInfo(T)) {
1118 .Struct, .Union, .Enum, .Opaque => {},1118 .@"struct", .@"union", .@"enum", .@"opaque" => {},
1119 else => return false,1119 else => return false,
1120 }1120 }
1121 if (!@hasDecl(T, name))1121 if (!@hasDecl(T, name))
1122 return false;1122 return false;
11231123
1124 return @typeInfo(@TypeOf(@field(T, name))) == .Fn;1124 return @typeInfo(@TypeOf(@field(T, name))) == .@"fn";
1125}1125}
11261126
1127test hasFn {1127test hasFn {
...@@ -1144,7 +1144,7 @@ test hasFn {...@@ -1144,7 +1144,7 @@ test hasFn {
1144/// Result is always comptime-known.1144/// Result is always comptime-known.
1145pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {1145pub inline fn hasMethod(comptime T: type, comptime name: []const u8) bool {
1146 return switch (@typeInfo(T)) {1146 return switch (@typeInfo(T)) {
1147 .Pointer => |P| switch (P.size) {1147 .pointer => |P| switch (P.size) {
1148 .One => hasFn(P.child, name),1148 .One => hasFn(P.child, name),
1149 .Many, .Slice, .C => false,1149 .Many, .Slice, .C => false,
1150 },1150 },
...@@ -1191,29 +1191,29 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {...@@ -1191,29 +1191,29 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
1191 return switch (@typeInfo(T)) {1191 return switch (@typeInfo(T)) {
1192 else => false, // TODO can we know if it's true for some of these types ?1192 else => false, // TODO can we know if it's true for some of these types ?
11931193
1194 .AnyFrame,1194 .@"anyframe",
1195 .Enum,1195 .@"enum",
1196 .ErrorSet,1196 .error_set,
1197 .Fn,1197 .@"fn",
1198 => true,1198 => true,
11991199
1200 .Bool => false,1200 .bool => false,
12011201
1202 .Int => |info| @sizeOf(T) * 8 == info.bits,1202 .int => |info| @sizeOf(T) * 8 == info.bits,
12031203
1204 .Pointer => |info| info.size != .Slice,1204 .pointer => |info| info.size != .Slice,
12051205
1206 .Optional => |info| switch (@typeInfo(info.child)) {1206 .optional => |info| switch (@typeInfo(info.child)) {
1207 .Pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {1207 .pointer => |ptr| !ptr.is_allowzero and switch (ptr.size) {
1208 .Slice, .C => false,1208 .Slice, .C => false,
1209 .One, .Many => true,1209 .One, .Many => true,
1210 },1210 },
1211 else => false,1211 else => false,
1212 },1212 },
12131213
1214 .Array => |info| hasUniqueRepresentation(info.child),1214 .array => |info| hasUniqueRepresentation(info.child),
12151215
1216 .Struct => |info| {1216 .@"struct" => |info| {
1217 if (info.layout == .@"packed") return @sizeOf(T) * 8 == @bitSizeOf(T);1217 if (info.layout == .@"packed") return @sizeOf(T) * 8 == @bitSizeOf(T);
12181218
1219 var sum_size = @as(usize, 0);1219 var sum_size = @as(usize, 0);
...@@ -1226,7 +1226,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {...@@ -1226,7 +1226,7 @@ pub inline fn hasUniqueRepresentation(comptime T: type) bool {
1226 return @sizeOf(T) == sum_size;1226 return @sizeOf(T) == sum_size;
1227 },1227 },
12281228
1229 .Vector => |info| hasUniqueRepresentation(info.child) and1229 .vector => |info| hasUniqueRepresentation(info.child) and
1230 @sizeOf(T) == @sizeOf(info.child) * info.len,1230 @sizeOf(T) == @sizeOf(info.child) * info.len,
1231 };1231 };
1232}1232}
lib/std/meta/trailer_flags.zig+8-8
...@@ -14,14 +14,14 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -14,14 +14,14 @@ pub fn TrailerFlags(comptime Fields: type) type {
14 bits: Int,14 bits: Int,
1515
16 pub const Int = meta.Int(.unsigned, bit_count);16 pub const Int = meta.Int(.unsigned, bit_count);
17 pub const bit_count = @typeInfo(Fields).Struct.fields.len;17 pub const bit_count = @typeInfo(Fields).@"struct".fields.len;
1818
19 pub const FieldEnum = std.meta.FieldEnum(Fields);19 pub const FieldEnum = std.meta.FieldEnum(Fields);
2020
21 pub const ActiveFields = std.enums.EnumFieldStruct(FieldEnum, bool, false);21 pub const ActiveFields = std.enums.EnumFieldStruct(FieldEnum, bool, false);
22 pub const FieldValues = blk: {22 pub const FieldValues = blk: {
23 var fields: [bit_count]Type.StructField = undefined;23 var fields: [bit_count]Type.StructField = undefined;
24 for (@typeInfo(Fields).Struct.fields, 0..) |struct_field, i| {24 for (@typeInfo(Fields).@"struct".fields, 0..) |struct_field, i| {
25 fields[i] = Type.StructField{25 fields[i] = Type.StructField{
26 .name = struct_field.name,26 .name = struct_field.name,
27 .type = ?struct_field.type,27 .type = ?struct_field.type,
...@@ -31,7 +31,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -31,7 +31,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
31 };31 };
32 }32 }
33 break :blk @Type(.{33 break :blk @Type(.{
34 .Struct = .{34 .@"struct" = .{
35 .layout = .auto,35 .layout = .auto,
36 .fields = &fields,36 .fields = &fields,
37 .decls = &.{},37 .decls = &.{},
...@@ -61,7 +61,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -61,7 +61,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
61 /// `fields` is a boolean struct where each active field is set to `true`61 /// `fields` is a boolean struct where each active field is set to `true`
62 pub fn init(fields: ActiveFields) Self {62 pub fn init(fields: ActiveFields) Self {
63 var self: Self = .{ .bits = 0 };63 var self: Self = .{ .bits = 0 };
64 inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {64 inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| {
65 if (@field(fields, field.name))65 if (@field(fields, field.name))
66 self.bits |= 1 << i;66 self.bits |= 1 << i;
67 }67 }
...@@ -70,7 +70,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -70,7 +70,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
7070
71 /// `fields` is a struct with each field set to an optional value71 /// `fields` is a struct with each field set to an optional value
72 pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void {72 pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void {
73 inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {73 inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| {
74 if (@field(fields, field.name)) |value|74 if (@field(fields, field.name)) |value|
75 self.set(p, @as(FieldEnum, @enumFromInt(i)), value);75 self.set(p, @as(FieldEnum, @enumFromInt(i)), value);
76 }76 }
...@@ -101,7 +101,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -101,7 +101,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
101101
102 pub fn offset(self: Self, comptime field: FieldEnum) usize {102 pub fn offset(self: Self, comptime field: FieldEnum) usize {
103 var off: usize = 0;103 var off: usize = 0;
104 inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| {104 inline for (@typeInfo(Fields).@"struct".fields, 0..) |field_info, i| {
105 const active = (self.bits & (1 << i)) != 0;105 const active = (self.bits & (1 << i)) != 0;
106 if (i == @intFromEnum(field)) {106 if (i == @intFromEnum(field)) {
107 assert(active);107 assert(active);
...@@ -114,12 +114,12 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -114,12 +114,12 @@ pub fn TrailerFlags(comptime Fields: type) type {
114 }114 }
115115
116 pub fn Field(comptime field: FieldEnum) type {116 pub fn Field(comptime field: FieldEnum) type {
117 return @typeInfo(Fields).Struct.fields[@intFromEnum(field)].type;117 return @typeInfo(Fields).@"struct".fields[@intFromEnum(field)].type;
118 }118 }
119119
120 pub fn sizeInBytes(self: Self) usize {120 pub fn sizeInBytes(self: Self) usize {
121 var off: usize = 0;121 var off: usize = 0;
122 inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| {122 inline for (@typeInfo(Fields).@"struct".fields, 0..) |field, i| {
123 if (@sizeOf(field.type) == 0)123 if (@sizeOf(field.type) == 0)
124 continue;124 continue;
125 if ((self.bits & (1 << i)) != 0) {125 if ((self.bits & (1 << i)) != 0) {
lib/std/multi_array_list.zig+10-11
...@@ -24,10 +24,9 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -24,10 +24,9 @@ pub fn MultiArrayList(comptime T: type) type {
24 capacity: usize = 0,24 capacity: usize = 0,
2525
26 const Elem = switch (@typeInfo(T)) {26 const Elem = switch (@typeInfo(T)) {
27 .Struct => T,27 .@"struct" => T,
28 .Union => |u| struct {28 .@"union" => |u| struct {
29 pub const Bare =29 pub const Bare = @Type(.{ .@"union" = .{
30 @Type(.{ .Union = .{
31 .layout = u.layout,30 .layout = u.layout,
32 .tag_type = null,31 .tag_type = null,
33 .fields = u.fields,32 .fields = u.fields,
...@@ -84,8 +83,8 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -84,8 +83,8 @@ pub fn MultiArrayList(comptime T: type) type {
8483
85 pub fn set(self: *Slice, index: usize, elem: T) void {84 pub fn set(self: *Slice, index: usize, elem: T) void {
86 const e = switch (@typeInfo(T)) {85 const e = switch (@typeInfo(T)) {
87 .Struct => elem,86 .@"struct" => elem,
88 .Union => Elem.fromT(elem),87 .@"union" => Elem.fromT(elem),
89 else => unreachable,88 else => unreachable,
90 };89 };
91 inline for (fields, 0..) |field_info, i| {90 inline for (fields, 0..) |field_info, i| {
...@@ -99,8 +98,8 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -99,8 +98,8 @@ pub fn MultiArrayList(comptime T: type) type {
99 @field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index];98 @field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index];
100 }99 }
101 return switch (@typeInfo(T)) {100 return switch (@typeInfo(T)) {
102 .Struct => result,101 .@"struct" => result,
103 .Union => Elem.toT(result.tags, result.data),102 .@"union" => Elem.toT(result.tags, result.data),
104 else => unreachable,103 else => unreachable,
105 };104 };
106 }105 }
...@@ -287,8 +286,8 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -287,8 +286,8 @@ pub fn MultiArrayList(comptime T: type) type {
287 assert(index <= self.len);286 assert(index <= self.len);
288 self.len += 1;287 self.len += 1;
289 const entry = switch (@typeInfo(T)) {288 const entry = switch (@typeInfo(T)) {
290 .Struct => elem,289 .@"struct" => elem,
291 .Union => Elem.fromT(elem),290 .@"union" => Elem.fromT(elem),
292 else => unreachable,291 else => unreachable,
293 };292 };
294 const slices = self.slice();293 const slices = self.slice();
...@@ -557,7 +556,7 @@ pub fn MultiArrayList(comptime T: type) type {...@@ -557,7 +556,7 @@ pub fn MultiArrayList(comptime T: type) type {
557 .is_comptime = fields[i].is_comptime,556 .is_comptime = fields[i].is_comptime,
558 .alignment = fields[i].alignment,557 .alignment = fields[i].alignment,
559 };558 };
560 break :entry @Type(.{ .Struct = .{559 break :entry @Type(.{ .@"struct" = .{
561 .layout = .@"extern",560 .layout = .@"extern",
562 .fields = &entry_fields,561 .fields = &entry_fields,
563 .decls = &.{},562 .decls = &.{},
lib/std/os/emscripten.zig+1-1
...@@ -560,7 +560,7 @@ pub const Sigaction = extern struct {...@@ -560,7 +560,7 @@ pub const Sigaction = extern struct {
560};560};
561561
562pub const sigset_t = [1024 / 32]u32;562pub const sigset_t = [1024 / 32]u32;
563pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len;563pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).array.len;
564pub const siginfo_t = extern struct {564pub const siginfo_t = extern struct {
565 signo: i32,565 signo: i32,
566 errno: i32,566 errno: i32,
lib/std/os/linux.zig+7-7
...@@ -1547,7 +1547,7 @@ pub fn seteuid(euid: uid_t) usize {...@@ -1547,7 +1547,7 @@ pub fn seteuid(euid: uid_t) usize {
1547 // The setresuid(2) man page says that if -1 is passed the corresponding1547 // The setresuid(2) man page says that if -1 is passed the corresponding
1548 // id will not be changed. Since uid_t is unsigned, this wraps around to the1548 // id will not be changed. Since uid_t is unsigned, this wraps around to the
1549 // max value in C.1549 // max value in C.
1550 comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned);1550 comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned);
1551 return setresuid(std.math.maxInt(uid_t), euid, std.math.maxInt(uid_t));1551 return setresuid(std.math.maxInt(uid_t), euid, std.math.maxInt(uid_t));
1552}1552}
15531553
...@@ -1558,7 +1558,7 @@ pub fn setegid(egid: gid_t) usize {...@@ -1558,7 +1558,7 @@ pub fn setegid(egid: gid_t) usize {
1558 // The setresgid(2) man page says that if -1 is passed the corresponding1558 // The setresgid(2) man page says that if -1 is passed the corresponding
1559 // id will not be changed. Since gid_t is unsigned, this wraps around to the1559 // id will not be changed. Since gid_t is unsigned, this wraps around to the
1560 // max value in C.1560 // max value in C.
1561 comptime assert(@typeInfo(uid_t) == .Int and @typeInfo(uid_t).Int.signedness == .unsigned);1561 comptime assert(@typeInfo(uid_t) == .int and @typeInfo(uid_t).int.signedness == .unsigned);
1562 return setresgid(std.math.maxInt(gid_t), egid, std.math.maxInt(gid_t));1562 return setresgid(std.math.maxInt(gid_t), egid, std.math.maxInt(gid_t));
1563}1563}
15641564
...@@ -1673,7 +1673,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact...@@ -1673,7 +1673,7 @@ pub fn sigaction(sig: u6, noalias act: ?*const Sigaction, noalias oact: ?*Sigact
1673 return 0;1673 return 0;
1674}1674}
16751675
1676const usize_bits = @typeInfo(usize).Int.bits;1676const usize_bits = @typeInfo(usize).int.bits;
16771677
1678pub fn sigaddset(set: *sigset_t, sig: u6) void {1678pub fn sigaddset(set: *sigset_t, sig: u6) void {
1679 const s = sig - 1;1679 const s = sig - 1;
...@@ -1734,7 +1734,7 @@ pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize {...@@ -1734,7 +1734,7 @@ pub fn sendmsg(fd: i32, msg: *const msghdr_const, flags: u32) usize {
1734}1734}
17351735
1736pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize {1736pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize {
1737 if (@typeInfo(usize).Int.bits > @typeInfo(@typeInfo(mmsghdr).Struct.fields[1].type).Int.bits) {1737 if (@typeInfo(usize).int.bits > @typeInfo(@typeInfo(mmsghdr).@"struct".fields[1].type).int.bits) {
1738 // workaround kernel brokenness:1738 // workaround kernel brokenness:
1739 // if adding up all iov_len overflows a i32 then split into multiple calls1739 // if adding up all iov_len overflows a i32 then split into multiple calls
1740 // see https://www.openwall.com/lists/musl/2014/06/07/51740 // see https://www.openwall.com/lists/musl/2014/06/07/5
...@@ -4904,7 +4904,7 @@ pub const NSIG = if (is_mips) 128 else 65;...@@ -4904,7 +4904,7 @@ pub const NSIG = if (is_mips) 128 else 65;
49044904
4905pub const sigset_t = [1024 / 32]u32;4905pub const sigset_t = [1024 / 32]u32;
49064906
4907pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).Array.len;4907pub const all_mask: sigset_t = [_]u32{0xffffffff} ** @typeInfo(sigset_t).array.len;
4908pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;4908pub const app_mask: sigset_t = [2]u32{ 0xfffffffc, 0x7fffffff } ++ [_]u32{0xffffffff} ** 30;
49094909
4910const k_sigaction_funcs = struct {4910const k_sigaction_funcs = struct {
...@@ -4947,7 +4947,7 @@ pub const Sigaction = extern struct {...@@ -4947,7 +4947,7 @@ pub const Sigaction = extern struct {
4947 restorer: ?*const fn () callconv(.C) void = null,4947 restorer: ?*const fn () callconv(.C) void = null,
4948};4948};
49494949
4950const sigset_len = @typeInfo(sigset_t).Array.len;4950const sigset_len = @typeInfo(sigset_t).array.len;
4951pub const empty_sigset = [_]u32{0} ** sigset_len;4951pub const empty_sigset = [_]u32{0} ** sigset_len;
4952pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1);4952pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1);
49534953
...@@ -7420,7 +7420,7 @@ pub const MADV = struct {...@@ -7420,7 +7420,7 @@ pub const MADV = struct {
7420};7420};
74217421
7422pub const POSIX_FADV = switch (native_arch) {7422pub const POSIX_FADV = switch (native_arch) {
7423 .s390x => if (@typeInfo(usize).Int.bits == 64) struct {7423 .s390x => if (@typeInfo(usize).int.bits == 64) struct {
7424 pub const NORMAL = 0;7424 pub const NORMAL = 0;
7425 pub const RANDOM = 1;7425 pub const RANDOM = 1;
7426 pub const SEQUENTIAL = 2;7426 pub const SEQUENTIAL = 2;
lib/std/os/linux/bpf.zig+1-1
...@@ -459,7 +459,7 @@ pub const Insn = packed struct {...@@ -459,7 +459,7 @@ pub const Insn = packed struct {
459 };459 };
460460
461 fn imm_reg(code: u8, dst: Reg, src: anytype, off: i16) Insn {461 fn imm_reg(code: u8, dst: Reg, src: anytype, off: i16) Insn {
462 const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .EnumLiteral)462 const imm_or_reg = if (@TypeOf(src) == Reg or @typeInfo(@TypeOf(src)) == .enum_literal)
463 ImmOrReg{ .reg = @as(Reg, src) }463 ImmOrReg{ .reg = @as(Reg, src) }
464 else464 else
465 ImmOrReg{ .imm = src };465 ImmOrReg{ .imm = src };
lib/std/os/uefi/protocol/device_path.zig+2-2
...@@ -76,7 +76,7 @@ pub const DevicePath = extern struct {...@@ -76,7 +76,7 @@ pub const DevicePath = extern struct {
76 }76 }
7777
78 pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {78 pub fn getDevicePath(self: *const DevicePath) ?uefi.DevicePath {
79 inline for (@typeInfo(uefi.DevicePath).Union.fields) |ufield| {79 inline for (@typeInfo(uefi.DevicePath).@"union".fields) |ufield| {
80 const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name);80 const enum_value = std.meta.stringToEnum(uefi.DevicePath.Type, ufield.name);
8181
82 // Got the associated union type for self.type, now82 // Got the associated union type for self.type, now
...@@ -94,7 +94,7 @@ pub const DevicePath = extern struct {...@@ -94,7 +94,7 @@ pub const DevicePath = extern struct {
94 }94 }
9595
96 pub fn initSubtype(self: *const DevicePath, comptime TUnion: type) ?TUnion {96 pub fn initSubtype(self: *const DevicePath, comptime TUnion: type) ?TUnion {
97 const type_info = @typeInfo(TUnion).Union;97 const type_info = @typeInfo(TUnion).@"union";
98 const TTag = type_info.tag_type.?;98 const TTag = type_info.tag_type.?;
9999
100 inline for (type_info.fields) |subtype| {100 inline for (type_info.fields) |subtype| {
lib/std/os/uefi/status.zig+2-2
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const testing = @import("std").testing;1const testing = @import("std").testing;
22
3const high_bit = 1 << @typeInfo(usize).Int.bits - 1;3const high_bit = 1 << @typeInfo(usize).int.bits - 1;
44
5pub const Status = enum(usize) {5pub const Status = enum(usize) {
6 /// The operation completed successfully.6 /// The operation completed successfully.
...@@ -186,7 +186,7 @@ pub const Status = enum(usize) {...@@ -186,7 +186,7 @@ pub const Status = enum(usize) {
186 };186 };
187187
188 pub fn err(self: Status) EfiError!void {188 pub fn err(self: Status) EfiError!void {
189 inline for (@typeInfo(EfiError).ErrorSet.?) |efi_err| {189 inline for (@typeInfo(EfiError).error_set.?) |efi_err| {
190 if (self == @field(Status, efi_err.name)) {190 if (self == @field(Status, efi_err.name)) {
191 return @field(EfiError, efi_err.name);191 return @field(EfiError, efi_err.name);
192 }192 }
lib/std/posix.zig+2-2
...@@ -6181,7 +6181,7 @@ pub fn sendfile(...@@ -6181,7 +6181,7 @@ pub fn sendfile(
6181 var total_written: usize = 0;6181 var total_written: usize = 0;
61826182
6183 // Prevents EOVERFLOW.6183 // Prevents EOVERFLOW.
6184 const size_t = std.meta.Int(.unsigned, @typeInfo(usize).Int.bits - 1);6184 const size_t = std.meta.Int(.unsigned, @typeInfo(usize).int.bits - 1);
6185 const max_count = switch (native_os) {6185 const max_count = switch (native_os) {
6186 .linux => 0x7ffff000,6186 .linux => 0x7ffff000,
6187 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),6187 .macos, .ios, .watchos, .tvos, .visionos => maxInt(i32),
...@@ -6988,7 +6988,7 @@ pub const PrctlError = error{...@@ -6988,7 +6988,7 @@ pub const PrctlError = error{
6988} || UnexpectedError;6988} || UnexpectedError;
69896989
6990pub fn prctl(option: PR, args: anytype) PrctlError!u31 {6990pub fn prctl(option: PR, args: anytype) PrctlError!u31 {
6991 if (@typeInfo(@TypeOf(args)) != .Struct)6991 if (@typeInfo(@TypeOf(args)) != .@"struct")
6992 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));6992 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
6993 if (args.len > 4)6993 if (args.len > 4)
6994 @compileError("prctl takes a maximum of 4 optional arguments");6994 @compileError("prctl takes a maximum of 4 optional arguments");
lib/std/posix/test.zig+1-1
...@@ -782,7 +782,7 @@ test "fsync" {...@@ -782,7 +782,7 @@ test "fsync" {
782test "getrlimit and setrlimit" {782test "getrlimit and setrlimit" {
783 if (posix.system.rlimit_resource == void) return error.SkipZigTest;783 if (posix.system.rlimit_resource == void) return error.SkipZigTest;
784784
785 inline for (@typeInfo(posix.rlimit_resource).Enum.fields) |field| {785 inline for (@typeInfo(posix.rlimit_resource).@"enum".fields) |field| {
786 const resource: posix.rlimit_resource = @enumFromInt(field.value);786 const resource: posix.rlimit_resource = @enumFromInt(field.value);
787 const limit = try posix.getrlimit(resource);787 const limit = try posix.getrlimit(resource);
788788
lib/std/process/Child.zig+1-1
...@@ -1112,7 +1112,7 @@ fn windowsCreateProcessPathExt(...@@ -1112,7 +1112,7 @@ fn windowsCreateProcessPathExt(
1112 }1112 }
1113 var io_status: windows.IO_STATUS_BLOCK = undefined;1113 var io_status: windows.IO_STATUS_BLOCK = undefined;
11141114
1115 const num_supported_pathext = @typeInfo(WindowsExtension).Enum.fields.len;1115 const num_supported_pathext = @typeInfo(WindowsExtension).@"enum".fields.len;
1116 var pathext_seen = [_]bool{false} ** num_supported_pathext;1116 var pathext_seen = [_]bool{false} ** num_supported_pathext;
1117 var any_pathext_seen = false;1117 var any_pathext_seen = false;
1118 var unappended_exists = false;1118 var unappended_exists = false;
lib/std/segmented_list.zig+1-1
...@@ -99,7 +99,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type...@@ -99,7 +99,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
99 pub const prealloc_count = prealloc_item_count;99 pub const prealloc_count = prealloc_item_count;
100100
101 fn AtType(comptime SelfType: type) type {101 fn AtType(comptime SelfType: type) type {
102 if (@typeInfo(SelfType).Pointer.is_const) {102 if (@typeInfo(SelfType).pointer.is_const) {
103 return *const T;103 return *const T;
104 } else {104 } else {
105 return *T;105 return *T;
lib/std/simd.zig+7-7
...@@ -105,8 +105,8 @@ test "suggestVectorLengthForCpu works with signed and unsigned values" {...@@ -105,8 +105,8 @@ test "suggestVectorLengthForCpu works with signed and unsigned values" {
105105
106fn vectorLength(comptime VectorType: type) comptime_int {106fn vectorLength(comptime VectorType: type) comptime_int {
107 return switch (@typeInfo(VectorType)) {107 return switch (@typeInfo(VectorType)) {
108 .Vector => |info| info.len,108 .vector => |info| info.len,
109 .Array => |info| info.len,109 .array => |info| info.len,
110 else => @compileError("Invalid type " ++ @typeName(VectorType)),110 else => @compileError("Invalid type " ++ @typeName(VectorType)),
111 };111 };
112}112}
...@@ -128,8 +128,8 @@ pub inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T) {...@@ -128,8 +128,8 @@ pub inline fn iota(comptime T: type, comptime len: usize) @Vector(len, T) {
128 var out: [len]T = undefined;128 var out: [len]T = undefined;
129 for (&out, 0..) |*element, i| {129 for (&out, 0..) |*element, i| {
130 element.* = switch (@typeInfo(T)) {130 element.* = switch (@typeInfo(T)) {
131 .Int => @as(T, @intCast(i)),131 .int => @as(T, @intCast(i)),
132 .Float => @as(T, @floatFromInt(i)),132 .float => @as(T, @floatFromInt(i)),
133 else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."),133 else => @compileError("Can't use type " ++ @typeName(T) ++ " in iota."),
134 };134 };
135 }135 }
...@@ -417,18 +417,18 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a...@@ -417,18 +417,18 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a
417 const Child = std.meta.Child(VecType);417 const Child = std.meta.Child(VecType);
418418
419 const identity = comptime switch (@typeInfo(Child)) {419 const identity = comptime switch (@typeInfo(Child)) {
420 .Bool => switch (op) {420 .bool => switch (op) {
421 .Or, .Xor => false,421 .Or, .Xor => false,
422 .And => true,422 .And => true,
423 else => @compileError("Invalid prefixScan operation " ++ @tagName(op) ++ " for vector of booleans."),423 else => @compileError("Invalid prefixScan operation " ++ @tagName(op) ++ " for vector of booleans."),
424 },424 },
425 .Int => switch (op) {425 .int => switch (op) {
426 .Max => std.math.minInt(Child),426 .Max => std.math.minInt(Child),
427 .Add, .Or, .Xor => 0,427 .Add, .Or, .Xor => 0,
428 .Mul => 1,428 .Mul => 1,
429 .And, .Min => std.math.maxInt(Child),429 .And, .Min => std.math.maxInt(Child),
430 },430 },
431 .Float => switch (op) {431 .float => switch (op) {
432 .Max => -std.math.inf(Child),432 .Max => -std.math.inf(Child),
433 .Add => 0,433 .Add => 0,
434 .Mul => 1,434 .Mul => 1,
lib/std/start.zig+6-6
...@@ -30,7 +30,7 @@ comptime {...@@ -30,7 +30,7 @@ comptime {
30 if (simplified_logic) {30 if (simplified_logic) {
31 if (builtin.output_mode == .Exe) {31 if (builtin.output_mode == .Exe) {
32 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {32 if ((builtin.link_libc or builtin.object_format == .c) and @hasDecl(root, "main")) {
33 if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {33 if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) {
34 @export(&main2, .{ .name = "main" });34 @export(&main2, .{ .name = "main" });
35 }35 }
36 } else if (builtin.os.tag == .windows) {36 } else if (builtin.os.tag == .windows) {
...@@ -55,7 +55,7 @@ comptime {...@@ -55,7 +55,7 @@ comptime {
55 if (builtin.link_libc and @hasDecl(root, "main")) {55 if (builtin.link_libc and @hasDecl(root, "main")) {
56 if (native_arch.isWasm()) {56 if (native_arch.isWasm()) {
57 @export(&mainWithoutEnv, .{ .name = "main" });57 @export(&mainWithoutEnv, .{ .name = "main" });
58 } else if (@typeInfo(@TypeOf(root.main)).Fn.calling_convention != .C) {58 } else if (@typeInfo(@TypeOf(root.main)).@"fn".calling_convention != .C) {
59 @export(&main, .{ .name = "main" });59 @export(&main, .{ .name = "main" });
60 }60 }
61 } else if (native_os == .windows) {61 } else if (native_os == .windows) {
...@@ -205,7 +205,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv...@@ -205,7 +205,7 @@ fn EfiMain(handle: uefi.Handle, system_table: *uefi.tables.SystemTable) callconv
205 uefi.handle = handle;205 uefi.handle = handle;
206 uefi.system_table = system_table;206 uefi.system_table = system_table;
207207
208 switch (@typeInfo(@TypeOf(root.main)).Fn.return_type.?) {208 switch (@typeInfo(@TypeOf(root.main)).@"fn".return_type.?) {
209 noreturn => {209 noreturn => {
210 root.main();210 root.main();
211 },211 },
...@@ -599,7 +599,7 @@ fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int {...@@ -599,7 +599,7 @@ fn mainWithoutEnv(c_argc: c_int, c_argv: [*][*:0]c_char) callconv(.C) c_int {
599const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'";599const bad_main_ret = "expected return type of main to be 'void', '!void', 'noreturn', 'u8', or '!u8'";
600600
601pub inline fn callMain() u8 {601pub inline fn callMain() u8 {
602 const ReturnType = @typeInfo(@TypeOf(root.main)).Fn.return_type.?;602 const ReturnType = @typeInfo(@TypeOf(root.main)).@"fn".return_type.?;
603603
604 switch (ReturnType) {604 switch (ReturnType) {
605 void => {605 void => {
...@@ -610,7 +610,7 @@ pub inline fn callMain() u8 {...@@ -610,7 +610,7 @@ pub inline fn callMain() u8 {
610 return root.main();610 return root.main();
611 },611 },
612 else => {612 else => {
613 if (@typeInfo(ReturnType) != .ErrorUnion) @compileError(bad_main_ret);613 if (@typeInfo(ReturnType) != .error_union) @compileError(bad_main_ret);
614614
615 const result = root.main() catch |err| {615 const result = root.main() catch |err| {
616 if (builtin.zig_backend == .stage2_riscv64) {616 if (builtin.zig_backend == .stage2_riscv64) {
...@@ -635,7 +635,7 @@ pub inline fn callMain() u8 {...@@ -635,7 +635,7 @@ pub inline fn callMain() u8 {
635635
636pub fn call_wWinMain() std.os.windows.INT {636pub fn call_wWinMain() std.os.windows.INT {
637 const peb = std.os.windows.peb();637 const peb = std.os.windows.peb();
638 const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?;638 const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).@"fn".params[0].type.?;
639 const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress));639 const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress));
640 const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer);640 const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer);
641641
lib/std/testing.zig+66-66
...@@ -64,33 +64,33 @@ pub inline fn expectEqual(expected: anytype, actual: anytype) !void {...@@ -64,33 +64,33 @@ pub inline fn expectEqual(expected: anytype, actual: anytype) !void {
6464
65fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {65fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
66 switch (@typeInfo(@TypeOf(actual))) {66 switch (@typeInfo(@TypeOf(actual))) {
67 .NoReturn,67 .noreturn,
68 .Opaque,68 .@"opaque",
69 .Frame,69 .frame,
70 .AnyFrame,70 .@"anyframe",
71 => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),71 => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),
7272
73 .Undefined,73 .undefined,
74 .Null,74 .null,
75 .Void,75 .void,
76 => return,76 => return,
7777
78 .Type => {78 .type => {
79 if (actual != expected) {79 if (actual != expected) {
80 print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) });80 print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) });
81 return error.TestExpectedEqual;81 return error.TestExpectedEqual;
82 }82 }
83 },83 },
8484
85 .Bool,85 .bool,
86 .Int,86 .int,
87 .Float,87 .float,
88 .ComptimeFloat,88 .comptime_float,
89 .ComptimeInt,89 .comptime_int,
90 .EnumLiteral,90 .enum_literal,
91 .Enum,91 .@"enum",
92 .Fn,92 .@"fn",
93 .ErrorSet,93 .error_set,
94 => {94 => {
95 if (actual != expected) {95 if (actual != expected) {
96 print("expected {}, found {}\n", .{ expected, actual });96 print("expected {}, found {}\n", .{ expected, actual });
...@@ -98,7 +98,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {...@@ -98,7 +98,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
98 }98 }
99 },99 },
100100
101 .Pointer => |pointer| {101 .pointer => |pointer| {
102 switch (pointer.size) {102 switch (pointer.size) {
103 .One, .Many, .C => {103 .One, .Many, .C => {
104 if (actual != expected) {104 if (actual != expected) {
...@@ -119,9 +119,9 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {...@@ -119,9 +119,9 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
119 }119 }
120 },120 },
121121
122 .Array => |array| try expectEqualSlices(array.child, &expected, &actual),122 .array => |array| try expectEqualSlices(array.child, &expected, &actual),
123123
124 .Vector => |info| {124 .vector => |info| {
125 var i: usize = 0;125 var i: usize = 0;
126 while (i < info.len) : (i += 1) {126 while (i < info.len) : (i += 1) {
127 if (!std.meta.eql(expected[i], actual[i])) {127 if (!std.meta.eql(expected[i], actual[i])) {
...@@ -133,13 +133,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {...@@ -133,13 +133,13 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
133 }133 }
134 },134 },
135135
136 .Struct => |structType| {136 .@"struct" => |structType| {
137 inline for (structType.fields) |field| {137 inline for (structType.fields) |field| {
138 try expectEqual(@field(expected, field.name), @field(actual, field.name));138 try expectEqual(@field(expected, field.name), @field(actual, field.name));
139 }139 }
140 },140 },
141141
142 .Union => |union_info| {142 .@"union" => |union_info| {
143 if (union_info.tag_type == null) {143 if (union_info.tag_type == null) {
144 @compileError("Unable to compare untagged union values");144 @compileError("Unable to compare untagged union values");
145 }145 }
...@@ -157,7 +157,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {...@@ -157,7 +157,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
157 }157 }
158 },158 },
159159
160 .Optional => {160 .optional => {
161 if (expected) |expected_payload| {161 if (expected) |expected_payload| {
162 if (actual) |actual_payload| {162 if (actual) |actual_payload| {
163 try expectEqual(expected_payload, actual_payload);163 try expectEqual(expected_payload, actual_payload);
...@@ -173,7 +173,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {...@@ -173,7 +173,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
173 }173 }
174 },174 },
175175
176 .ErrorUnion => {176 .error_union => {
177 if (expected) |expected_payload| {177 if (expected) |expected_payload| {
178 if (actual) |actual_payload| {178 if (actual) |actual_payload| {
179 try expectEqual(expected_payload, actual_payload);179 try expectEqual(expected_payload, actual_payload);
...@@ -237,12 +237,12 @@ pub inline fn expectApproxEqAbs(expected: anytype, actual: anytype, tolerance: a...@@ -237,12 +237,12 @@ pub inline fn expectApproxEqAbs(expected: anytype, actual: anytype, tolerance: a
237237
238fn expectApproxEqAbsInner(comptime T: type, expected: T, actual: T, tolerance: T) !void {238fn expectApproxEqAbsInner(comptime T: type, expected: T, actual: T, tolerance: T) !void {
239 switch (@typeInfo(T)) {239 switch (@typeInfo(T)) {
240 .Float => if (!math.approxEqAbs(T, expected, actual, tolerance)) {240 .float => if (!math.approxEqAbs(T, expected, actual, tolerance)) {
241 print("actual {}, not within absolute tolerance {} of expected {}\n", .{ actual, tolerance, expected });241 print("actual {}, not within absolute tolerance {} of expected {}\n", .{ actual, tolerance, expected });
242 return error.TestExpectedApproxEqAbs;242 return error.TestExpectedApproxEqAbs;
243 },243 },
244244
245 .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"),245 .comptime_float => @compileError("Cannot approximately compare two comptime_float values"),
246246
247 else => @compileError("Unable to compare non floating point values"),247 else => @compileError("Unable to compare non floating point values"),
248 }248 }
...@@ -273,12 +273,12 @@ pub inline fn expectApproxEqRel(expected: anytype, actual: anytype, tolerance: a...@@ -273,12 +273,12 @@ pub inline fn expectApproxEqRel(expected: anytype, actual: anytype, tolerance: a
273273
274fn expectApproxEqRelInner(comptime T: type, expected: T, actual: T, tolerance: T) !void {274fn expectApproxEqRelInner(comptime T: type, expected: T, actual: T, tolerance: T) !void {
275 switch (@typeInfo(T)) {275 switch (@typeInfo(T)) {
276 .Float => if (!math.approxEqRel(T, expected, actual, tolerance)) {276 .float => if (!math.approxEqRel(T, expected, actual, tolerance)) {
277 print("actual {}, not within relative tolerance {} of expected {}\n", .{ actual, tolerance, expected });277 print("actual {}, not within relative tolerance {} of expected {}\n", .{ actual, tolerance, expected });
278 return error.TestExpectedApproxEqRel;278 return error.TestExpectedApproxEqRel;
279 },279 },
280280
281 .ComptimeFloat => @compileError("Cannot approximately compare two comptime_float values"),281 .comptime_float => @compileError("Cannot approximately compare two comptime_float values"),
282282
283 else => @compileError("Unable to compare non floating point values"),283 else => @compileError("Unable to compare non floating point values"),
284 }284 }
...@@ -415,7 +415,7 @@ fn SliceDiffer(comptime T: type) type {...@@ -415,7 +415,7 @@ fn SliceDiffer(comptime T: type) type {
415 const full_index = self.start_index + i;415 const full_index = self.start_index + i;
416 const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true;416 const diff = if (i < self.actual.len) !std.meta.eql(self.actual[i], value) else true;
417 if (diff) try self.ttyconf.setColor(writer, .red);417 if (diff) try self.ttyconf.setColor(writer, .red);
418 if (@typeInfo(T) == .Pointer) {418 if (@typeInfo(T) == .pointer) {
419 try writer.print("[{}]{*}: {any}\n", .{ full_index, value, value });419 try writer.print("[{}]{*}: {any}\n", .{ full_index, value, value });
420 } else {420 } else {
421 try writer.print("[{}]: {any}\n", .{ full_index, value });421 try writer.print("[{}]: {any}\n", .{ full_index, value });
...@@ -505,10 +505,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s...@@ -505,10 +505,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s
505505
506 const expected_value_sentinel = blk: {506 const expected_value_sentinel = blk: {
507 switch (@typeInfo(@TypeOf(expected))) {507 switch (@typeInfo(@TypeOf(expected))) {
508 .Pointer => {508 .pointer => {
509 break :blk expected[expected.len];509 break :blk expected[expected.len];
510 },510 },
511 .Array => |array_info| {511 .array => |array_info| {
512 const indexable_outside_of_bounds = @as([]const array_info.child, &expected);512 const indexable_outside_of_bounds = @as([]const array_info.child, &expected);
513 break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len];513 break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len];
514 },514 },
...@@ -518,10 +518,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s...@@ -518,10 +518,10 @@ pub fn expectEqualSentinel(comptime T: type, comptime sentinel: T, expected: [:s
518518
519 const actual_value_sentinel = blk: {519 const actual_value_sentinel = blk: {
520 switch (@typeInfo(@TypeOf(actual))) {520 switch (@typeInfo(@TypeOf(actual))) {
521 .Pointer => {521 .pointer => {
522 break :blk actual[actual.len];522 break :blk actual[actual.len];
523 },523 },
524 .Array => |array_info| {524 .array => |array_info| {
525 const indexable_outside_of_bounds = @as([]const array_info.child, &actual);525 const indexable_outside_of_bounds = @as([]const array_info.child, &actual);
526 break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len];526 break :blk indexable_outside_of_bounds[indexable_outside_of_bounds.len];
527 },527 },
...@@ -689,33 +689,33 @@ pub inline fn expectEqualDeep(expected: anytype, actual: anytype) error{TestExpe...@@ -689,33 +689,33 @@ pub inline fn expectEqualDeep(expected: anytype, actual: anytype) error{TestExpe
689689
690fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpectedEqual}!void {690fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpectedEqual}!void {
691 switch (@typeInfo(@TypeOf(actual))) {691 switch (@typeInfo(@TypeOf(actual))) {
692 .NoReturn,692 .noreturn,
693 .Opaque,693 .@"opaque",
694 .Frame,694 .frame,
695 .AnyFrame,695 .@"anyframe",
696 => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),696 => @compileError("value of type " ++ @typeName(@TypeOf(actual)) ++ " encountered"),
697697
698 .Undefined,698 .undefined,
699 .Null,699 .null,
700 .Void,700 .void,
701 => return,701 => return,
702702
703 .Type => {703 .type => {
704 if (actual != expected) {704 if (actual != expected) {
705 print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) });705 print("expected type {s}, found type {s}\n", .{ @typeName(expected), @typeName(actual) });
706 return error.TestExpectedEqual;706 return error.TestExpectedEqual;
707 }707 }
708 },708 },
709709
710 .Bool,710 .bool,
711 .Int,711 .int,
712 .Float,712 .float,
713 .ComptimeFloat,713 .comptime_float,
714 .ComptimeInt,714 .comptime_int,
715 .EnumLiteral,715 .enum_literal,
716 .Enum,716 .@"enum",
717 .Fn,717 .@"fn",
718 .ErrorSet,718 .error_set,
719 => {719 => {
720 if (actual != expected) {720 if (actual != expected) {
721 print("expected {}, found {}\n", .{ expected, actual });721 print("expected {}, found {}\n", .{ expected, actual });
...@@ -723,7 +723,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -723,7 +723,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
723 }723 }
724 },724 },
725725
726 .Pointer => |pointer| {726 .pointer => |pointer| {
727 switch (pointer.size) {727 switch (pointer.size) {
728 // We have no idea what is behind those pointers, so the best we can do is `==` check.728 // We have no idea what is behind those pointers, so the best we can do is `==` check.
729 .C, .Many => {729 .C, .Many => {
...@@ -735,7 +735,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -735,7 +735,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
735 .One => {735 .One => {
736 // Length of those pointers are runtime value, so the best we can do is `==` check.736 // Length of those pointers are runtime value, so the best we can do is `==` check.
737 switch (@typeInfo(pointer.child)) {737 switch (@typeInfo(pointer.child)) {
738 .Fn, .Opaque => {738 .@"fn", .@"opaque" => {
739 if (actual != expected) {739 if (actual != expected) {
740 print("expected {*}, found {*}\n", .{ expected, actual });740 print("expected {*}, found {*}\n", .{ expected, actual });
741 return error.TestExpectedEqual;741 return error.TestExpectedEqual;
...@@ -762,7 +762,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -762,7 +762,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
762 }762 }
763 },763 },
764764
765 .Array => |_| {765 .array => |_| {
766 if (expected.len != actual.len) {766 if (expected.len != actual.len) {
767 print("Array len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });767 print("Array len not the same, expected {d}, found {d}\n", .{ expected.len, actual.len });
768 return error.TestExpectedEqual;768 return error.TestExpectedEqual;
...@@ -778,9 +778,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -778,9 +778,9 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
778 }778 }
779 },779 },
780780
781 .Vector => |info| {781 .vector => |info| {
782 if (info.len != @typeInfo(@TypeOf(actual)).Vector.len) {782 if (info.len != @typeInfo(@TypeOf(actual)).vector.len) {
783 print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).Vector.len });783 print("Vector len not the same, expected {d}, found {d}\n", .{ info.len, @typeInfo(@TypeOf(actual)).vector.len });
784 return error.TestExpectedEqual;784 return error.TestExpectedEqual;
785 }785 }
786 var i: usize = 0;786 var i: usize = 0;
...@@ -794,7 +794,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -794,7 +794,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
794 }794 }
795 },795 },
796796
797 .Struct => |structType| {797 .@"struct" => |structType| {
798 inline for (structType.fields) |field| {798 inline for (structType.fields) |field| {
799 expectEqualDeep(@field(expected, field.name), @field(actual, field.name)) catch |e| {799 expectEqualDeep(@field(expected, field.name), @field(actual, field.name)) catch |e| {
800 print("Field {s} incorrect. expected {any}, found {any}\n", .{ field.name, @field(expected, field.name), @field(actual, field.name) });800 print("Field {s} incorrect. expected {any}, found {any}\n", .{ field.name, @field(expected, field.name), @field(actual, field.name) });
...@@ -803,7 +803,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -803,7 +803,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
803 }803 }
804 },804 },
805805
806 .Union => |union_info| {806 .@"union" => |union_info| {
807 if (union_info.tag_type == null) {807 if (union_info.tag_type == null) {
808 @compileError("Unable to compare untagged union values");808 @compileError("Unable to compare untagged union values");
809 }809 }
...@@ -823,7 +823,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -823,7 +823,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
823 }823 }
824 },824 },
825825
826 .Optional => {826 .optional => {
827 if (expected) |expected_payload| {827 if (expected) |expected_payload| {
828 if (actual) |actual_payload| {828 if (actual) |actual_payload| {
829 try expectEqualDeep(expected_payload, actual_payload);829 try expectEqualDeep(expected_payload, actual_payload);
...@@ -839,7 +839,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe...@@ -839,7 +839,7 @@ fn expectEqualDeepInner(comptime T: type, expected: T, actual: T) error{TestExpe
839 }839 }
840 },840 },
841841
842 .ErrorUnion => {842 .error_union => {
843 if (expected) |expected_payload| {843 if (expected) |expected_payload| {
844 if (actual) |actual_payload| {844 if (actual) |actual_payload| {
845 try expectEqualDeep(expected_payload, actual_payload);845 try expectEqualDeep(expected_payload, actual_payload);
...@@ -1036,20 +1036,20 @@ test {...@@ -1036,20 +1036,20 @@ test {
1036/// }1036/// }
1037/// ```1037/// ```
1038pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime test_fn: anytype, extra_args: anytype) !void {1038pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime test_fn: anytype, extra_args: anytype) !void {
1039 switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).Fn.return_type.?)) {1039 switch (@typeInfo(@typeInfo(@TypeOf(test_fn)).@"fn".return_type.?)) {
1040 .ErrorUnion => |info| {1040 .error_union => |info| {
1041 if (info.payload != void) {1041 if (info.payload != void) {
1042 @compileError("Return type must be !void");1042 @compileError("Return type must be !void");
1043 }1043 }
1044 },1044 },
1045 else => @compileError("Return type must be !void"),1045 else => @compileError("Return type must be !void"),
1046 }1046 }
1047 if (@typeInfo(@TypeOf(extra_args)) != .Struct) {1047 if (@typeInfo(@TypeOf(extra_args)) != .@"struct") {
1048 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(extra_args)));1048 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(extra_args)));
1049 }1049 }
10501050
1051 const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn));1051 const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn));
1052 const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields;1052 const fn_args_fields = @typeInfo(ArgsTuple).@"struct".fields;
1053 if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) {1053 if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) {
1054 @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");1054 @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");
1055 }1055 }
...@@ -1061,7 +1061,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime...@@ -1061,7 +1061,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
1061 // Setup the tuple that will actually be used with @call (we'll need to insert1061 // Setup the tuple that will actually be used with @call (we'll need to insert
1062 // the failing allocator in field @"0" before each @call)1062 // the failing allocator in field @"0" before each @call)
1063 var args: ArgsTuple = undefined;1063 var args: ArgsTuple = undefined;
1064 inline for (@typeInfo(@TypeOf(extra_args)).Struct.fields, 0..) |field, i| {1064 inline for (@typeInfo(@TypeOf(extra_args)).@"struct".fields, 0..) |field, i| {
1065 const arg_i_str = comptime str: {1065 const arg_i_str = comptime str: {
1066 var str_buf: [100]u8 = undefined;1066 var str_buf: [100]u8 = undefined;
1067 const args_i = i + 1;1067 const args_i = i + 1;
...@@ -1129,7 +1129,7 @@ pub fn refAllDeclsRecursive(comptime T: type) void {...@@ -1129,7 +1129,7 @@ pub fn refAllDeclsRecursive(comptime T: type) void {
1129 inline for (comptime std.meta.declarations(T)) |decl| {1129 inline for (comptime std.meta.declarations(T)) |decl| {
1130 if (@TypeOf(@field(T, decl.name)) == type) {1130 if (@TypeOf(@field(T, decl.name)) == type) {
1131 switch (@typeInfo(@field(T, decl.name))) {1131 switch (@typeInfo(@field(T, decl.name))) {
1132 .Struct, .Enum, .Union, .Opaque => refAllDeclsRecursive(@field(T, decl.name)),1132 .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)),
1133 else => {},1133 else => {},
1134 }1134 }
1135 }1135 }
lib/std/zig.zig+2-2
...@@ -246,7 +246,7 @@ pub const BuildId = union(enum) {...@@ -246,7 +246,7 @@ pub const BuildId = union(enum) {
246 hexstring: HexString,246 hexstring: HexString,
247247
248 pub fn eql(a: BuildId, b: BuildId) bool {248 pub fn eql(a: BuildId, b: BuildId) bool {
249 const Tag = @typeInfo(BuildId).Union.tag_type.?;249 const Tag = @typeInfo(BuildId).@"union".tag_type.?;
250 const a_tag: Tag = a;250 const a_tag: Tag = a;
251 const b_tag: Tag = b;251 const b_tag: Tag = b;
252 if (a_tag != b_tag) return false;252 if (a_tag != b_tag) return false;
...@@ -654,7 +654,7 @@ pub fn parseTargetQueryOrReportFatalError(...@@ -654,7 +654,7 @@ pub fn parseTargetQueryOrReportFatalError(
654 help: {654 help: {
655 var help_text = std.ArrayList(u8).init(allocator);655 var help_text = std.ArrayList(u8).init(allocator);
656 defer help_text.deinit();656 defer help_text.deinit();
657 inline for (@typeInfo(std.Target.ObjectFormat).Enum.fields) |field| {657 inline for (@typeInfo(std.Target.ObjectFormat).@"enum".fields) |field| {
658 help_text.writer().print(" {s}\n", .{field.name}) catch break :help;658 help_text.writer().print(" {s}\n", .{field.name}) catch break :help;
659 }659 }
660 std.log.info("available object formats:\n{s}", .{help_text.items});660 std.log.info("available object formats:\n{s}", .{help_text.items});
lib/std/zig/AstGen.zig+39-39
...@@ -153,7 +153,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {...@@ -153,7 +153,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
153 try astgen.instructions.ensureTotalCapacity(gpa, tree.nodes.len);153 try astgen.instructions.ensureTotalCapacity(gpa, tree.nodes.len);
154154
155 // First few indexes of extra are reserved and set at the end.155 // First few indexes of extra are reserved and set at the end.
156 const reserved_count = @typeInfo(Zir.ExtraIndex).Enum.fields.len;156 const reserved_count = @typeInfo(Zir.ExtraIndex).@"enum".fields.len;
157 try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count);157 try astgen.extra.ensureTotalCapacity(gpa, tree.nodes.len + reserved_count);
158 astgen.extra.items.len += reserved_count;158 astgen.extra.items.len += reserved_count;
159159
...@@ -197,7 +197,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {...@@ -197,7 +197,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
197 astgen.extra.items[err_index] = 0;197 astgen.extra.items[err_index] = 0;
198 } else {198 } else {
199 try astgen.extra.ensureUnusedCapacity(gpa, 1 + astgen.compile_errors.items.len *199 try astgen.extra.ensureUnusedCapacity(gpa, 1 + astgen.compile_errors.items.len *
200 @typeInfo(Zir.Inst.CompileErrors.Item).Struct.fields.len);200 @typeInfo(Zir.Inst.CompileErrors.Item).@"struct".fields.len);
201201
202 astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{202 astgen.extra.items[err_index] = astgen.addExtraAssumeCapacity(Zir.Inst.CompileErrors{
203 .items_len = @intCast(astgen.compile_errors.items.len),203 .items_len = @intCast(astgen.compile_errors.items.len),
...@@ -212,8 +212,8 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {...@@ -212,8 +212,8 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
212 if (astgen.imports.count() == 0) {212 if (astgen.imports.count() == 0) {
213 astgen.extra.items[imports_index] = 0;213 astgen.extra.items[imports_index] = 0;
214 } else {214 } else {
215 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).Struct.fields.len +215 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Imports).@"struct".fields.len +
216 astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).Struct.fields.len);216 astgen.imports.count() * @typeInfo(Zir.Inst.Imports.Item).@"struct".fields.len);
217217
218 astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{218 astgen.extra.items[imports_index] = astgen.addExtraAssumeCapacity(Zir.Inst.Imports{
219 .imports_len = @intCast(astgen.imports.count()),219 .imports_len = @intCast(astgen.imports.count()),
...@@ -1885,7 +1885,7 @@ fn structInitExprAnon(...@@ -1885,7 +1885,7 @@ fn structInitExprAnon(
1885 const payload_index = try addExtra(astgen, Zir.Inst.StructInitAnon{1885 const payload_index = try addExtra(astgen, Zir.Inst.StructInitAnon{
1886 .fields_len = @intCast(struct_init.ast.fields.len),1886 .fields_len = @intCast(struct_init.ast.fields.len),
1887 });1887 });
1888 const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).Struct.fields.len;1888 const field_size = @typeInfo(Zir.Inst.StructInitAnon.Item).@"struct".fields.len;
1889 var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);1889 var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
18901890
1891 for (struct_init.ast.fields) |field_init| {1891 for (struct_init.ast.fields) |field_init| {
...@@ -1916,7 +1916,7 @@ fn structInitExprTyped(...@@ -1916,7 +1916,7 @@ fn structInitExprTyped(
1916 const payload_index = try addExtra(astgen, Zir.Inst.StructInit{1916 const payload_index = try addExtra(astgen, Zir.Inst.StructInit{
1917 .fields_len = @intCast(struct_init.ast.fields.len),1917 .fields_len = @intCast(struct_init.ast.fields.len),
1918 });1918 });
1919 const field_size = @typeInfo(Zir.Inst.StructInit.Item).Struct.fields.len;1919 const field_size = @typeInfo(Zir.Inst.StructInit.Item).@"struct".fields.len;
1920 var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);1920 var extra_index: usize = try reserveExtra(astgen, struct_init.ast.fields.len * field_size);
19211921
1922 for (struct_init.ast.fields) |field_init| {1922 for (struct_init.ast.fields) |field_init| {
...@@ -2464,7 +2464,7 @@ fn labeledBlockExpr(...@@ -2464,7 +2464,7 @@ fn labeledBlockExpr(
2464 };2464 };
2465 // We need to call `rvalue` to write through to the pointer only if we had a2465 // We need to call `rvalue` to write through to the pointer only if we had a
2466 // result pointer and aren't forwarding it.2466 // result pointer and aren't forwarding it.
2467 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;2467 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
2468 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);2468 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
24692469
2470 // Reserve the Block ZIR instruction index so that we can put it into the GenZir struct2470 // Reserve the Block ZIR instruction index so that we can put it into the GenZir struct
...@@ -3864,7 +3864,7 @@ fn ptrType(...@@ -3864,7 +3864,7 @@ fn ptrType(
3864 const gpa = gz.astgen.gpa;3864 const gpa = gz.astgen.gpa;
3865 try gz.instructions.ensureUnusedCapacity(gpa, 1);3865 try gz.instructions.ensureUnusedCapacity(gpa, 1);
3866 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);3866 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
3867 try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).Struct.fields.len +3867 try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.PtrType).@"struct".fields.len +
3868 trailing_count);3868 trailing_count);
38693869
3870 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.PtrType{3870 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.PtrType{
...@@ -5939,7 +5939,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi...@@ -5939,7 +5939,7 @@ fn errorSetDecl(gz: *GenZir, ri: ResultInfo, node: Ast.Node.Index) InnerError!Zi
5939 const main_tokens = tree.nodes.items(.main_token);5939 const main_tokens = tree.nodes.items(.main_token);
5940 const token_tags = tree.tokens.items(.tag);5940 const token_tags = tree.tokens.items(.tag);
59415941
5942 const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).Struct.fields.len);5942 const payload_index = try reserveExtra(astgen, @typeInfo(Zir.Inst.ErrorSetDecl).@"struct".fields.len);
5943 var fields_len: usize = 0;5943 var fields_len: usize = 0;
5944 {5944 {
5945 var idents: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.TokenIndex) = .{};5945 var idents: std.AutoHashMapUnmanaged(Zir.NullTerminatedString, Ast.TokenIndex) = .{};
...@@ -6078,7 +6078,7 @@ fn orelseCatchExpr(...@@ -6078,7 +6078,7 @@ fn orelseCatchExpr(
6078 };6078 };
6079 // We need to call `rvalue` to write through to the pointer only if we had a6079 // We need to call `rvalue` to write through to the pointer only if we had a
6080 // result pointer and aren't forwarding it.6080 // result pointer and aren't forwarding it.
6081 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;6081 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
6082 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);6082 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
60836083
6084 const do_err_trace = astgen.fn_block != null and (cond_op == .is_non_err or cond_op == .is_non_err_ptr);6084 const do_err_trace = astgen.fn_block != null and (cond_op == .is_non_err or cond_op == .is_non_err_ptr);
...@@ -6347,7 +6347,7 @@ fn ifExpr(...@@ -6347,7 +6347,7 @@ fn ifExpr(
6347 };6347 };
6348 // We need to call `rvalue` to write through to the pointer only if we had a6348 // We need to call `rvalue` to write through to the pointer only if we had a
6349 // result pointer and aren't forwarding it.6349 // result pointer and aren't forwarding it.
6350 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;6350 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
6351 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);6351 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
63526352
6353 var block_scope = parent_gz.makeSubBlock(scope);6353 var block_scope = parent_gz.makeSubBlock(scope);
...@@ -6537,7 +6537,7 @@ fn setCondBrPayload(...@@ -6537,7 +6537,7 @@ fn setCondBrPayload(
6537 const else_body_len = astgen.countBodyLenAfterFixups(else_body);6537 const else_body_len = astgen.countBodyLenAfterFixups(else_body);
6538 try astgen.extra.ensureUnusedCapacity(6538 try astgen.extra.ensureUnusedCapacity(
6539 astgen.gpa,6539 astgen.gpa,
6540 @typeInfo(Zir.Inst.CondBr).Struct.fields.len + then_body_len + else_body_len,6540 @typeInfo(Zir.Inst.CondBr).@"struct".fields.len + then_body_len + else_body_len,
6541 );6541 );
65426542
6543 const zir_datas = astgen.instructions.items(.data);6543 const zir_datas = astgen.instructions.items(.data);
...@@ -6573,7 +6573,7 @@ fn whileExpr(...@@ -6573,7 +6573,7 @@ fn whileExpr(
6573 };6573 };
6574 // We need to call `rvalue` to write through to the pointer only if we had a6574 // We need to call `rvalue` to write through to the pointer only if we had a
6575 // result pointer and aren't forwarding it.6575 // result pointer and aren't forwarding it.
6576 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;6576 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
6577 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);6577 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
65786578
6579 if (while_full.label_token) |label_token| {6579 if (while_full.label_token) |label_token| {
...@@ -6853,7 +6853,7 @@ fn forExpr(...@@ -6853,7 +6853,7 @@ fn forExpr(
6853 };6853 };
6854 // We need to call `rvalue` to write through to the pointer only if we had a6854 // We need to call `rvalue` to write through to the pointer only if we had a
6855 // result pointer and aren't forwarding it.6855 // result pointer and aren't forwarding it.
6856 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;6856 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
6857 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);6857 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
68586858
6859 const is_inline = for_full.inline_token != null;6859 const is_inline = for_full.inline_token != null;
...@@ -6951,7 +6951,7 @@ fn forExpr(...@@ -6951,7 +6951,7 @@ fn forExpr(
6951 // nicer error reporting as well as fewer ZIR bytes emitted.6951 // nicer error reporting as well as fewer ZIR bytes emitted.
6952 const len: Zir.Inst.Ref = len: {6952 const len: Zir.Inst.Ref = len: {
6953 const lens_len: u32 = @intCast(lens.len);6953 const lens_len: u32 = @intCast(lens.len);
6954 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).Struct.fields.len + lens_len);6954 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.MultiOp).@"struct".fields.len + lens_len);
6955 const len = try parent_gz.addPlNode(.for_len, node, Zir.Inst.MultiOp{6955 const len = try parent_gz.addPlNode(.for_len, node, Zir.Inst.MultiOp{
6956 .operands_len = lens_len,6956 .operands_len = lens_len,
6957 });6957 });
...@@ -7188,7 +7188,7 @@ fn switchExprErrUnion(...@@ -7188,7 +7188,7 @@ fn switchExprErrUnion(
71887188
7189 // We need to call `rvalue` to write through to the pointer only if we had a7189 // We need to call `rvalue` to write through to the pointer only if we had a
7190 // result pointer and aren't forwarding it.7190 // result pointer and aren't forwarding it.
7191 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;7191 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
7192 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);7192 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
7193 var scalar_cases_len: u32 = 0;7193 var scalar_cases_len: u32 = 0;
7194 var multi_cases_len: u32 = 0;7194 var multi_cases_len: u32 = 0;
...@@ -7622,10 +7622,10 @@ fn switchExprErrUnion(...@@ -7622,10 +7622,10 @@ fn switchExprErrUnion(
7622 // Now that the item expressions are generated we can add this.7622 // Now that the item expressions are generated we can add this.
7623 try parent_gz.instructions.append(gpa, switch_block);7623 try parent_gz.instructions.append(gpa, switch_block);
76247624
7625 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).Struct.fields.len +7625 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlockErrUnion).@"struct".fields.len +
7626 @intFromBool(multi_cases_len != 0) +7626 @intFromBool(multi_cases_len != 0) +
7627 payloads.items.len - case_table_end +7627 payloads.items.len - case_table_end +
7628 (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len);7628 (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len);
76297629
7630 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlockErrUnion{7630 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlockErrUnion{
7631 .operand = raw_operand,7631 .operand = raw_operand,
...@@ -7705,7 +7705,7 @@ fn switchExpr(...@@ -7705,7 +7705,7 @@ fn switchExpr(
7705 };7705 };
7706 // We need to call `rvalue` to write through to the pointer only if we had a7706 // We need to call `rvalue` to write through to the pointer only if we had a
7707 // result pointer and aren't forwarding it.7707 // result pointer and aren't forwarding it.
7708 const LocTag = @typeInfo(ResultInfo.Loc).Union.tag_type.?;7708 const LocTag = @typeInfo(ResultInfo.Loc).@"union".tag_type.?;
7709 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);7709 const need_result_rvalue = @as(LocTag, block_ri.rl) != @as(LocTag, ri.rl);
77107710
7711 // We perform two passes over the AST. This first pass is to collect information7711 // We perform two passes over the AST. This first pass is to collect information
...@@ -8068,11 +8068,11 @@ fn switchExpr(...@@ -8068,11 +8068,11 @@ fn switchExpr(
8068 // Now that the item expressions are generated we can add this.8068 // Now that the item expressions are generated we can add this.
8069 try parent_gz.instructions.append(gpa, switch_block);8069 try parent_gz.instructions.append(gpa, switch_block);
80708070
8071 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).Struct.fields.len +8071 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.SwitchBlock).@"struct".fields.len +
8072 @intFromBool(multi_cases_len != 0) +8072 @intFromBool(multi_cases_len != 0) +
8073 @intFromBool(any_has_tag_capture) +8073 @intFromBool(any_has_tag_capture) +
8074 payloads.items.len - case_table_end +8074 payloads.items.len - case_table_end +
8075 (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).Struct.fields.len);8075 (case_table_end - case_table_start) * @typeInfo(Zir.Inst.As).@"struct".fields.len);
80768076
8077 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{8077 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.SwitchBlock{
8078 .operand = raw_operand,8078 .operand = raw_operand,
...@@ -8971,7 +8971,7 @@ fn ptrCast(...@@ -8971,7 +8971,7 @@ fn ptrCast(
8971 const node_datas = tree.nodes.items(.data);8971 const node_datas = tree.nodes.items(.data);
8972 const node_tags = tree.nodes.items(.tag);8972 const node_tags = tree.nodes.items(.tag);
89738973
8974 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;8974 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
8975 var flags: Zir.Inst.FullPtrCastFlags = .{};8975 var flags: Zir.Inst.FullPtrCastFlags = .{};
89768976
8977 // Note that all pointer cast builtins have one parameter, so we only need8977 // Note that all pointer cast builtins have one parameter, so we only need
...@@ -12080,7 +12080,7 @@ const GenZir = struct {...@@ -12080,7 +12080,7 @@ const GenZir = struct {
12080 const body_len = astgen.countBodyLenAfterFixups(body);12080 const body_len = astgen.countBodyLenAfterFixups(body);
12081 try astgen.extra.ensureUnusedCapacity(12081 try astgen.extra.ensureUnusedCapacity(
12082 gpa,12082 gpa,
12083 @typeInfo(Zir.Inst.BoolBr).Struct.fields.len + body_len,12083 @typeInfo(Zir.Inst.BoolBr).@"struct".fields.len + body_len,
12084 );12084 );
12085 const zir_datas = astgen.instructions.items(.data);12085 const zir_datas = astgen.instructions.items(.data);
12086 zir_datas[@intFromEnum(bool_br)].pl_node.payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.BoolBr{12086 zir_datas[@intFromEnum(bool_br)].pl_node.payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.BoolBr{
...@@ -12099,7 +12099,7 @@ const GenZir = struct {...@@ -12099,7 +12099,7 @@ const GenZir = struct {
12099 const body_len = astgen.countBodyLenAfterFixups(body);12099 const body_len = astgen.countBodyLenAfterFixups(body);
12100 try astgen.extra.ensureUnusedCapacity(12100 try astgen.extra.ensureUnusedCapacity(
12101 gpa,12101 gpa,
12102 @typeInfo(Zir.Inst.Block).Struct.fields.len + body_len,12102 @typeInfo(Zir.Inst.Block).@"struct".fields.len + body_len,
12103 );12103 );
12104 const zir_datas = astgen.instructions.items(.data);12104 const zir_datas = astgen.instructions.items(.data);
12105 zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(12105 zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
...@@ -12117,7 +12117,7 @@ const GenZir = struct {...@@ -12117,7 +12117,7 @@ const GenZir = struct {
12117 const body_len = astgen.countBodyLenAfterFixups(body);12117 const body_len = astgen.countBodyLenAfterFixups(body);
12118 try astgen.extra.ensureUnusedCapacity(12118 try astgen.extra.ensureUnusedCapacity(
12119 gpa,12119 gpa,
12120 @typeInfo(Zir.Inst.Try).Struct.fields.len + body_len,12120 @typeInfo(Zir.Inst.Try).@"struct".fields.len + body_len,
12121 );12121 );
12122 const zir_datas = astgen.instructions.items(.data);12122 const zir_datas = astgen.instructions.items(.data);
12123 zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(12123 zir_datas[@intFromEnum(inst)].pl_node.payload_index = astgen.addExtraAssumeCapacity(
...@@ -12235,7 +12235,7 @@ const GenZir = struct {...@@ -12235,7 +12235,7 @@ const GenZir = struct {
1223512235
12236 try astgen.extra.ensureUnusedCapacity(12236 try astgen.extra.ensureUnusedCapacity(
12237 gpa,12237 gpa,
12238 @typeInfo(Zir.Inst.FuncFancy).Struct.fields.len +12238 @typeInfo(Zir.Inst.FuncFancy).@"struct".fields.len +
12239 fancyFnExprExtraLen(astgen, align_body, args.align_ref) +12239 fancyFnExprExtraLen(astgen, align_body, args.align_ref) +
12240 fancyFnExprExtraLen(astgen, addrspace_body, args.addrspace_ref) +12240 fancyFnExprExtraLen(astgen, addrspace_body, args.addrspace_ref) +
12241 fancyFnExprExtraLen(astgen, section_body, args.section_ref) +12241 fancyFnExprExtraLen(astgen, section_body, args.section_ref) +
...@@ -12354,7 +12354,7 @@ const GenZir = struct {...@@ -12354,7 +12354,7 @@ const GenZir = struct {
12354 } else {12354 } else {
12355 try astgen.extra.ensureUnusedCapacity(12355 try astgen.extra.ensureUnusedCapacity(
12356 gpa,12356 gpa,
12357 @typeInfo(Zir.Inst.Func).Struct.fields.len + 1 +12357 @typeInfo(Zir.Inst.Func).@"struct".fields.len + 1 +
12358 fancyFnExprExtraLen(astgen, ret_body, ret_ref) +12358 fancyFnExprExtraLen(astgen, ret_body, ret_ref) +
12359 body_len + src_locs_and_hash.len,12359 body_len + src_locs_and_hash.len,
12360 );12360 );
...@@ -12428,7 +12428,7 @@ const GenZir = struct {...@@ -12428,7 +12428,7 @@ const GenZir = struct {
1242812428
12429 try astgen.extra.ensureUnusedCapacity(12429 try astgen.extra.ensureUnusedCapacity(
12430 gpa,12430 gpa,
12431 @typeInfo(Zir.Inst.ExtendedVar).Struct.fields.len +12431 @typeInfo(Zir.Inst.ExtendedVar).@"struct".fields.len +
12432 @intFromBool(args.lib_name != .empty) +12432 @intFromBool(args.lib_name != .empty) +
12433 @intFromBool(args.align_inst != .none) +12433 @intFromBool(args.align_inst != .none) +
12434 @intFromBool(args.init != .none),12434 @intFromBool(args.init != .none),
...@@ -12590,7 +12590,7 @@ const GenZir = struct {...@@ -12590,7 +12590,7 @@ const GenZir = struct {
12590 const param_body = param_gz.instructionsSlice();12590 const param_body = param_gz.instructionsSlice();
12591 const body_len = gz.astgen.countBodyLenAfterFixups(param_body);12591 const body_len = gz.astgen.countBodyLenAfterFixups(param_body);
12592 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);12592 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
12593 try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).Struct.fields.len + body_len);12593 try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Param).@"struct".fields.len + body_len);
1259412594
12595 const doc_comment_index = if (first_doc_comment) |first|12595 const doc_comment_index = if (first_doc_comment) |first|
12596 try gz.astgen.docCommentAsStringFromFirst(abs_tok_index, first)12596 try gz.astgen.docCommentAsStringFromFirst(abs_tok_index, first)
...@@ -12663,7 +12663,7 @@ const GenZir = struct {...@@ -12663,7 +12663,7 @@ const GenZir = struct {
12663 try astgen.instructions.ensureUnusedCapacity(gpa, 1);12663 try astgen.instructions.ensureUnusedCapacity(gpa, 1);
12664 try astgen.extra.ensureUnusedCapacity(12664 try astgen.extra.ensureUnusedCapacity(
12665 gpa,12665 gpa,
12666 @typeInfo(Zir.Inst.NodeMultiOp).Struct.fields.len + operands.len,12666 @typeInfo(Zir.Inst.NodeMultiOp).@"struct".fields.len + operands.len,
12667 );12667 );
1266812668
12669 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{12669 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.NodeMultiOp{
...@@ -12904,7 +12904,7 @@ const GenZir = struct {...@@ -12904,7 +12904,7 @@ const GenZir = struct {
12904 ) !Zir.Inst.Index {12904 ) !Zir.Inst.Index {
12905 const gpa = gz.astgen.gpa;12905 const gpa = gz.astgen.gpa;
12906 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);12906 try gz.astgen.instructions.ensureUnusedCapacity(gpa, 1);
12907 try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).Struct.fields.len);12907 try gz.astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Break).@"struct".fields.len);
1290812908
12909 const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len);12909 const new_index: Zir.Inst.Index = @enumFromInt(gz.astgen.instructions.len);
12910 gz.astgen.instructions.appendAssumeCapacity(.{12910 gz.astgen.instructions.appendAssumeCapacity(.{
...@@ -13027,7 +13027,7 @@ const GenZir = struct {...@@ -13027,7 +13027,7 @@ const GenZir = struct {
13027 try astgen.instructions.ensureUnusedCapacity(gpa, 1);13027 try astgen.instructions.ensureUnusedCapacity(gpa, 1);
13028 try astgen.extra.ensureUnusedCapacity(13028 try astgen.extra.ensureUnusedCapacity(
13029 gpa,13029 gpa,
13030 @typeInfo(Zir.Inst.AllocExtended).Struct.fields.len +13030 @typeInfo(Zir.Inst.AllocExtended).@"struct".fields.len +
13031 @intFromBool(args.type_inst != .none) +13031 @intFromBool(args.type_inst != .none) +
13032 @intFromBool(args.align_inst != .none),13032 @intFromBool(args.align_inst != .none),
13033 );13033 );
...@@ -13079,9 +13079,9 @@ const GenZir = struct {...@@ -13079,9 +13079,9 @@ const GenZir = struct {
1307913079
13080 try gz.instructions.ensureUnusedCapacity(gpa, 1);13080 try gz.instructions.ensureUnusedCapacity(gpa, 1);
13081 try astgen.instructions.ensureUnusedCapacity(gpa, 1);13081 try astgen.instructions.ensureUnusedCapacity(gpa, 1);
13082 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).Struct.fields.len +13082 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.Asm).@"struct".fields.len +
13083 args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).Struct.fields.len +13083 args.outputs.len * @typeInfo(Zir.Inst.Asm.Output).@"struct".fields.len +
13084 args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).Struct.fields.len +13084 args.inputs.len * @typeInfo(Zir.Inst.Asm.Input).@"struct".fields.len +
13085 args.clobbers.len);13085 args.clobbers.len);
1308613086
13087 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{13087 const payload_index = gz.astgen.addExtraAssumeCapacity(Zir.Inst.Asm{
...@@ -13190,7 +13190,7 @@ const GenZir = struct {...@@ -13190,7 +13190,7 @@ const GenZir = struct {
1319013190
13191 const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);13191 const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
1319213192
13193 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).Struct.fields.len + 3);13193 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len + 3);
13194 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.StructDecl{13194 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.StructDecl{
13195 .fields_hash_0 = fields_hash_arr[0],13195 .fields_hash_0 = fields_hash_arr[0],
13196 .fields_hash_1 = fields_hash_arr[1],13196 .fields_hash_1 = fields_hash_arr[1],
...@@ -13251,7 +13251,7 @@ const GenZir = struct {...@@ -13251,7 +13251,7 @@ const GenZir = struct {
1325113251
13252 const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);13252 const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
1325313253
13254 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).Struct.fields.len + 5);13254 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.UnionDecl).@"struct".fields.len + 5);
13255 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.UnionDecl{13255 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.UnionDecl{
13256 .fields_hash_0 = fields_hash_arr[0],13256 .fields_hash_0 = fields_hash_arr[0],
13257 .fields_hash_1 = fields_hash_arr[1],13257 .fields_hash_1 = fields_hash_arr[1],
...@@ -13313,7 +13313,7 @@ const GenZir = struct {...@@ -13313,7 +13313,7 @@ const GenZir = struct {
1331313313
13314 const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);13314 const fields_hash_arr: [4]u32 = @bitCast(args.fields_hash);
1331513315
13316 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).Struct.fields.len + 5);13316 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.EnumDecl).@"struct".fields.len + 5);
13317 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.EnumDecl{13317 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.EnumDecl{
13318 .fields_hash_0 = fields_hash_arr[0],13318 .fields_hash_0 = fields_hash_arr[0],
13319 .fields_hash_1 = fields_hash_arr[1],13319 .fields_hash_1 = fields_hash_arr[1],
...@@ -13366,7 +13366,7 @@ const GenZir = struct {...@@ -13366,7 +13366,7 @@ const GenZir = struct {
1336613366
13367 assert(args.src_node != 0);13367 assert(args.src_node != 0);
1336813368
13369 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).Struct.fields.len + 2);13369 try astgen.extra.ensureUnusedCapacity(gpa, @typeInfo(Zir.Inst.OpaqueDecl).@"struct".fields.len + 2);
13370 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.OpaqueDecl{13370 const payload_index = astgen.addExtraAssumeCapacity(Zir.Inst.OpaqueDecl{
13371 .src_line = astgen.source_line,13371 .src_line = astgen.source_line,
13372 .src_node = args.src_node,13372 .src_node = args.src_node,
lib/std/zig/ErrorBundle.zig+6-6
...@@ -108,7 +108,7 @@ pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLoca...@@ -108,7 +108,7 @@ pub fn getSourceLocation(eb: ErrorBundle, index: SourceLocationIndex) SourceLoca
108108
109pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex {109pub fn getNotes(eb: ErrorBundle, index: MessageIndex) []const MessageIndex {
110 const notes_len = eb.getErrorMessage(index).notes_len;110 const notes_len = eb.getErrorMessage(index).notes_len;
111 const start = @intFromEnum(index) + @typeInfo(ErrorMessage).Struct.fields.len;111 const start = @intFromEnum(index) + @typeInfo(ErrorMessage).@"struct".fields.len;
112 return @as([]const MessageIndex, @ptrCast(eb.extra[start..][0..notes_len]));112 return @as([]const MessageIndex, @ptrCast(eb.extra[start..][0..notes_len]));
113}113}
114114
...@@ -119,7 +119,7 @@ pub fn getCompileLogOutput(eb: ErrorBundle) [:0]const u8 {...@@ -119,7 +119,7 @@ pub fn getCompileLogOutput(eb: ErrorBundle) [:0]const u8 {
119/// Returns the requested data, as well as the new index which is at the start of the119/// Returns the requested data, as well as the new index which is at the start of the
120/// trailers for the object.120/// trailers for the object.
121fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } {121fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } {
122 const fields = @typeInfo(T).Struct.fields;122 const fields = @typeInfo(T).@"struct".fields;
123 var i: usize = index;123 var i: usize = index;
124 var result: T = undefined;124 var result: T = undefined;
125 inline for (fields) |field| {125 inline for (fields) |field| {
...@@ -456,7 +456,7 @@ pub const Wip = struct {...@@ -456,7 +456,7 @@ pub const Wip = struct {
456456
457 pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 {457 pub fn reserveNotes(wip: *Wip, notes_len: u32) !u32 {
458 try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len +458 try wip.extra.ensureUnusedCapacity(wip.gpa, notes_len +
459 notes_len * @typeInfo(ErrorBundle.ErrorMessage).Struct.fields.len);459 notes_len * @typeInfo(ErrorBundle.ErrorMessage).@"struct".fields.len);
460 wip.extra.items.len += notes_len;460 wip.extra.items.len += notes_len;
461 return @intCast(wip.extra.items.len - notes_len);461 return @intCast(wip.extra.items.len - notes_len);
462 }462 }
...@@ -616,13 +616,13 @@ pub const Wip = struct {...@@ -616,13 +616,13 @@ pub const Wip = struct {
616616
617 fn addExtra(wip: *Wip, extra: anytype) Allocator.Error!u32 {617 fn addExtra(wip: *Wip, extra: anytype) Allocator.Error!u32 {
618 const gpa = wip.gpa;618 const gpa = wip.gpa;
619 const fields = @typeInfo(@TypeOf(extra)).Struct.fields;619 const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
620 try wip.extra.ensureUnusedCapacity(gpa, fields.len);620 try wip.extra.ensureUnusedCapacity(gpa, fields.len);
621 return addExtraAssumeCapacity(wip, extra);621 return addExtraAssumeCapacity(wip, extra);
622 }622 }
623623
624 fn addExtraAssumeCapacity(wip: *Wip, extra: anytype) u32 {624 fn addExtraAssumeCapacity(wip: *Wip, extra: anytype) u32 {
625 const fields = @typeInfo(@TypeOf(extra)).Struct.fields;625 const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
626 const result: u32 = @intCast(wip.extra.items.len);626 const result: u32 = @intCast(wip.extra.items.len);
627 wip.extra.items.len += fields.len;627 wip.extra.items.len += fields.len;
628 setExtra(wip, result, extra);628 setExtra(wip, result, extra);
...@@ -630,7 +630,7 @@ pub const Wip = struct {...@@ -630,7 +630,7 @@ pub const Wip = struct {
630 }630 }
631631
632 fn setExtra(wip: *Wip, index: usize, extra: anytype) void {632 fn setExtra(wip: *Wip, index: usize, extra: anytype) void {
633 const fields = @typeInfo(@TypeOf(extra)).Struct.fields;633 const fields = @typeInfo(@TypeOf(extra)).@"struct".fields;
634 var i = index;634 var i = index;
635 inline for (fields) |field| {635 inline for (fields) |field| {
636 wip.extra.items[i] = switch (field.type) {636 wip.extra.items[i] = switch (field.type) {
lib/std/zig/Server.zig+3-3
...@@ -282,9 +282,9 @@ fn bswap(x: anytype) @TypeOf(x) {...@@ -282,9 +282,9 @@ fn bswap(x: anytype) @TypeOf(x) {
282282
283 const T = @TypeOf(x);283 const T = @TypeOf(x);
284 switch (@typeInfo(T)) {284 switch (@typeInfo(T)) {
285 .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),285 .@"enum" => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),
286 .Int => return @byteSwap(x),286 .int => return @byteSwap(x),
287 .Struct => |info| switch (info.layout) {287 .@"struct" => |info| switch (info.layout) {
288 .@"extern" => {288 .@"extern" => {
289 var result: T = undefined;289 var result: T = undefined;
290 inline for (info.fields) |field| {290 inline for (info.fields) |field| {
lib/std/zig/Zir.zig+8-8
...@@ -68,7 +68,7 @@ fn ExtraData(comptime T: type) type {...@@ -68,7 +68,7 @@ fn ExtraData(comptime T: type) type {
68/// Returns the requested data, as well as the new index which is at the start of the68/// Returns the requested data, as well as the new index which is at the start of the
69/// trailers for the object.69/// trailers for the object.
70pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {70pub fn extraData(code: Zir, comptime T: type, index: usize) ExtraData(T) {
71 const fields = @typeInfo(T).Struct.fields;71 const fields = @typeInfo(T).@"struct".fields;
72 var i: usize = index;72 var i: usize = index;
73 var result: T = undefined;73 var result: T = undefined;
74 inline for (fields) |field| {74 inline for (fields) |field| {
...@@ -1823,7 +1823,7 @@ pub const Inst = struct {...@@ -1823,7 +1823,7 @@ pub const Inst = struct {
18231823
1824 // Uncomment to view how many tag slots are available.1824 // Uncomment to view how many tag slots are available.
1825 //comptime {1825 //comptime {
1826 // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).Enum.fields.len);1826 // @compileLog("ZIR tags left: ", 256 - @typeInfo(Tag).@"enum".fields.len);
1827 //}1827 //}
1828 };1828 };
18291829
...@@ -3551,7 +3551,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {...@@ -3551,7 +3551,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
3551 },3551 },
3552 .struct_decl => {3552 .struct_decl => {
3553 const small: Inst.StructDecl.Small = @bitCast(extended.small);3553 const small: Inst.StructDecl.Small = @bitCast(extended.small);
3554 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).Struct.fields.len);3554 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.StructDecl).@"struct".fields.len);
3555 const captures_len = if (small.has_captures_len) captures_len: {3555 const captures_len = if (small.has_captures_len) captures_len: {
3556 const captures_len = zir.extra[extra_index];3556 const captures_len = zir.extra[extra_index];
3557 extra_index += 1;3557 extra_index += 1;
...@@ -3584,7 +3584,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {...@@ -3584,7 +3584,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
3584 },3584 },
3585 .enum_decl => {3585 .enum_decl => {
3586 const small: Inst.EnumDecl.Small = @bitCast(extended.small);3586 const small: Inst.EnumDecl.Small = @bitCast(extended.small);
3587 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).Struct.fields.len);3587 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.EnumDecl).@"struct".fields.len);
3588 extra_index += @intFromBool(small.has_tag_type);3588 extra_index += @intFromBool(small.has_tag_type);
3589 const captures_len = if (small.has_captures_len) captures_len: {3589 const captures_len = if (small.has_captures_len) captures_len: {
3590 const captures_len = zir.extra[extra_index];3590 const captures_len = zir.extra[extra_index];
...@@ -3609,7 +3609,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {...@@ -3609,7 +3609,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
3609 },3609 },
3610 .union_decl => {3610 .union_decl => {
3611 const small: Inst.UnionDecl.Small = @bitCast(extended.small);3611 const small: Inst.UnionDecl.Small = @bitCast(extended.small);
3612 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).Struct.fields.len);3612 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.UnionDecl).@"struct".fields.len);
3613 extra_index += @intFromBool(small.has_tag_type);3613 extra_index += @intFromBool(small.has_tag_type);
3614 const captures_len = if (small.has_captures_len) captures_len: {3614 const captures_len = if (small.has_captures_len) captures_len: {
3615 const captures_len = zir.extra[extra_index];3615 const captures_len = zir.extra[extra_index];
...@@ -3634,7 +3634,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {...@@ -3634,7 +3634,7 @@ pub fn declIterator(zir: Zir, decl_inst: Zir.Inst.Index) DeclIterator {
3634 },3634 },
3635 .opaque_decl => {3635 .opaque_decl => {
3636 const small: Inst.OpaqueDecl.Small = @bitCast(extended.small);3636 const small: Inst.OpaqueDecl.Small = @bitCast(extended.small);
3637 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).Struct.fields.len);3637 var extra_index: u32 = @intCast(extended.operand + @typeInfo(Inst.OpaqueDecl).@"struct".fields.len);
3638 const decls_len = if (small.has_decls_len) decls_len: {3638 const decls_len = if (small.has_decls_len) decls_len: {
3639 const decls_len = zir.extra[extra_index];3639 const decls_len = zir.extra[extra_index];
3640 extra_index += 1;3640 extra_index += 1;
...@@ -4607,7 +4607,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {...@@ -4607,7 +4607,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {
4607 const extra_index = extra.end +4607 const extra_index = extra.end +
4608 extra.data.ret_body_len +4608 extra.data.ret_body_len +
4609 extra.data.body_len +4609 extra.data.body_len +
4610 @typeInfo(Inst.Func.SrcLocs).Struct.fields.len;4610 @typeInfo(Inst.Func.SrcLocs).@"struct".fields.len;
4611 return @bitCast([4]u32{4611 return @bitCast([4]u32{
4612 zir.extra[extra_index + 0],4612 zir.extra[extra_index + 0],
4613 zir.extra[extra_index + 1],4613 zir.extra[extra_index + 1],
...@@ -4647,7 +4647,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {...@@ -4647,7 +4647,7 @@ pub fn getAssociatedSrcHash(zir: Zir, inst: Zir.Inst.Index) ?std.zig.SrcHash {
4647 } else extra_index += @intFromBool(bits.has_ret_ty_ref);4647 } else extra_index += @intFromBool(bits.has_ret_ty_ref);
4648 extra_index += @intFromBool(bits.has_any_noalias);4648 extra_index += @intFromBool(bits.has_any_noalias);
4649 extra_index += extra.data.body_len;4649 extra_index += extra.data.body_len;
4650 extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).Struct.fields.len;4650 extra_index += @typeInfo(Zir.Inst.Func.SrcLocs).@"struct".fields.len;
4651 return @bitCast([4]u32{4651 return @bitCast([4]u32{
4652 zir.extra[extra_index + 0],4652 zir.extra[extra_index + 0],
4653 zir.extra[extra_index + 1],4653 zir.extra[extra_index + 1],
lib/std/zig/c_translation.zig+59-59
...@@ -9,60 +9,60 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {...@@ -9,60 +9,60 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
9 // this function should behave like transCCast in translate-c, except it's for macros9 // this function should behave like transCCast in translate-c, except it's for macros
10 const SourceType = @TypeOf(target);10 const SourceType = @TypeOf(target);
11 switch (@typeInfo(DestType)) {11 switch (@typeInfo(DestType)) {
12 .Fn => return castToPtr(*const DestType, SourceType, target),12 .@"fn" => return castToPtr(*const DestType, SourceType, target),
13 .Pointer => return castToPtr(DestType, SourceType, target),13 .pointer => return castToPtr(DestType, SourceType, target),
14 .Optional => |dest_opt| {14 .optional => |dest_opt| {
15 if (@typeInfo(dest_opt.child) == .Pointer) {15 if (@typeInfo(dest_opt.child) == .pointer) {
16 return castToPtr(DestType, SourceType, target);16 return castToPtr(DestType, SourceType, target);
17 } else if (@typeInfo(dest_opt.child) == .Fn) {17 } else if (@typeInfo(dest_opt.child) == .@"fn") {
18 return castToPtr(?*const dest_opt.child, SourceType, target);18 return castToPtr(?*const dest_opt.child, SourceType, target);
19 }19 }
20 },20 },
21 .Int => {21 .int => {
22 switch (@typeInfo(SourceType)) {22 switch (@typeInfo(SourceType)) {
23 .Pointer => {23 .pointer => {
24 return castInt(DestType, @intFromPtr(target));24 return castInt(DestType, @intFromPtr(target));
25 },25 },
26 .Optional => |opt| {26 .optional => |opt| {
27 if (@typeInfo(opt.child) == .Pointer) {27 if (@typeInfo(opt.child) == .pointer) {
28 return castInt(DestType, @intFromPtr(target));28 return castInt(DestType, @intFromPtr(target));
29 }29 }
30 },30 },
31 .Int => {31 .int => {
32 return castInt(DestType, target);32 return castInt(DestType, target);
33 },33 },
34 .Fn => {34 .@"fn" => {
35 return castInt(DestType, @intFromPtr(&target));35 return castInt(DestType, @intFromPtr(&target));
36 },36 },
37 .Bool => {37 .bool => {
38 return @intFromBool(target);38 return @intFromBool(target);
39 },39 },
40 else => {},40 else => {},
41 }41 }
42 },42 },
43 .Float => {43 .float => {
44 switch (@typeInfo(SourceType)) {44 switch (@typeInfo(SourceType)) {
45 .Int => return @as(DestType, @floatFromInt(target)),45 .int => return @as(DestType, @floatFromInt(target)),
46 .Float => return @as(DestType, @floatCast(target)),46 .float => return @as(DestType, @floatCast(target)),
47 .Bool => return @as(DestType, @floatFromInt(@intFromBool(target))),47 .bool => return @as(DestType, @floatFromInt(@intFromBool(target))),
48 else => {},48 else => {},
49 }49 }
50 },50 },
51 .Union => |info| {51 .@"union" => |info| {
52 inline for (info.fields) |field| {52 inline for (info.fields) |field| {
53 if (field.type == SourceType) return @unionInit(DestType, field.name, target);53 if (field.type == SourceType) return @unionInit(DestType, field.name, target);
54 }54 }
55 @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");55 @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");
56 },56 },
57 .Bool => return cast(usize, target) != 0,57 .bool => return cast(usize, target) != 0,
58 else => {},58 else => {},
59 }59 }
60 return @as(DestType, target);60 return @as(DestType, target);
61}61}
6262
63fn castInt(comptime DestType: type, target: anytype) DestType {63fn castInt(comptime DestType: type, target: anytype) DestType {
64 const dest = @typeInfo(DestType).Int;64 const dest = @typeInfo(DestType).int;
65 const source = @typeInfo(@TypeOf(target)).Int;65 const source = @typeInfo(@TypeOf(target)).int;
6666
67 if (dest.bits < source.bits)67 if (dest.bits < source.bits)
68 return @as(DestType, @bitCast(@as(std.meta.Int(source.signedness, dest.bits), @truncate(target))))68 return @as(DestType, @bitCast(@as(std.meta.Int(source.signedness, dest.bits), @truncate(target))))
...@@ -76,20 +76,20 @@ fn castPtr(comptime DestType: type, target: anytype) DestType {...@@ -76,20 +76,20 @@ fn castPtr(comptime DestType: type, target: anytype) DestType {
7676
77fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {77fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype) DestType {
78 switch (@typeInfo(SourceType)) {78 switch (@typeInfo(SourceType)) {
79 .Int => {79 .int => {
80 return @as(DestType, @ptrFromInt(castInt(usize, target)));80 return @as(DestType, @ptrFromInt(castInt(usize, target)));
81 },81 },
82 .ComptimeInt => {82 .comptime_int => {
83 if (target < 0)83 if (target < 0)
84 return @as(DestType, @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(target))))))84 return @as(DestType, @ptrFromInt(@as(usize, @bitCast(@as(isize, @intCast(target))))))
85 else85 else
86 return @as(DestType, @ptrFromInt(@as(usize, @intCast(target))));86 return @as(DestType, @ptrFromInt(@as(usize, @intCast(target))));
87 },87 },
88 .Pointer => {88 .pointer => {
89 return castPtr(DestType, target);89 return castPtr(DestType, target);
90 },90 },
91 .Optional => |target_opt| {91 .optional => |target_opt| {
92 if (@typeInfo(target_opt.child) == .Pointer) {92 if (@typeInfo(target_opt.child) == .pointer) {
93 return castPtr(DestType, target);93 return castPtr(DestType, target);
94 }94 }
95 },95 },
...@@ -100,8 +100,8 @@ fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype...@@ -100,8 +100,8 @@ fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype
100100
101fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer {101fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer {
102 return switch (@typeInfo(PtrType)) {102 return switch (@typeInfo(PtrType)) {
103 .Optional => |opt_info| @typeInfo(opt_info.child).Pointer,103 .optional => |opt_info| @typeInfo(opt_info.child).pointer,
104 .Pointer => |ptr_info| ptr_info,104 .pointer => |ptr_info| ptr_info,
105 else => unreachable,105 else => unreachable,
106 };106 };
107}107}
...@@ -144,17 +144,17 @@ test "cast" {...@@ -144,17 +144,17 @@ test "cast" {
144pub fn sizeof(target: anytype) usize {144pub fn sizeof(target: anytype) usize {
145 const T: type = if (@TypeOf(target) == type) target else @TypeOf(target);145 const T: type = if (@TypeOf(target) == type) target else @TypeOf(target);
146 switch (@typeInfo(T)) {146 switch (@typeInfo(T)) {
147 .Float, .Int, .Struct, .Union, .Array, .Bool, .Vector => return @sizeOf(T),147 .float, .int, .@"struct", .@"union", .array, .bool, .vector => return @sizeOf(T),
148 .Fn => {148 .@"fn" => {
149 // sizeof(main) in C returns 1149 // sizeof(main) in C returns 1
150 return 1;150 return 1;
151 },151 },
152 .Null => return @sizeOf(*anyopaque),152 .null => return @sizeOf(*anyopaque),
153 .Void => {153 .void => {
154 // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC.154 // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC.
155 return 1;155 return 1;
156 },156 },
157 .Opaque => {157 .@"opaque" => {
158 if (T == anyopaque) {158 if (T == anyopaque) {
159 // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC.159 // Note: sizeof(void) is 1 on clang/gcc and 0 on MSVC.
160 return 1;160 return 1;
...@@ -162,24 +162,24 @@ pub fn sizeof(target: anytype) usize {...@@ -162,24 +162,24 @@ pub fn sizeof(target: anytype) usize {
162 @compileError("Cannot use C sizeof on opaque type " ++ @typeName(T));162 @compileError("Cannot use C sizeof on opaque type " ++ @typeName(T));
163 }163 }
164 },164 },
165 .Optional => |opt| {165 .optional => |opt| {
166 if (@typeInfo(opt.child) == .Pointer) {166 if (@typeInfo(opt.child) == .pointer) {
167 return sizeof(opt.child);167 return sizeof(opt.child);
168 } else {168 } else {
169 @compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T));169 @compileError("Cannot use C sizeof on non-pointer optional " ++ @typeName(T));
170 }170 }
171 },171 },
172 .Pointer => |ptr| {172 .pointer => |ptr| {
173 if (ptr.size == .Slice) {173 if (ptr.size == .Slice) {
174 @compileError("Cannot use C sizeof on slice type " ++ @typeName(T));174 @compileError("Cannot use C sizeof on slice type " ++ @typeName(T));
175 }175 }
176 // for strings, sizeof("a") returns 2.176 // for strings, sizeof("a") returns 2.
177 // normal pointer decay scenarios from C are handled177 // normal pointer decay scenarios from C are handled
178 // in the .Array case above, but strings remain literals178 // in the .array case above, but strings remain literals
179 // and are therefore always pointers, so they need to be179 // and are therefore always pointers, so they need to be
180 // specially handled here.180 // specially handled here.
181 if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .Array) {181 if (ptr.size == .One and ptr.is_const and @typeInfo(ptr.child) == .array) {
182 const array_info = @typeInfo(ptr.child).Array;182 const array_info = @typeInfo(ptr.child).array;
183 if ((array_info.child == u8 or array_info.child == u16) and183 if ((array_info.child == u8 or array_info.child == u16) and
184 array_info.sentinel != null and184 array_info.sentinel != null and
185 @as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0)185 @as(*align(1) const array_info.child, @ptrCast(array_info.sentinel.?)).* == 0)
...@@ -195,8 +195,8 @@ pub fn sizeof(target: anytype) usize {...@@ -195,8 +195,8 @@ pub fn sizeof(target: anytype) usize {
195 }195 }
196 return @sizeOf(T);196 return @sizeOf(T);
197 },197 },
198 .ComptimeFloat => return @sizeOf(f64), // TODO c_double #3999198 .comptime_float => return @sizeOf(f64), // TODO c_double #3999
199 .ComptimeInt => {199 .comptime_int => {
200 // TODO to get the correct result we have to translate200 // TODO to get the correct result we have to translate
201 // `1073741824 * 4` as `int(1073741824) *% int(4)` since201 // `1073741824 * 4` as `int(1073741824) *% int(4)` since
202 // sizeof(1073741824 * 4) != sizeof(4294967296).202 // sizeof(1073741824 * 4) != sizeof(4294967296).
...@@ -262,7 +262,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt...@@ -262,7 +262,7 @@ fn PromoteIntLiteralReturnType(comptime SuffixType: type, comptime number: compt
262 const signed_oct_hex = [_]type{ c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong };262 const signed_oct_hex = [_]type{ c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong };
263 const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong };263 const unsigned = [_]type{ c_uint, c_ulong, c_ulonglong };
264264
265 const list: []const type = if (@typeInfo(SuffixType).Int.signedness == .unsigned)265 const list: []const type = if (@typeInfo(SuffixType).int.signedness == .unsigned)
266 &unsigned266 &unsigned
267 else if (base == .decimal)267 else if (base == .decimal)
268 &signed_decimal268 &signed_decimal
...@@ -339,8 +339,8 @@ test "shuffleVectorIndex" {...@@ -339,8 +339,8 @@ test "shuffleVectorIndex" {
339/// from SelfType for pointing to a C flexible array of ElementType.339/// from SelfType for pointing to a C flexible array of ElementType.
340pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type {340pub fn FlexibleArrayType(comptime SelfType: type, comptime ElementType: type) type {
341 switch (@typeInfo(SelfType)) {341 switch (@typeInfo(SelfType)) {
342 .Pointer => |ptr| {342 .pointer => |ptr| {
343 return @Type(.{ .Pointer = .{343 return @Type(.{ .pointer = .{
344 .size = .C,344 .size = .C,
345 .is_const = ptr.is_const,345 .is_const = ptr.is_const,
346 .is_volatile = ptr.is_volatile,346 .is_volatile = ptr.is_volatile,
...@@ -372,7 +372,7 @@ test "Flexible Array Type" {...@@ -372,7 +372,7 @@ test "Flexible Array Type" {
372/// the type and denominator is -1. C has undefined behavior for those two cases; this function has safety372/// the type and denominator is -1. C has undefined behavior for those two cases; this function has safety
373/// checked undefined behavior373/// checked undefined behavior
374pub fn signedRemainder(numerator: anytype, denominator: anytype) @TypeOf(numerator, denominator) {374pub fn signedRemainder(numerator: anytype, denominator: anytype) @TypeOf(numerator, denominator) {
375 std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).Int.signedness == .signed);375 std.debug.assert(@typeInfo(@TypeOf(numerator, denominator)).int.signedness == .signed);
376 if (denominator > 0) return @rem(numerator, denominator);376 if (denominator > 0) return @rem(numerator, denominator);
377 return numerator - @divTrunc(numerator, denominator) * denominator;377 return numerator - @divTrunc(numerator, denominator) * denominator;
378}378}
...@@ -384,15 +384,15 @@ pub const Macros = struct {...@@ -384,15 +384,15 @@ pub const Macros = struct {
384384
385 fn L_SUFFIX_ReturnType(comptime number: anytype) type {385 fn L_SUFFIX_ReturnType(comptime number: anytype) type {
386 switch (@typeInfo(@TypeOf(number))) {386 switch (@typeInfo(@TypeOf(number))) {
387 .Int, .ComptimeInt => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)),387 .int, .comptime_int => return @TypeOf(promoteIntLiteral(c_long, number, .decimal)),
388 .Float, .ComptimeFloat => return c_longdouble,388 .float, .comptime_float => return c_longdouble,
389 else => @compileError("Invalid value for L suffix"),389 else => @compileError("Invalid value for L suffix"),
390 }390 }
391 }391 }
392 pub fn L_SUFFIX(comptime number: anytype) L_SUFFIX_ReturnType(number) {392 pub fn L_SUFFIX(comptime number: anytype) L_SUFFIX_ReturnType(number) {
393 switch (@typeInfo(@TypeOf(number))) {393 switch (@typeInfo(@TypeOf(number))) {
394 .Int, .ComptimeInt => return promoteIntLiteral(c_long, number, .decimal),394 .int, .comptime_int => return promoteIntLiteral(c_long, number, .decimal),
395 .Float, .ComptimeFloat => @compileError("TODO: c_longdouble initialization from comptime_float not supported"),395 .float, .comptime_float => @compileError("TODO: c_longdouble initialization from comptime_float not supported"),
396 else => @compileError("Invalid value for L suffix"),396 else => @compileError("Invalid value for L suffix"),
397 }397 }
398 }398 }
...@@ -420,13 +420,13 @@ pub const Macros = struct {...@@ -420,13 +420,13 @@ pub const Macros = struct {
420 /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)420 /// A 2-argument function-like macro defined as #define FOO(A, B) (A)(B)
421 /// could be either: cast B to A, or call A with the value B.421 /// could be either: cast B to A, or call A with the value B.
422 pub fn CAST_OR_CALL(a: anytype, b: anytype) switch (@typeInfo(@TypeOf(a))) {422 pub fn CAST_OR_CALL(a: anytype, b: anytype) switch (@typeInfo(@TypeOf(a))) {
423 .Type => a,423 .type => a,
424 .Fn => |fn_info| fn_info.return_type orelse void,424 .@"fn" => |fn_info| fn_info.return_type orelse void,
425 else => |info| @compileError("Unexpected argument type: " ++ @tagName(info)),425 else => |info| @compileError("Unexpected argument type: " ++ @tagName(info)),
426 } {426 } {
427 switch (@typeInfo(@TypeOf(a))) {427 switch (@typeInfo(@TypeOf(a))) {
428 .Type => return cast(a, b),428 .type => return cast(a, b),
429 .Fn => return a(b),429 .@"fn" => return a(b),
430 else => unreachable, // return type will be a compile error otherwise430 else => unreachable, // return type will be a compile error otherwise
431 }431 }
432 }432 }
...@@ -444,7 +444,7 @@ fn PromotedIntType(comptime T: type) type {...@@ -444,7 +444,7 @@ fn PromotedIntType(comptime T: type) type {
444 c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong => T,444 c_int, c_uint, c_long, c_ulong, c_longlong, c_ulonglong => T,
445 else => if (T == comptime_int) {445 else => if (T == comptime_int) {
446 @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a fixed-size number type is required");446 @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a fixed-size number type is required");
447 } else if (@typeInfo(T) == .Int) {447 } else if (@typeInfo(T) == .int) {
448 @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a C ABI type is required");448 @compileError("Cannot promote `" ++ @typeName(T) ++ "`; a C ABI type is required");
449 } else {449 } else {
450 @compileError("Attempted to promote invalid type `" ++ @typeName(T) ++ "`");450 @compileError("Attempted to promote invalid type `" ++ @typeName(T) ++ "`");
...@@ -490,8 +490,8 @@ fn ArithmeticConversion(comptime A: type, comptime B: type) type {...@@ -490,8 +490,8 @@ fn ArithmeticConversion(comptime A: type, comptime B: type) type {
490490
491 if (A_Promoted == B_Promoted) return A_Promoted;491 if (A_Promoted == B_Promoted) return A_Promoted;
492492
493 const a_signed = @typeInfo(A_Promoted).Int.signedness == .signed;493 const a_signed = @typeInfo(A_Promoted).int.signedness == .signed;
494 const b_signed = @typeInfo(B_Promoted).Int.signedness == .signed;494 const b_signed = @typeInfo(B_Promoted).int.signedness == .signed;
495495
496 if (a_signed == b_signed) {496 if (a_signed == b_signed) {
497 return if (integerRank(A_Promoted) > integerRank(B_Promoted)) A_Promoted else B_Promoted;497 return if (integerRank(A_Promoted) > integerRank(B_Promoted)) A_Promoted else B_Promoted;
...@@ -544,8 +544,8 @@ pub const MacroArithmetic = struct {...@@ -544,8 +544,8 @@ pub const MacroArithmetic = struct {
544 const a_casted = cast(ResType, a);544 const a_casted = cast(ResType, a);
545 const b_casted = cast(ResType, b);545 const b_casted = cast(ResType, b);
546 switch (@typeInfo(ResType)) {546 switch (@typeInfo(ResType)) {
547 .Float => return a_casted / b_casted,547 .float => return a_casted / b_casted,
548 .Int => return @divTrunc(a_casted, b_casted),548 .int => return @divTrunc(a_casted, b_casted),
549 else => unreachable,549 else => unreachable,
550 }550 }
551 }551 }
...@@ -555,8 +555,8 @@ pub const MacroArithmetic = struct {...@@ -555,8 +555,8 @@ pub const MacroArithmetic = struct {
555 const a_casted = cast(ResType, a);555 const a_casted = cast(ResType, a);
556 const b_casted = cast(ResType, b);556 const b_casted = cast(ResType, b);
557 switch (@typeInfo(ResType)) {557 switch (@typeInfo(ResType)) {
558 .Int => {558 .int => {
559 if (@typeInfo(ResType).Int.signedness == .signed) {559 if (@typeInfo(ResType).int.signedness == .signed) {
560 return signedRemainder(a_casted, b_casted);560 return signedRemainder(a_casted, b_casted);
561 } else {561 } else {
562 return a_casted % b_casted;562 return a_casted % b_casted;
lib/std/zig/parser_test.zig+1-1
...@@ -2548,7 +2548,7 @@ test "zig fmt: same-line comment after non-block if expression" {...@@ -2548,7 +2548,7 @@ test "zig fmt: same-line comment after non-block if expression" {
2548test "zig fmt: same-line comment on comptime expression" {2548test "zig fmt: same-line comment on comptime expression" {
2549 try testCanonical(2549 try testCanonical(
2550 \\test "" {2550 \\test "" {
2551 \\ comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt2551 \\ comptime assert(@typeInfo(T) == .int); // must pass an integer to absInt
2552 \\}2552 \\}
2553 \\2553 \\
2554 );2554 );
lib/std/zig/system/windows.zig+2-2
...@@ -56,11 +56,11 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {...@@ -56,11 +56,11 @@ fn getCpuInfoFromRegistry(core: usize, args: anytype) !void {
56 const ArgsType = @TypeOf(args);56 const ArgsType = @TypeOf(args);
57 const args_type_info = @typeInfo(ArgsType);57 const args_type_info = @typeInfo(ArgsType);
5858
59 if (args_type_info != .Struct) {59 if (args_type_info != .@"struct") {
60 @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));60 @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
61 }61 }
6262
63 const fields_info = args_type_info.Struct.fields;63 const fields_info = args_type_info.@"struct".fields;
6464
65 // Originally, I wanted to issue a single call with a more complex table structure such that we65 // Originally, I wanted to issue a single call with a more complex table structure such that we
66 // would sequentially visit each CPU#d subkey in the registry and pull the value of interest into66 // would sequentially visit each CPU#d subkey in the registry and pull the value of interest into
src/Air/types_resolved.zig+25-25
...@@ -272,7 +272,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {...@@ -272,7 +272,7 @@ fn checkBody(air: Air, body: []const Air.Inst.Index, zcu: *Zcu) bool {
272 const elems_len: usize = @intCast(ty.arrayLen(zcu));272 const elems_len: usize = @intCast(ty.arrayLen(zcu));
273 const elems: []const Air.Inst.Ref = @ptrCast(air.extra[data.ty_pl.payload..][0..elems_len]);273 const elems: []const Air.Inst.Ref = @ptrCast(air.extra[data.ty_pl.payload..][0..elems_len]);
274 if (!checkType(ty, zcu)) return false;274 if (!checkType(ty, zcu)) return false;
275 if (ty.zigTypeTag(zcu) == .Struct) {275 if (ty.zigTypeTag(zcu) == .@"struct") {
276 for (elems, 0..) |elem, elem_idx| {276 for (elems, 0..) |elem, elem_idx| {
277 if (ty.structFieldIsComptime(elem_idx, zcu)) continue;277 if (ty.structFieldIsComptime(elem_idx, zcu)) continue;
278 if (!checkRef(elem, zcu)) return false;278 if (!checkRef(elem, zcu)) return false;
...@@ -453,35 +453,35 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool {...@@ -453,35 +453,35 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool {
453 return switch (ty.zigTypeTagOrPoison(zcu) catch |err| switch (err) {453 return switch (ty.zigTypeTagOrPoison(zcu) catch |err| switch (err) {
454 error.GenericPoison => return true,454 error.GenericPoison => return true,
455 }) {455 }) {
456 .Type,456 .type,
457 .Void,457 .void,
458 .Bool,458 .bool,
459 .NoReturn,459 .noreturn,
460 .Int,460 .int,
461 .Float,461 .float,
462 .ErrorSet,462 .error_set,
463 .Enum,463 .@"enum",
464 .Opaque,464 .@"opaque",
465 .Vector,465 .vector,
466 // These types can appear due to some dummy instructions Sema introduces and expects to be omitted by Liveness.466 // These types can appear due to some dummy instructions Sema introduces and expects to be omitted by Liveness.
467 // It's a little silly -- but fine, we'll return `true`.467 // It's a little silly -- but fine, we'll return `true`.
468 .ComptimeFloat,468 .comptime_float,
469 .ComptimeInt,469 .comptime_int,
470 .Undefined,470 .undefined,
471 .Null,471 .null,
472 .EnumLiteral,472 .enum_literal,
473 => true,473 => true,
474474
475 .Frame,475 .frame,
476 .AnyFrame,476 .@"anyframe",
477 => @panic("TODO Air.types_resolved.checkType async frames"),477 => @panic("TODO Air.types_resolved.checkType async frames"),
478478
479 .Optional => checkType(ty.childType(zcu), zcu),479 .optional => checkType(ty.childType(zcu), zcu),
480 .ErrorUnion => checkType(ty.errorUnionPayload(zcu), zcu),480 .error_union => checkType(ty.errorUnionPayload(zcu), zcu),
481 .Pointer => checkType(ty.childType(zcu), zcu),481 .pointer => checkType(ty.childType(zcu), zcu),
482 .Array => checkType(ty.childType(zcu), zcu),482 .array => checkType(ty.childType(zcu), zcu),
483483
484 .Fn => {484 .@"fn" => {
485 const info = zcu.typeToFunc(ty).?;485 const info = zcu.typeToFunc(ty).?;
486 for (0..info.param_types.len) |i| {486 for (0..info.param_types.len) |i| {
487 const param_ty = info.param_types.get(ip)[i];487 const param_ty = info.param_types.get(ip)[i];
...@@ -489,7 +489,7 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool {...@@ -489,7 +489,7 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool {
489 }489 }
490 return checkType(Type.fromInterned(info.return_type), zcu);490 return checkType(Type.fromInterned(info.return_type), zcu);
491 },491 },
492 .Struct => switch (ip.indexToKey(ty.toIntern())) {492 .@"struct" => switch (ip.indexToKey(ty.toIntern())) {
493 .struct_type => {493 .struct_type => {
494 const struct_obj = zcu.typeToStruct(ty).?;494 const struct_obj = zcu.typeToStruct(ty).?;
495 return switch (struct_obj.layout) {495 return switch (struct_obj.layout) {
...@@ -508,6 +508,6 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool {...@@ -508,6 +508,6 @@ pub fn checkType(ty: Type, zcu: *Zcu) bool {
508 },508 },
509 else => unreachable,509 else => unreachable,
510 },510 },
511 .Union => return zcu.typeToUnion(ty).?.flagsUnordered(ip).status == .fully_resolved,511 .@"union" => return zcu.typeToUnion(ty).?.flagsUnordered(ip).status == .fully_resolved,
512 };512 };
513}513}
src/Compilation.zig+5-5
...@@ -384,7 +384,7 @@ const Job = union(enum) {...@@ -384,7 +384,7 @@ const Job = union(enum) {
384 /// The value is the index into `system_libs`.384 /// The value is the index into `system_libs`.
385 windows_import_lib: usize,385 windows_import_lib: usize,
386386
387 const Tag = @typeInfo(Job).Union.tag_type.?;387 const Tag = @typeInfo(Job).@"union".tag_type.?;
388 fn stage(tag: Tag) usize {388 fn stage(tag: Tag) usize {
389 return switch (tag) {389 return switch (tag) {
390 // Prioritize functions so that codegen can get to work on them on a390 // Prioritize functions so that codegen can get to work on them on a
...@@ -911,7 +911,7 @@ pub const cache_helpers = struct {...@@ -911,7 +911,7 @@ pub const cache_helpers = struct {
911 }911 }
912912
913 pub fn addDebugFormat(hh: *Cache.HashHelper, x: Config.DebugFormat) void {913 pub fn addDebugFormat(hh: *Cache.HashHelper, x: Config.DebugFormat) void {
914 const tag: @typeInfo(Config.DebugFormat).Union.tag_type.? = x;914 const tag: @typeInfo(Config.DebugFormat).@"union".tag_type.? = x;
915 hh.add(tag);915 hh.add(tag);
916 switch (x) {916 switch (x) {
917 .strip, .code_view => {},917 .strip, .code_view => {},
...@@ -1486,7 +1486,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1486,7 +1486,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1486 .emit_asm = options.emit_asm,1486 .emit_asm = options.emit_asm,
1487 .emit_llvm_ir = options.emit_llvm_ir,1487 .emit_llvm_ir = options.emit_llvm_ir,
1488 .emit_llvm_bc = options.emit_llvm_bc,1488 .emit_llvm_bc = options.emit_llvm_bc,
1489 .work_queues = .{std.fifo.LinearFifo(Job, .Dynamic).init(gpa)} ** @typeInfo(std.meta.FieldType(Compilation, .work_queues)).Array.len,1489 .work_queues = .{std.fifo.LinearFifo(Job, .Dynamic).init(gpa)} ** @typeInfo(std.meta.FieldType(Compilation, .work_queues)).array.len,
1490 .codegen_work = if (InternPool.single_threaded) {} else .{1490 .codegen_work = if (InternPool.single_threaded) {} else .{
1491 .mutex = .{},1491 .mutex = .{},
1492 .cond = .{},1492 .cond = .{},
...@@ -3113,8 +3113,8 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {...@@ -3113,8 +3113,8 @@ pub fn getAllErrorsAlloc(comp: *Compilation) !ErrorBundle {
3113 err: *?Error,3113 err: *?Error,
31143114
3115 const Error = @typeInfo(3115 const Error = @typeInfo(
3116 @typeInfo(@TypeOf(Zcu.SrcLoc.span)).Fn.return_type.?,3116 @typeInfo(@TypeOf(Zcu.SrcLoc.span)).@"fn".return_type.?,
3117 ).ErrorUnion.error_set;3117 ).error_union.error_set;
31183118
3119 pub fn lessThan(ctx: @This(), lhs_index: usize, rhs_index: usize) bool {3119 pub fn lessThan(ctx: @This(), lhs_index: usize, rhs_index: usize) bool {
3120 if (ctx.err.*) |_| return lhs_index < rhs_index;3120 if (ctx.err.*) |_| return lhs_index < rhs_index;
src/InternPool.zig+93-93
...@@ -893,7 +893,7 @@ const Local = struct {...@@ -893,7 +893,7 @@ const Local = struct {
893 };893 };
894894
895 fn List(comptime Elem: type) type {895 fn List(comptime Elem: type) type {
896 assert(@typeInfo(Elem) == .Struct);896 assert(@typeInfo(Elem) == .@"struct");
897 return struct {897 return struct {
898 bytes: [*]align(@alignOf(Elem)) u8,898 bytes: [*]align(@alignOf(Elem)) u8,
899899
...@@ -907,7 +907,7 @@ const Local = struct {...@@ -907,7 +907,7 @@ const Local = struct {
907 const fields = std.enums.values(std.meta.FieldEnum(Elem));907 const fields = std.enums.values(std.meta.FieldEnum(Elem));
908908
909 fn PtrArrayElem(comptime len: usize) type {909 fn PtrArrayElem(comptime len: usize) type {
910 const elem_info = @typeInfo(Elem).Struct;910 const elem_info = @typeInfo(Elem).@"struct";
911 const elem_fields = elem_info.fields;911 const elem_fields = elem_info.fields;
912 var new_fields: [elem_fields.len]std.builtin.Type.StructField = undefined;912 var new_fields: [elem_fields.len]std.builtin.Type.StructField = undefined;
913 for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{913 for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{
...@@ -917,7 +917,7 @@ const Local = struct {...@@ -917,7 +917,7 @@ const Local = struct {
917 .is_comptime = false,917 .is_comptime = false,
918 .alignment = 0,918 .alignment = 0,
919 };919 };
920 return @Type(.{ .Struct = .{920 return @Type(.{ .@"struct" = .{
921 .layout = .auto,921 .layout = .auto,
922 .fields = &new_fields,922 .fields = &new_fields,
923 .decls = &.{},923 .decls = &.{},
...@@ -928,12 +928,12 @@ const Local = struct {...@@ -928,12 +928,12 @@ const Local = struct {
928 size: std.builtin.Type.Pointer.Size,928 size: std.builtin.Type.Pointer.Size,
929 is_const: bool = false,929 is_const: bool = false,
930 }) type {930 }) type {
931 const elem_info = @typeInfo(Elem).Struct;931 const elem_info = @typeInfo(Elem).@"struct";
932 const elem_fields = elem_info.fields;932 const elem_fields = elem_info.fields;
933 var new_fields: [elem_fields.len]std.builtin.Type.StructField = undefined;933 var new_fields: [elem_fields.len]std.builtin.Type.StructField = undefined;
934 for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{934 for (&new_fields, elem_fields) |*new_field, elem_field| new_field.* = .{
935 .name = elem_field.name,935 .name = elem_field.name,
936 .type = @Type(.{ .Pointer = .{936 .type = @Type(.{ .pointer = .{
937 .size = opts.size,937 .size = opts.size,
938 .is_const = opts.is_const,938 .is_const = opts.is_const,
939 .is_volatile = false,939 .is_volatile = false,
...@@ -947,7 +947,7 @@ const Local = struct {...@@ -947,7 +947,7 @@ const Local = struct {
947 .is_comptime = false,947 .is_comptime = false,
948 .alignment = 0,948 .alignment = 0,
949 };949 };
950 return @Type(.{ .Struct = .{950 return @Type(.{ .@"struct" = .{
951 .layout = .auto,951 .layout = .auto,
952 .fields = &new_fields,952 .fields = &new_fields,
953 .decls = &.{},953 .decls = &.{},
...@@ -1306,7 +1306,7 @@ const Shard = struct {...@@ -1306,7 +1306,7 @@ const Shard = struct {
1306 };1306 };
13071307
1308 fn Map(comptime Value: type) type {1308 fn Map(comptime Value: type) type {
1309 comptime assert(@typeInfo(Value).Enum.tag_type == u32);1309 comptime assert(@typeInfo(Value).@"enum".tag_type == u32);
1310 _ = @as(Value, .none); // expected .none key1310 _ = @as(Value, .none); // expected .none key
1311 return struct {1311 return struct {
1312 /// header: Header,1312 /// header: Header,
...@@ -2254,7 +2254,7 @@ pub const Key = union(enum) {...@@ -2254,7 +2254,7 @@ pub const Key = union(enum) {
2254 byte_offset: u64,2254 byte_offset: u64,
22552255
2256 pub const BaseAddr = union(enum) {2256 pub const BaseAddr = union(enum) {
2257 const Tag = @typeInfo(BaseAddr).Union.tag_type.?;2257 const Tag = @typeInfo(BaseAddr).@"union".tag_type.?;
22582258
2259 /// Points to the value of a single `Nav`, which may be constant or a `variable`.2259 /// Points to the value of a single `Nav`, which may be constant or a `variable`.
2260 nav: Nav.Index,2260 nav: Nav.Index,
...@@ -2411,7 +2411,7 @@ pub const Key = union(enum) {...@@ -2411,7 +2411,7 @@ pub const Key = union(enum) {
24112411
2412 pub fn hash64(key: Key, ip: *const InternPool) u64 {2412 pub fn hash64(key: Key, ip: *const InternPool) u64 {
2413 const asBytes = std.mem.asBytes;2413 const asBytes = std.mem.asBytes;
2414 const KeyTag = @typeInfo(Key).Union.tag_type.?;2414 const KeyTag = @typeInfo(Key).@"union".tag_type.?;
2415 const seed = @intFromEnum(@as(KeyTag, key));2415 const seed = @intFromEnum(@as(KeyTag, key));
2416 return switch (key) {2416 return switch (key) {
2417 // TODO: assert no padding in these types2417 // TODO: assert no padding in these types
...@@ -2487,7 +2487,7 @@ pub const Key = union(enum) {...@@ -2487,7 +2487,7 @@ pub const Key = union(enum) {
2487 .lazy_align, .lazy_size => |lazy_ty| {2487 .lazy_align, .lazy_size => |lazy_ty| {
2488 std.hash.autoHash(2488 std.hash.autoHash(
2489 &hasher,2489 &hasher,
2490 @as(@typeInfo(Key.Int.Storage).Union.tag_type.?, int.storage),2490 @as(@typeInfo(Key.Int.Storage).@"union".tag_type.?, int.storage),
2491 );2491 );
2492 std.hash.autoHash(&hasher, lazy_ty);2492 std.hash.autoHash(&hasher, lazy_ty);
2493 },2493 },
...@@ -2651,7 +2651,7 @@ pub const Key = union(enum) {...@@ -2651,7 +2651,7 @@ pub const Key = union(enum) {
2651 }2651 }
26522652
2653 pub fn eql(a: Key, b: Key, ip: *const InternPool) bool {2653 pub fn eql(a: Key, b: Key, ip: *const InternPool) bool {
2654 const KeyTag = @typeInfo(Key).Union.tag_type.?;2654 const KeyTag = @typeInfo(Key).@"union".tag_type.?;
2655 const a_tag: KeyTag = a;2655 const a_tag: KeyTag = a;
2656 const b_tag: KeyTag = b;2656 const b_tag: KeyTag = b;
2657 if (a_tag != b_tag) return false;2657 if (a_tag != b_tag) return false;
...@@ -2861,7 +2861,7 @@ pub const Key = union(enum) {...@@ -2861,7 +2861,7 @@ pub const Key = union(enum) {
2861 return a_val == b_val;2861 return a_val == b_val;
2862 }2862 }
28632863
2864 const StorageTag = @typeInfo(Key.Float.Storage).Union.tag_type.?;2864 const StorageTag = @typeInfo(Key.Float.Storage).@"union".tag_type.?;
2865 assert(@as(StorageTag, a_info.storage) == @as(StorageTag, b_info.storage));2865 assert(@as(StorageTag, a_info.storage) == @as(StorageTag, b_info.storage));
28662866
2867 switch (a_info.storage) {2867 switch (a_info.storage) {
...@@ -2905,7 +2905,7 @@ pub const Key = union(enum) {...@@ -2905,7 +2905,7 @@ pub const Key = union(enum) {
2905 if (a_info.ty != b_info.ty) return false;2905 if (a_info.ty != b_info.ty) return false;
29062906
2907 const len = ip.aggregateTypeLen(a_info.ty);2907 const len = ip.aggregateTypeLen(a_info.ty);
2908 const StorageTag = @typeInfo(Key.Aggregate.Storage).Union.tag_type.?;2908 const StorageTag = @typeInfo(Key.Aggregate.Storage).@"union".tag_type.?;
2909 if (@as(StorageTag, a_info.storage) != @as(StorageTag, b_info.storage)) {2909 if (@as(StorageTag, a_info.storage) != @as(StorageTag, b_info.storage)) {
2910 for (0..@intCast(len)) |elem_index| {2910 for (0..@intCast(len)) |elem_index| {
2911 const a_elem = switch (a_info.storage) {2911 const a_elem = switch (a_info.storage) {
...@@ -4000,7 +4000,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -4000,7 +4000,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
4000 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);4000 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);
4001 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "fields_len").?];4001 const fields_len = extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "fields_len").?];
4002 const flags: Tag.TypeStruct.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?], .unordered));4002 const flags: Tag.TypeStruct.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?], .unordered));
4003 var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStruct).Struct.fields.len);4003 var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStruct).@"struct".fields.len);
4004 const captures_len = if (flags.any_captures) c: {4004 const captures_len = if (flags.any_captures) c: {
4005 const len = extra_list.view().items(.@"0")[extra_index];4005 const len = extra_list.view().items(.@"0")[extra_index];
4006 extra_index += 1;4006 extra_index += 1;
...@@ -4105,7 +4105,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {...@@ -4105,7 +4105,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
4105 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?]);4105 const namespace: NamespaceIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "namespace").?]);
4106 const names_map: MapIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "names_map").?]);4106 const names_map: MapIndex = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "names_map").?]);
4107 const flags: Tag.TypeStructPacked.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?], .unordered));4107 const flags: Tag.TypeStructPacked.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?], .unordered));
4108 var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStructPacked).Struct.fields.len);4108 var extra_index = item.data + @as(u32, @typeInfo(Tag.TypeStructPacked).@"struct".fields.len);
4109 const has_inits = item.tag == .type_struct_packed_inits;4109 const has_inits = item.tag == .type_struct_packed_inits;
4110 const captures_len = if (flags.any_captures) c: {4110 const captures_len = if (flags.any_captures) c: {
4111 const len = extra_list.view().items(.@"0")[extra_index];4111 const len = extra_list.view().items(.@"0")[extra_index];
...@@ -4711,9 +4711,9 @@ pub const Index = enum(u32) {...@@ -4711,9 +4711,9 @@ pub const Index = enum(u32) {
4711 },4711 },
4712 }) void {4712 }) void {
4713 _ = self;4713 _ = self;
4714 const map_fields = @typeInfo(@typeInfo(@TypeOf(tag_to_encoding_map)).Pointer.child).Struct.fields;4714 const map_fields = @typeInfo(@typeInfo(@TypeOf(tag_to_encoding_map)).pointer.child).@"struct".fields;
4715 @setEvalBranchQuota(2_000);4715 @setEvalBranchQuota(2_000);
4716 inline for (@typeInfo(Tag).Enum.fields, 0..) |tag, start| {4716 inline for (@typeInfo(Tag).@"enum".fields, 0..) |tag, start| {
4717 inline for (0..map_fields.len) |offset| {4717 inline for (0..map_fields.len) |offset| {
4718 if (comptime std.mem.eql(u8, tag.name, map_fields[(start + offset) % map_fields.len].name)) break;4718 if (comptime std.mem.eql(u8, tag.name, map_fields[(start + offset) % map_fields.len].name)) break;
4719 } else {4719 } else {
...@@ -6384,7 +6384,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -6384,7 +6384,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
6384 const extra_items = extra_list.view().items(.@"0");6384 const extra_items = extra_list.view().items(.@"0");
6385 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);6385 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[data + std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?]);
6386 const flags: Tag.TypeStruct.Flags = @bitCast(@atomicLoad(u32, &extra_items[data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?], .unordered));6386 const flags: Tag.TypeStruct.Flags = @bitCast(@atomicLoad(u32, &extra_items[data + std.meta.fieldIndex(Tag.TypeStruct, "flags").?], .unordered));
6387 const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStruct).Struct.fields.len);6387 const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStruct).@"struct".fields.len);
6388 if (flags.is_reified) {6388 if (flags.is_reified) {
6389 assert(!flags.any_captures);6389 assert(!flags.any_captures);
6390 break :ns .{ .reified = .{6390 break :ns .{ .reified = .{
...@@ -6407,7 +6407,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {...@@ -6407,7 +6407,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
6407 const extra_items = extra_list.view().items(.@"0");6407 const extra_items = extra_list.view().items(.@"0");
6408 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "zir_index").?]);6408 const zir_index: TrackedInst.Index = @enumFromInt(extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "zir_index").?]);
6409 const flags: Tag.TypeStructPacked.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?], .unordered));6409 const flags: Tag.TypeStructPacked.Flags = @bitCast(@atomicLoad(u32, &extra_items[item.data + std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?], .unordered));
6410 const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStructPacked).Struct.fields.len);6410 const end_extra_index = data + @as(u32, @typeInfo(Tag.TypeStructPacked).@"struct".fields.len);
6411 if (flags.is_reified) {6411 if (flags.is_reified) {
6412 assert(!flags.any_captures);6412 assert(!flags.any_captures);
6413 break :ns .{ .reified = .{6413 break :ns .{ .reified = .{
...@@ -6922,7 +6922,7 @@ fn extraFuncInstance(ip: *const InternPool, tid: Zcu.PerThread.Id, extra: Local....@@ -6922,7 +6922,7 @@ fn extraFuncInstance(ip: *const InternPool, tid: Zcu.PerThread.Id, extra: Local.
6922 const ty: Index = @enumFromInt(extra_items[extra_index + std.meta.fieldIndex(Tag.FuncInstance, "ty").?]);6922 const ty: Index = @enumFromInt(extra_items[extra_index + std.meta.fieldIndex(Tag.FuncInstance, "ty").?]);
6923 const generic_owner: Index = @enumFromInt(extra_items[extra_index + std.meta.fieldIndex(Tag.FuncInstance, "generic_owner").?]);6923 const generic_owner: Index = @enumFromInt(extra_items[extra_index + std.meta.fieldIndex(Tag.FuncInstance, "generic_owner").?]);
6924 const func_decl = ip.funcDeclInfo(generic_owner);6924 const func_decl = ip.funcDeclInfo(generic_owner);
6925 const end_extra_index = extra_index + @as(u32, @typeInfo(Tag.FuncInstance).Struct.fields.len);6925 const end_extra_index = extra_index + @as(u32, @typeInfo(Tag.FuncInstance).@"struct".fields.len);
6926 return .{6926 return .{
6927 .tid = tid,6927 .tid = tid,
6928 .ty = ty,6928 .ty = ty,
...@@ -7288,7 +7288,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7288,7 +7288,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7288 const names_map = try ip.addMap(gpa, tid, names.len);7288 const names_map = try ip.addMap(gpa, tid, names.len);
7289 ip.addStringsToMap(names_map, names);7289 ip.addStringsToMap(names_map, names);
7290 const names_len = error_set_type.names.len;7290 const names_len = error_set_type.names.len;
7291 try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).Struct.fields.len + names_len);7291 try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).@"struct".fields.len + names_len);
7292 items.appendAssumeCapacity(.{7292 items.appendAssumeCapacity(.{
7293 .tag = .type_error_set,7293 .tag = .type_error_set,
7294 .data = addExtraAssumeCapacity(extra, Tag.ErrorSet{7294 .data = addExtraAssumeCapacity(extra, Tag.ErrorSet{
...@@ -7883,7 +7883,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7883,7 +7883,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7883 .repeated_elem => |elem| elem,7883 .repeated_elem => |elem| elem,
7884 };7884 };
78857885
7886 try extra.ensureUnusedCapacity(@typeInfo(Repeated).Struct.fields.len);7886 try extra.ensureUnusedCapacity(@typeInfo(Repeated).@"struct".fields.len);
7887 items.appendAssumeCapacity(.{7887 items.appendAssumeCapacity(.{
7888 .tag = .repeated,7888 .tag = .repeated,
7889 .data = addExtraAssumeCapacity(extra, Repeated{7889 .data = addExtraAssumeCapacity(extra, Repeated{
...@@ -7898,7 +7898,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7898,7 +7898,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7898 const strings = ip.getLocal(tid).getMutableStrings(gpa);7898 const strings = ip.getLocal(tid).getMutableStrings(gpa);
7899 const start = strings.mutate.len;7899 const start = strings.mutate.len;
7900 try strings.ensureUnusedCapacity(@intCast(len_including_sentinel + 1));7900 try strings.ensureUnusedCapacity(@intCast(len_including_sentinel + 1));
7901 try extra.ensureUnusedCapacity(@typeInfo(Bytes).Struct.fields.len);7901 try extra.ensureUnusedCapacity(@typeInfo(Bytes).@"struct".fields.len);
7902 switch (aggregate.storage) {7902 switch (aggregate.storage) {
7903 .bytes => |bytes| strings.appendSliceAssumeCapacity(.{bytes.toSlice(len, ip)}),7903 .bytes => |bytes| strings.appendSliceAssumeCapacity(.{bytes.toSlice(len, ip)}),
7904 .elems => |elems| for (elems[0..@intCast(len)]) |elem| switch (ip.indexToKey(elem)) {7904 .elems => |elems| for (elems[0..@intCast(len)]) |elem| switch (ip.indexToKey(elem)) {
...@@ -7938,7 +7938,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7938,7 +7938,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
7938 }7938 }
79397939
7940 try extra.ensureUnusedCapacity(7940 try extra.ensureUnusedCapacity(
7941 @typeInfo(Tag.Aggregate).Struct.fields.len + @as(usize, @intCast(len_including_sentinel + 1)),7941 @typeInfo(Tag.Aggregate).@"struct".fields.len + @as(usize, @intCast(len_including_sentinel + 1)),
7942 );7942 );
7943 items.appendAssumeCapacity(.{7943 items.appendAssumeCapacity(.{
7944 .tag = .aggregate,7944 .tag = .aggregate,
...@@ -7961,7 +7961,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All...@@ -7961,7 +7961,7 @@ pub fn get(ip: *InternPool, gpa: Allocator, tid: Zcu.PerThread.Id, key: Key) All
79617961
7962 .memoized_call => |memoized_call| {7962 .memoized_call => |memoized_call| {
7963 for (memoized_call.arg_values) |arg| assert(arg != .none);7963 for (memoized_call.arg_values) |arg| assert(arg != .none);
7964 try extra.ensureUnusedCapacity(@typeInfo(MemoizedCall).Struct.fields.len +7964 try extra.ensureUnusedCapacity(@typeInfo(MemoizedCall).@"struct".fields.len +
7965 memoized_call.arg_values.len);7965 memoized_call.arg_values.len);
7966 items.appendAssumeCapacity(.{7966 items.appendAssumeCapacity(.{
7967 .tag = .memoized_call,7967 .tag = .memoized_call,
...@@ -8050,7 +8050,7 @@ pub fn getUnionType(...@@ -8050,7 +8050,7 @@ pub fn getUnionType(
80508050
8051 const align_elements_len = if (ini.flags.any_aligned_fields) (ini.fields_len + 3) / 4 else 0;8051 const align_elements_len = if (ini.flags.any_aligned_fields) (ini.fields_len + 3) / 4 else 0;
8052 const align_element: u32 = @bitCast([1]u8{@intFromEnum(Alignment.none)} ** 4);8052 const align_element: u32 = @bitCast([1]u8{@intFromEnum(Alignment.none)} ** 4);
8053 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeUnion).Struct.fields.len +8053 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeUnion).@"struct".fields.len +
8054 // TODO: fmt bug8054 // TODO: fmt bug
8055 // zig fmt: off8055 // zig fmt: off
8056 switch (ini.key) {8056 switch (ini.key) {
...@@ -8259,7 +8259,7 @@ pub fn getStructType(...@@ -8259,7 +8259,7 @@ pub fn getStructType(
8259 .auto => false,8259 .auto => false,
8260 .@"extern" => true,8260 .@"extern" => true,
8261 .@"packed" => {8261 .@"packed" => {
8262 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStructPacked).Struct.fields.len +8262 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStructPacked).@"struct".fields.len +
8263 // TODO: fmt bug8263 // TODO: fmt bug
8264 // zig fmt: off8264 // zig fmt: off
8265 switch (ini.key) {8265 switch (ini.key) {
...@@ -8327,7 +8327,7 @@ pub fn getStructType(...@@ -8327,7 +8327,7 @@ pub fn getStructType(
8327 const align_element: u32 = @bitCast([1]u8{@intFromEnum(Alignment.none)} ** 4);8327 const align_element: u32 = @bitCast([1]u8{@intFromEnum(Alignment.none)} ** 4);
8328 const comptime_elements_len = if (ini.any_comptime_fields) (ini.fields_len + 31) / 32 else 0;8328 const comptime_elements_len = if (ini.any_comptime_fields) (ini.fields_len + 31) / 32 else 0;
83298329
8330 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStruct).Struct.fields.len +8330 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeStruct).@"struct".fields.len +
8331 // TODO: fmt bug8331 // TODO: fmt bug
8332 // zig fmt: off8332 // zig fmt: off
8333 switch (ini.key) {8333 switch (ini.key) {
...@@ -8443,7 +8443,7 @@ pub fn getAnonStructType(...@@ -8443,7 +8443,7 @@ pub fn getAnonStructType(
84438443
8444 try items.ensureUnusedCapacity(1);8444 try items.ensureUnusedCapacity(1);
8445 try extra.ensureUnusedCapacity(8445 try extra.ensureUnusedCapacity(
8446 @typeInfo(TypeStructAnon).Struct.fields.len + (fields_len * 3),8446 @typeInfo(TypeStructAnon).@"struct".fields.len + (fields_len * 3),
8447 );8447 );
84488448
8449 const extra_index = addExtraAssumeCapacity(extra, TypeStructAnon{8449 const extra_index = addExtraAssumeCapacity(extra, TypeStructAnon{
...@@ -8509,7 +8509,7 @@ pub fn getFuncType(...@@ -8509,7 +8509,7 @@ pub fn getFuncType(
8509 const prev_extra_len = extra.mutate.len;8509 const prev_extra_len = extra.mutate.len;
8510 const params_len: u32 = @intCast(key.param_types.len);8510 const params_len: u32 = @intCast(key.param_types.len);
85118511
8512 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeFunction).Struct.fields.len +8512 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeFunction).@"struct".fields.len +
8513 @intFromBool(key.comptime_bits != 0) +8513 @intFromBool(key.comptime_bits != 0) +
8514 @intFromBool(key.noalias_bits != 0) +8514 @intFromBool(key.noalias_bits != 0) +
8515 params_len);8515 params_len);
...@@ -8575,7 +8575,7 @@ pub fn getExtern(...@@ -8575,7 +8575,7 @@ pub fn getExtern(
8575 const items = local.getMutableItems(gpa);8575 const items = local.getMutableItems(gpa);
8576 const extra = local.getMutableExtra(gpa);8576 const extra = local.getMutableExtra(gpa);
8577 try items.ensureUnusedCapacity(1);8577 try items.ensureUnusedCapacity(1);
8578 try extra.ensureUnusedCapacity(@typeInfo(Tag.Extern).Struct.fields.len);8578 try extra.ensureUnusedCapacity(@typeInfo(Tag.Extern).@"struct".fields.len);
8579 try local.getMutableNavs(gpa).ensureUnusedCapacity(1);8579 try local.getMutableNavs(gpa).ensureUnusedCapacity(1);
85808580
8581 // Predict the index the `@"extern" will live at, so we can construct the owner `Nav` before releasing the shard's mutex.8581 // Predict the index the `@"extern" will live at, so we can construct the owner `Nav` before releasing the shard's mutex.
...@@ -8642,7 +8642,7 @@ pub fn getFuncDecl(...@@ -8642,7 +8642,7 @@ pub fn getFuncDecl(
8642 // arrays. This is similar to what `getOrPutTrailingString` does.8642 // arrays. This is similar to what `getOrPutTrailingString` does.
8643 const prev_extra_len = extra.mutate.len;8643 const prev_extra_len = extra.mutate.len;
86448644
8645 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).Struct.fields.len);8645 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).@"struct".fields.len);
86468646
8647 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{8647 const func_decl_extra_index = addExtraAssumeCapacity(extra, Tag.FuncDecl{
8648 .analysis = .{8648 .analysis = .{
...@@ -8723,10 +8723,10 @@ pub fn getFuncDeclIes(...@@ -8723,10 +8723,10 @@ pub fn getFuncDeclIes(
8723 const prev_extra_len = extra.mutate.len;8723 const prev_extra_len = extra.mutate.len;
8724 const params_len: u32 = @intCast(key.param_types.len);8724 const params_len: u32 = @intCast(key.param_types.len);
87258725
8726 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).Struct.fields.len +8726 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncDecl).@"struct".fields.len +
8727 1 + // inferred_error_set8727 1 + // inferred_error_set
8728 @typeInfo(Tag.ErrorUnionType).Struct.fields.len +8728 @typeInfo(Tag.ErrorUnionType).@"struct".fields.len +
8729 @typeInfo(Tag.TypeFunction).Struct.fields.len +8729 @typeInfo(Tag.TypeFunction).@"struct".fields.len +
8730 @intFromBool(key.comptime_bits != 0) +8730 @intFromBool(key.comptime_bits != 0) +
8731 @intFromBool(key.noalias_bits != 0) +8731 @intFromBool(key.noalias_bits != 0) +
8732 params_len);8732 params_len);
...@@ -8855,7 +8855,7 @@ pub fn getErrorSetType(...@@ -8855,7 +8855,7 @@ pub fn getErrorSetType(
8855 const local = ip.getLocal(tid);8855 const local = ip.getLocal(tid);
8856 const items = local.getMutableItems(gpa);8856 const items = local.getMutableItems(gpa);
8857 const extra = local.getMutableExtra(gpa);8857 const extra = local.getMutableExtra(gpa);
8858 try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).Struct.fields.len + names.len);8858 try extra.ensureUnusedCapacity(@typeInfo(Tag.ErrorSet).@"struct".fields.len + names.len);
88598859
8860 const names_map = try ip.addMap(gpa, tid, names.len);8860 const names_map = try ip.addMap(gpa, tid, names.len);
8861 errdefer local.mutate.maps.len -= 1;8861 errdefer local.mutate.maps.len -= 1;
...@@ -8930,7 +8930,7 @@ pub fn getFuncInstance(...@@ -8930,7 +8930,7 @@ pub fn getFuncInstance(
8930 const local = ip.getLocal(tid);8930 const local = ip.getLocal(tid);
8931 const items = local.getMutableItems(gpa);8931 const items = local.getMutableItems(gpa);
8932 const extra = local.getMutableExtra(gpa);8932 const extra = local.getMutableExtra(gpa);
8933 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).Struct.fields.len +8933 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).@"struct".fields.len +
8934 arg.comptime_args.len);8934 arg.comptime_args.len);
89358935
8936 const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner);8936 const generic_owner = unwrapCoercedFunc(ip, arg.generic_owner);
...@@ -9015,11 +9015,11 @@ pub fn getFuncInstanceIes(...@@ -9015,11 +9015,11 @@ pub fn getFuncInstanceIes(
9015 const prev_extra_len = extra.mutate.len;9015 const prev_extra_len = extra.mutate.len;
9016 const params_len: u32 = @intCast(arg.param_types.len);9016 const params_len: u32 = @intCast(arg.param_types.len);
90179017
9018 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).Struct.fields.len +9018 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncInstance).@"struct".fields.len +
9019 1 + // inferred_error_set9019 1 + // inferred_error_set
9020 arg.comptime_args.len +9020 arg.comptime_args.len +
9021 @typeInfo(Tag.ErrorUnionType).Struct.fields.len +9021 @typeInfo(Tag.ErrorUnionType).@"struct".fields.len +
9022 @typeInfo(Tag.TypeFunction).Struct.fields.len +9022 @typeInfo(Tag.TypeFunction).@"struct".fields.len +
9023 @intFromBool(arg.noalias_bits != 0) +9023 @intFromBool(arg.noalias_bits != 0) +
9024 params_len);9024 params_len);
90259025
...@@ -9324,7 +9324,7 @@ pub fn getEnumType(...@@ -9324,7 +9324,7 @@ pub fn getEnumType(
9324 switch (ini.tag_mode) {9324 switch (ini.tag_mode) {
9325 .auto => {9325 .auto => {
9326 assert(!ini.has_values);9326 assert(!ini.has_values);
9327 try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).Struct.fields.len +9327 try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).@"struct".fields.len +
9328 // TODO: fmt bug9328 // TODO: fmt bug
9329 // zig fmt: off9329 // zig fmt: off
9330 switch (ini.key) {9330 switch (ini.key) {
...@@ -9384,7 +9384,7 @@ pub fn getEnumType(...@@ -9384,7 +9384,7 @@ pub fn getEnumType(
9384 local.mutate.maps.len -= 1;9384 local.mutate.maps.len -= 1;
9385 };9385 };
93869386
9387 try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).Struct.fields.len +9387 try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).@"struct".fields.len +
9388 // TODO: fmt bug9388 // TODO: fmt bug
9389 // zig fmt: off9389 // zig fmt: off
9390 switch (ini.key) {9390 switch (ini.key) {
...@@ -9499,7 +9499,7 @@ pub fn getGeneratedTagEnumType(...@@ -9499,7 +9499,7 @@ pub fn getGeneratedTagEnumType(
9499 const prev_extra_len = extra.mutate.len;9499 const prev_extra_len = extra.mutate.len;
9500 switch (ini.tag_mode) {9500 switch (ini.tag_mode) {
9501 .auto => {9501 .auto => {
9502 try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).Struct.fields.len +9502 try extra.ensureUnusedCapacity(@typeInfo(EnumAuto).@"struct".fields.len +
9503 1 + // owner_union9503 1 + // owner_union
9504 fields_len); // field names9504 fields_len); // field names
9505 items.appendAssumeCapacity(.{9505 items.appendAssumeCapacity(.{
...@@ -9518,7 +9518,7 @@ pub fn getGeneratedTagEnumType(...@@ -9518,7 +9518,7 @@ pub fn getGeneratedTagEnumType(
9518 extra.appendSliceAssumeCapacity(.{@ptrCast(ini.names)});9518 extra.appendSliceAssumeCapacity(.{@ptrCast(ini.names)});
9519 },9519 },
9520 .explicit, .nonexhaustive => {9520 .explicit, .nonexhaustive => {
9521 try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).Struct.fields.len +9521 try extra.ensureUnusedCapacity(@typeInfo(EnumExplicit).@"struct".fields.len +
9522 1 + // owner_union9522 1 + // owner_union
9523 fields_len + // field names9523 fields_len + // field names
9524 ini.values.len); // field values9524 ini.values.len); // field values
...@@ -9606,7 +9606,7 @@ pub fn getOpaqueType(...@@ -9606,7 +9606,7 @@ pub fn getOpaqueType(
9606 const extra = local.getMutableExtra(gpa);9606 const extra = local.getMutableExtra(gpa);
9607 try items.ensureUnusedCapacity(1);9607 try items.ensureUnusedCapacity(1);
96089608
9609 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeOpaque).Struct.fields.len + switch (ini.key) {9609 try extra.ensureUnusedCapacity(@typeInfo(Tag.TypeOpaque).@"struct".fields.len + switch (ini.key) {
9610 .declared => |d| d.captures.len,9610 .declared => |d| d.captures.len,
9611 .reified => 0,9611 .reified => 0,
9612 });9612 });
...@@ -9740,14 +9740,14 @@ fn addInt(...@@ -9740,14 +9740,14 @@ fn addInt(
9740}9740}
97419741
9742fn addExtra(extra: Local.Extra.Mutable, item: anytype) Allocator.Error!u32 {9742fn addExtra(extra: Local.Extra.Mutable, item: anytype) Allocator.Error!u32 {
9743 const fields = @typeInfo(@TypeOf(item)).Struct.fields;9743 const fields = @typeInfo(@TypeOf(item)).@"struct".fields;
9744 try extra.ensureUnusedCapacity(fields.len);9744 try extra.ensureUnusedCapacity(fields.len);
9745 return addExtraAssumeCapacity(extra, item);9745 return addExtraAssumeCapacity(extra, item);
9746}9746}
97479747
9748fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 {9748fn addExtraAssumeCapacity(extra: Local.Extra.Mutable, item: anytype) u32 {
9749 const result: u32 = extra.mutate.len;9749 const result: u32 = extra.mutate.len;
9750 inline for (@typeInfo(@TypeOf(item)).Struct.fields) |field| {9750 inline for (@typeInfo(@TypeOf(item)).@"struct".fields) |field| {
9751 extra.appendAssumeCapacity(.{switch (field.type) {9751 extra.appendAssumeCapacity(.{switch (field.type) {
9752 Index,9752 Index,
9753 Cau.Index,9753 Cau.Index,
...@@ -9791,7 +9791,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {...@@ -9791,7 +9791,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
9791 else => @compileError("unsupported host"),9791 else => @compileError("unsupported host"),
9792 }9792 }
9793 const result: u32 = @intCast(ip.limbs.items.len);9793 const result: u32 = @intCast(ip.limbs.items.len);
9794 inline for (@typeInfo(@TypeOf(extra)).Struct.fields, 0..) |field, i| {9794 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields, 0..) |field, i| {
9795 const new: u32 = switch (field.type) {9795 const new: u32 = switch (field.type) {
9796 u32 => @field(extra, field.name),9796 u32 => @field(extra, field.name),
9797 Index => @intFromEnum(@field(extra, field.name)),9797 Index => @intFromEnum(@field(extra, field.name)),
...@@ -9809,7 +9809,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {...@@ -9809,7 +9809,7 @@ fn addLimbsExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
9809fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { data: T, end: u32 } {9809fn extraDataTrail(extra: Local.Extra, comptime T: type, index: u32) struct { data: T, end: u32 } {
9810 const extra_items = extra.view().items(.@"0");9810 const extra_items = extra.view().items(.@"0");
9811 var result: T = undefined;9811 var result: T = undefined;
9812 const fields = @typeInfo(T).Struct.fields;9812 const fields = @typeInfo(T).@"struct".fields;
9813 inline for (fields, index..) |field, extra_index| {9813 inline for (fields, index..) |field, extra_index| {
9814 const extra_item = extra_items[extra_index];9814 const extra_item = extra_items[extra_index];
9815 @field(result, field.name) = switch (field.type) {9815 @field(result, field.name) = switch (field.type) {
...@@ -10268,7 +10268,7 @@ fn getCoercedFunc(...@@ -10268,7 +10268,7 @@ fn getCoercedFunc(
10268 const extra = local.getMutableExtra(gpa);10268 const extra = local.getMutableExtra(gpa);
1026910269
10270 const prev_extra_len = extra.mutate.len;10270 const prev_extra_len = extra.mutate.len;
10271 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncCoerced).Struct.fields.len);10271 try extra.ensureUnusedCapacity(@typeInfo(Tag.FuncCoerced).@"struct".fields.len);
1027210272
10273 const extra_index = addExtraAssumeCapacity(extra, Tag.FuncCoerced{10273 const extra_index = addExtraAssumeCapacity(extra, Tag.FuncCoerced{
10274 .ty = ty,10274 .ty = ty,
...@@ -10480,31 +10480,31 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {...@@ -10480,31 +10480,31 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {
10480 .type_inferred_error_set => 0,10480 .type_inferred_error_set => 0,
10481 .type_enum_explicit, .type_enum_nonexhaustive => b: {10481 .type_enum_explicit, .type_enum_nonexhaustive => b: {
10482 const info = extraData(extra_list, EnumExplicit, data);10482 const info = extraData(extra_list, EnumExplicit, data);
10483 var ints = @typeInfo(EnumExplicit).Struct.fields.len;10483 var ints = @typeInfo(EnumExplicit).@"struct".fields.len;
10484 if (info.zir_index == .none) ints += 1;10484 if (info.zir_index == .none) ints += 1;
10485 ints += if (info.captures_len != std.math.maxInt(u32))10485 ints += if (info.captures_len != std.math.maxInt(u32))
10486 info.captures_len10486 info.captures_len
10487 else10487 else
10488 @typeInfo(PackedU64).Struct.fields.len;10488 @typeInfo(PackedU64).@"struct".fields.len;
10489 ints += info.fields_len;10489 ints += info.fields_len;
10490 if (info.values_map != .none) ints += info.fields_len;10490 if (info.values_map != .none) ints += info.fields_len;
10491 break :b @sizeOf(u32) * ints;10491 break :b @sizeOf(u32) * ints;
10492 },10492 },
10493 .type_enum_auto => b: {10493 .type_enum_auto => b: {
10494 const info = extraData(extra_list, EnumAuto, data);10494 const info = extraData(extra_list, EnumAuto, data);
10495 const ints = @typeInfo(EnumAuto).Struct.fields.len + info.captures_len + info.fields_len;10495 const ints = @typeInfo(EnumAuto).@"struct".fields.len + info.captures_len + info.fields_len;
10496 break :b @sizeOf(u32) * ints;10496 break :b @sizeOf(u32) * ints;
10497 },10497 },
10498 .type_opaque => b: {10498 .type_opaque => b: {
10499 const info = extraData(extra_list, Tag.TypeOpaque, data);10499 const info = extraData(extra_list, Tag.TypeOpaque, data);
10500 const ints = @typeInfo(Tag.TypeOpaque).Struct.fields.len + info.captures_len;10500 const ints = @typeInfo(Tag.TypeOpaque).@"struct".fields.len + info.captures_len;
10501 break :b @sizeOf(u32) * ints;10501 break :b @sizeOf(u32) * ints;
10502 },10502 },
10503 .type_struct => b: {10503 .type_struct => b: {
10504 if (data == 0) break :b 0;10504 if (data == 0) break :b 0;
10505 const extra = extraDataTrail(extra_list, Tag.TypeStruct, data);10505 const extra = extraDataTrail(extra_list, Tag.TypeStruct, data);
10506 const info = extra.data;10506 const info = extra.data;
10507 var ints: usize = @typeInfo(Tag.TypeStruct).Struct.fields.len;10507 var ints: usize = @typeInfo(Tag.TypeStruct).@"struct".fields.len;
10508 if (info.flags.any_captures) {10508 if (info.flags.any_captures) {
10509 const captures_len = extra_items[extra.end];10509 const captures_len = extra_items[extra.end];
10510 ints += 1 + captures_len;10510 ints += 1 + captures_len;
...@@ -10535,7 +10535,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {...@@ -10535,7 +10535,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {
10535 extra_items[extra.end]10535 extra_items[extra.end]
10536 else10536 else
10537 0;10537 0;
10538 break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).Struct.fields.len +10538 break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).@"struct".fields.len +
10539 @intFromBool(extra.data.flags.any_captures) + captures_len +10539 @intFromBool(extra.data.flags.any_captures) + captures_len +
10540 extra.data.fields_len * 2);10540 extra.data.fields_len * 2);
10541 },10541 },
...@@ -10545,7 +10545,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {...@@ -10545,7 +10545,7 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void {
10545 extra_items[extra.end]10545 extra_items[extra.end]
10546 else10546 else
10547 0;10547 0;
10548 break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).Struct.fields.len +10548 break :b @sizeOf(u32) * (@typeInfo(Tag.TypeStructPacked).@"struct".fields.len +
10549 @intFromBool(extra.data.flags.any_captures) + captures_len +10549 @intFromBool(extra.data.flags.any_captures) + captures_len +
10550 extra.data.fields_len * 3);10550 extra.data.fields_len * 3);
10551 },10551 },
...@@ -11627,7 +11627,7 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois...@@ -11627,7 +11627,7 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
11627 .c_ulong_type,11627 .c_ulong_type,
11628 .c_longlong_type,11628 .c_longlong_type,
11629 .c_ulonglong_type,11629 .c_ulonglong_type,
11630 => .Int,11630 => .int,
1163111631
11632 .c_longdouble_type,11632 .c_longdouble_type,
11633 .f16_type,11633 .f16_type,
...@@ -11635,20 +11635,20 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois...@@ -11635,20 +11635,20 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
11635 .f64_type,11635 .f64_type,
11636 .f80_type,11636 .f80_type,
11637 .f128_type,11637 .f128_type,
11638 => .Float,11638 => .float,
1163911639
11640 .anyopaque_type => .Opaque,11640 .anyopaque_type => .@"opaque",
11641 .bool_type => .Bool,11641 .bool_type => .bool,
11642 .void_type => .Void,11642 .void_type => .void,
11643 .type_type => .Type,11643 .type_type => .type,
11644 .anyerror_type, .adhoc_inferred_error_set_type => .ErrorSet,11644 .anyerror_type, .adhoc_inferred_error_set_type => .error_set,
11645 .comptime_int_type => .ComptimeInt,11645 .comptime_int_type => .comptime_int,
11646 .comptime_float_type => .ComptimeFloat,11646 .comptime_float_type => .comptime_float,
11647 .noreturn_type => .NoReturn,11647 .noreturn_type => .noreturn,
11648 .anyframe_type => .AnyFrame,11648 .anyframe_type => .@"anyframe",
11649 .null_type => .Null,11649 .null_type => .null,
11650 .undefined_type => .Undefined,11650 .undefined_type => .undefined,
11651 .enum_literal_type => .EnumLiteral,11651 .enum_literal_type => .enum_literal,
1165211652
11653 .manyptr_u8_type,11653 .manyptr_u8_type,
11654 .manyptr_const_u8_type,11654 .manyptr_const_u8_type,
...@@ -11656,11 +11656,11 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois...@@ -11656,11 +11656,11 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
11656 .single_const_pointer_to_comptime_int_type,11656 .single_const_pointer_to_comptime_int_type,
11657 .slice_const_u8_type,11657 .slice_const_u8_type,
11658 .slice_const_u8_sentinel_0_type,11658 .slice_const_u8_sentinel_0_type,
11659 => .Pointer,11659 => .pointer,
1166011660
11661 .optional_noreturn_type => .Optional,11661 .optional_noreturn_type => .optional,
11662 .anyerror_void_error_union_type => .ErrorUnion,11662 .anyerror_void_error_union_type => .error_union,
11663 .empty_struct_type => .Struct,11663 .empty_struct_type => .@"struct",
1166411664
11665 .generic_poison_type => return error.GenericPoison,11665 .generic_poison_type => return error.GenericPoison,
1166611666
...@@ -11687,48 +11687,48 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois...@@ -11687,48 +11687,48 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois
1168711687
11688 .type_int_signed,11688 .type_int_signed,
11689 .type_int_unsigned,11689 .type_int_unsigned,
11690 => .Int,11690 => .int,
1169111691
11692 .type_array_big,11692 .type_array_big,
11693 .type_array_small,11693 .type_array_small,
11694 => .Array,11694 => .array,
1169511695
11696 .type_vector => .Vector,11696 .type_vector => .vector,
1169711697
11698 .type_pointer,11698 .type_pointer,
11699 .type_slice,11699 .type_slice,
11700 => .Pointer,11700 => .pointer,
1170111701
11702 .type_optional => .Optional,11702 .type_optional => .optional,
11703 .type_anyframe => .AnyFrame,11703 .type_anyframe => .@"anyframe",
1170411704
11705 .type_error_union,11705 .type_error_union,
11706 .type_anyerror_union,11706 .type_anyerror_union,
11707 => .ErrorUnion,11707 => .error_union,
1170811708
11709 .type_error_set,11709 .type_error_set,
11710 .type_inferred_error_set,11710 .type_inferred_error_set,
11711 => .ErrorSet,11711 => .error_set,
1171211712
11713 .type_enum_auto,11713 .type_enum_auto,
11714 .type_enum_explicit,11714 .type_enum_explicit,
11715 .type_enum_nonexhaustive,11715 .type_enum_nonexhaustive,
11716 => .Enum,11716 => .@"enum",
1171711717
11718 .simple_type => unreachable, // handled via Index tag above11718 .simple_type => unreachable, // handled via Index tag above
1171911719
11720 .type_opaque => .Opaque,11720 .type_opaque => .@"opaque",
1172111721
11722 .type_struct,11722 .type_struct,
11723 .type_struct_anon,11723 .type_struct_anon,
11724 .type_struct_packed,11724 .type_struct_packed,
11725 .type_struct_packed_inits,11725 .type_struct_packed_inits,
11726 .type_tuple_anon,11726 .type_tuple_anon,
11727 => .Struct,11727 => .@"struct",
1172811728
11729 .type_union => .Union,11729 .type_union => .@"union",
1173011730
11731 .type_function => .Fn,11731 .type_function => .@"fn",
1173211732
11733 // values, not types11733 // values, not types
11734 .undef,11734 .undef,
...@@ -11919,8 +11919,8 @@ fn funcIesResolvedPtr(ip: *InternPool, func_index: Index) *Index {...@@ -11919,8 +11919,8 @@ fn funcIesResolvedPtr(ip: *InternPool, func_index: Index) *Index {
11919 const func_extra = unwrapped_func.getExtra(ip);11919 const func_extra = unwrapped_func.getExtra(ip);
11920 const func_item = unwrapped_func.getItem(ip);11920 const func_item = unwrapped_func.getItem(ip);
11921 const extra_index = switch (func_item.tag) {11921 const extra_index = switch (func_item.tag) {
11922 .func_decl => func_item.data + @typeInfo(Tag.FuncDecl).Struct.fields.len,11922 .func_decl => func_item.data + @typeInfo(Tag.FuncDecl).@"struct".fields.len,
11923 .func_instance => func_item.data + @typeInfo(Tag.FuncInstance).Struct.fields.len,11923 .func_instance => func_item.data + @typeInfo(Tag.FuncInstance).@"struct".fields.len,
11924 .func_coerced => {11924 .func_coerced => {
11925 const uncoerced_func_index: Index = @enumFromInt(func_extra.view().items(.@"0")[11925 const uncoerced_func_index: Index = @enumFromInt(func_extra.view().items(.@"0")[
11926 func_item.data + std.meta.fieldIndex(Tag.FuncCoerced, "func").?11926 func_item.data + std.meta.fieldIndex(Tag.FuncCoerced, "func").?
...@@ -11929,8 +11929,8 @@ fn funcIesResolvedPtr(ip: *InternPool, func_index: Index) *Index {...@@ -11929,8 +11929,8 @@ fn funcIesResolvedPtr(ip: *InternPool, func_index: Index) *Index {
11929 const uncoerced_func_item = unwrapped_uncoerced_func.getItem(ip);11929 const uncoerced_func_item = unwrapped_uncoerced_func.getItem(ip);
11930 return @ptrCast(&unwrapped_uncoerced_func.getExtra(ip).view().items(.@"0")[11930 return @ptrCast(&unwrapped_uncoerced_func.getExtra(ip).view().items(.@"0")[
11931 switch (uncoerced_func_item.tag) {11931 switch (uncoerced_func_item.tag) {
11932 .func_decl => uncoerced_func_item.data + @typeInfo(Tag.FuncDecl).Struct.fields.len,11932 .func_decl => uncoerced_func_item.data + @typeInfo(Tag.FuncDecl).@"struct".fields.len,
11933 .func_instance => uncoerced_func_item.data + @typeInfo(Tag.FuncInstance).Struct.fields.len,11933 .func_instance => uncoerced_func_item.data + @typeInfo(Tag.FuncInstance).@"struct".fields.len,
11934 else => unreachable,11934 else => unreachable,
11935 }11935 }
11936 ]);11936 ]);
src/Package/Fetch.zig+2-2
...@@ -325,7 +325,7 @@ pub fn run(f: *Fetch) RunError!void {...@@ -325,7 +325,7 @@ pub fn run(f: *Fetch) RunError!void {
325 // "p/$hash/foo", with possibly more directories after "foo".325 // "p/$hash/foo", with possibly more directories after "foo".
326 // We want to fail unless the resolved relative path has a326 // We want to fail unless the resolved relative path has a
327 // prefix of "p/$hash/".327 // prefix of "p/$hash/".
328 const digest_len = @typeInfo(Manifest.MultiHashHexDigest).Array.len;328 const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len;
329 const prefix_len: usize = if (f.job_queue.read_only) 0 else "p/".len;329 const prefix_len: usize = if (f.job_queue.read_only) 0 else "p/".len;
330 const expected_prefix = f.parent_package_root.sub_path[0 .. prefix_len + digest_len];330 const expected_prefix = f.parent_package_root.sub_path[0 .. prefix_len + digest_len];
331 if (!std.mem.startsWith(u8, pkg_root.sub_path, expected_prefix)) {331 if (!std.mem.startsWith(u8, pkg_root.sub_path, expected_prefix)) {
...@@ -670,7 +670,7 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {...@@ -670,7 +670,7 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
670 .url = url,670 .url = url,
671 .hash = h: {671 .hash = h: {
672 const h = dep.hash orelse break :h null;672 const h = dep.hash orelse break :h null;
673 const digest_len = @typeInfo(Manifest.MultiHashHexDigest).Array.len;673 const digest_len = @typeInfo(Manifest.MultiHashHexDigest).array.len;
674 const multihash_digest = h[0..digest_len].*;674 const multihash_digest = h[0..digest_len].*;
675 const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);675 const gop = f.job_queue.table.getOrPutAssumeCapacity(multihash_digest);
676 if (gop.found_existing) continue;676 if (gop.found_existing) continue;
src/Sema.zig+971-971
...@@ -1783,7 +1783,7 @@ fn analyzeBodyInner(...@@ -1783,7 +1783,7 @@ fn analyzeBodyInner(
1783 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);1783 const inline_body = sema.code.bodySlice(extra.end, extra.data.body_len);
1784 const err_union = try sema.resolveInst(extra.data.operand);1784 const err_union = try sema.resolveInst(extra.data.operand);
1785 const err_union_ty = sema.typeOf(err_union);1785 const err_union_ty = sema.typeOf(err_union);
1786 if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) {1786 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
1787 return sema.fail(block, operand_src, "expected error union type, found '{}'", .{1787 return sema.fail(block, operand_src, "expected error union type, found '{}'", .{
1788 err_union_ty.fmt(pt),1788 err_union_ty.fmt(pt),
1789 });1789 });
...@@ -1985,14 +1985,14 @@ fn resolveDestType(...@@ -1985,14 +1985,14 @@ fn resolveDestType(
1985 else => |e| return e,1985 else => |e| return e,
1986 };1986 };
19871987
1988 if (remove_eu and raw_ty.zigTypeTag(zcu) == .ErrorUnion) {1988 if (remove_eu and raw_ty.zigTypeTag(zcu) == .error_union) {
1989 const eu_child = raw_ty.errorUnionPayload(zcu);1989 const eu_child = raw_ty.errorUnionPayload(zcu);
1990 if (remove_opt and eu_child.zigTypeTag(zcu) == .Optional) {1990 if (remove_opt and eu_child.zigTypeTag(zcu) == .optional) {
1991 return eu_child.childType(zcu);1991 return eu_child.childType(zcu);
1992 }1992 }
1993 return eu_child;1993 return eu_child;
1994 }1994 }
1995 if (remove_opt and raw_ty.zigTypeTag(zcu) == .Optional) {1995 if (remove_opt and raw_ty.zigTypeTag(zcu) == .optional) {
1996 return raw_ty.childType(zcu);1996 return raw_ty.childType(zcu);
1997 }1997 }
1998 return raw_ty;1998 return raw_ty;
...@@ -2280,7 +2280,7 @@ fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non...@@ -2280,7 +2280,7 @@ fn failWithExpectedOptionalType(sema: *Sema, block: *Block, src: LazySrcLoc, non
2280 non_optional_ty.fmt(pt),2280 non_optional_ty.fmt(pt),
2281 });2281 });
2282 errdefer msg.destroy(sema.gpa);2282 errdefer msg.destroy(sema.gpa);
2283 if (non_optional_ty.zigTypeTag(pt.zcu) == .ErrorUnion) {2283 if (non_optional_ty.zigTypeTag(pt.zcu) == .error_union) {
2284 try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{});2284 try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{});
2285 }2285 }
2286 try addDeclaredHereNote(sema, msg, non_optional_ty);2286 try addDeclaredHereNote(sema, msg, non_optional_ty);
...@@ -2327,7 +2327,7 @@ fn failWithErrorSetCodeMissing(...@@ -2327,7 +2327,7 @@ fn failWithErrorSetCodeMissing(
2327fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value, vector_index: usize) CompileError {2327fn failWithIntegerOverflow(sema: *Sema, block: *Block, src: LazySrcLoc, int_ty: Type, val: Value, vector_index: usize) CompileError {
2328 const pt = sema.pt;2328 const pt = sema.pt;
2329 const zcu = pt.zcu;2329 const zcu = pt.zcu;
2330 if (int_ty.zigTypeTag(zcu) == .Vector) {2330 if (int_ty.zigTypeTag(zcu) == .vector) {
2331 const msg = msg: {2331 const msg = msg: {
2332 const msg = try sema.errMsg(src, "overflow of vector type '{}' with value '{}'", .{2332 const msg = try sema.errMsg(src, "overflow of vector type '{}' with value '{}'", .{
2333 int_ty.fmt(pt), val.fmtValueSema(pt, sema),2333 int_ty.fmt(pt), val.fmtValueSema(pt, sema),
...@@ -2380,7 +2380,7 @@ fn failWithInvalidFieldAccess(...@@ -2380,7 +2380,7 @@ fn failWithInvalidFieldAccess(
2380 const zcu = pt.zcu;2380 const zcu = pt.zcu;
2381 const inner_ty = if (object_ty.isSinglePointer(zcu)) object_ty.childType(zcu) else object_ty;2381 const inner_ty = if (object_ty.isSinglePointer(zcu)) object_ty.childType(zcu) else object_ty;
23822382
2383 if (inner_ty.zigTypeTag(zcu) == .Optional) opt: {2383 if (inner_ty.zigTypeTag(zcu) == .optional) opt: {
2384 const child_ty = inner_ty.optionalChild(zcu);2384 const child_ty = inner_ty.optionalChild(zcu);
2385 if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :opt;2385 if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :opt;
2386 const msg = msg: {2386 const msg = msg: {
...@@ -2390,7 +2390,7 @@ fn failWithInvalidFieldAccess(...@@ -2390,7 +2390,7 @@ fn failWithInvalidFieldAccess(
2390 break :msg msg;2390 break :msg msg;
2391 };2391 };
2392 return sema.failWithOwnedErrorMsg(block, msg);2392 return sema.failWithOwnedErrorMsg(block, msg);
2393 } else if (inner_ty.zigTypeTag(zcu) == .ErrorUnion) err: {2393 } else if (inner_ty.zigTypeTag(zcu) == .error_union) err: {
2394 const child_ty = inner_ty.errorUnionPayload(zcu);2394 const child_ty = inner_ty.errorUnionPayload(zcu);
2395 if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :err;2395 if (!typeSupportsFieldAccess(zcu, child_ty, field_name)) break :err;
2396 const msg = msg: {2396 const msg = msg: {
...@@ -2407,16 +2407,16 @@ fn failWithInvalidFieldAccess(...@@ -2407,16 +2407,16 @@ fn failWithInvalidFieldAccess(
2407fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.NullTerminatedString) bool {2407fn typeSupportsFieldAccess(zcu: *const Zcu, ty: Type, field_name: InternPool.NullTerminatedString) bool {
2408 const ip = &zcu.intern_pool;2408 const ip = &zcu.intern_pool;
2409 switch (ty.zigTypeTag(zcu)) {2409 switch (ty.zigTypeTag(zcu)) {
2410 .Array => return field_name.eqlSlice("len", ip),2410 .array => return field_name.eqlSlice("len", ip),
2411 .Pointer => {2411 .pointer => {
2412 const ptr_info = ty.ptrInfo(zcu);2412 const ptr_info = ty.ptrInfo(zcu);
2413 if (ptr_info.flags.size == .Slice) {2413 if (ptr_info.flags.size == .Slice) {
2414 return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip);2414 return field_name.eqlSlice("ptr", ip) or field_name.eqlSlice("len", ip);
2415 } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Array) {2415 } else if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
2416 return field_name.eqlSlice("len", ip);2416 return field_name.eqlSlice("len", ip);
2417 } else return false;2417 } else return false;
2418 },2418 },
2419 .Type, .Struct, .Union => return true,2419 .type, .@"struct", .@"union" => return true,
2420 else => return false,2420 else => return false,
2421 }2421 }
2422}2422}
...@@ -3384,9 +3384,9 @@ fn ensureResultUsed(...@@ -3384,9 +3384,9 @@ fn ensureResultUsed(
3384 const pt = sema.pt;3384 const pt = sema.pt;
3385 const zcu = pt.zcu;3385 const zcu = pt.zcu;
3386 switch (ty.zigTypeTag(zcu)) {3386 switch (ty.zigTypeTag(zcu)) {
3387 .Void, .NoReturn => return,3387 .void, .noreturn => return,
3388 .ErrorSet => return sema.fail(block, src, "error set is ignored", .{}),3388 .error_set => return sema.fail(block, src, "error set is ignored", .{}),
3389 .ErrorUnion => {3389 .error_union => {
3390 const msg = msg: {3390 const msg = msg: {
3391 const msg = try sema.errMsg(src, "error union is ignored", .{});3391 const msg = try sema.errMsg(src, "error union is ignored", .{});
3392 errdefer msg.destroy(sema.gpa);3392 errdefer msg.destroy(sema.gpa);
...@@ -3419,8 +3419,8 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -3419,8 +3419,8 @@ fn zirEnsureResultNonError(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
3419 const src = block.nodeOffset(inst_data.src_node);3419 const src = block.nodeOffset(inst_data.src_node);
3420 const operand_ty = sema.typeOf(operand);3420 const operand_ty = sema.typeOf(operand);
3421 switch (operand_ty.zigTypeTag(zcu)) {3421 switch (operand_ty.zigTypeTag(zcu)) {
3422 .ErrorSet => return sema.fail(block, src, "error set is discarded", .{}),3422 .error_set => return sema.fail(block, src, "error set is discarded", .{}),
3423 .ErrorUnion => {3423 .error_union => {
3424 const msg = msg: {3424 const msg = msg: {
3425 const msg = try sema.errMsg(src, "error union is discarded", .{});3425 const msg = try sema.errMsg(src, "error union is discarded", .{});
3426 errdefer msg.destroy(sema.gpa);3426 errdefer msg.destroy(sema.gpa);
...@@ -3443,13 +3443,13 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index...@@ -3443,13 +3443,13 @@ fn zirEnsureErrUnionPayloadVoid(sema: *Sema, block: *Block, inst: Zir.Inst.Index
3443 const src = block.nodeOffset(inst_data.src_node);3443 const src = block.nodeOffset(inst_data.src_node);
3444 const operand = try sema.resolveInst(inst_data.operand);3444 const operand = try sema.resolveInst(inst_data.operand);
3445 const operand_ty = sema.typeOf(operand);3445 const operand_ty = sema.typeOf(operand);
3446 const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .Pointer)3446 const err_union_ty = if (operand_ty.zigTypeTag(zcu) == .pointer)
3447 operand_ty.childType(zcu)3447 operand_ty.childType(zcu)
3448 else3448 else
3449 operand_ty;3449 operand_ty;
3450 if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) return;3450 if (err_union_ty.zigTypeTag(zcu) != .error_union) return;
3451 const payload_ty = err_union_ty.errorUnionPayload(zcu).zigTypeTag(zcu);3451 const payload_ty = err_union_ty.errorUnionPayload(zcu).zigTypeTag(zcu);
3452 if (payload_ty != .Void and payload_ty != .NoReturn) {3452 if (payload_ty != .void and payload_ty != .noreturn) {
3453 const msg = msg: {3453 const msg = msg: {
3454 const msg = try sema.errMsg(src, "error union payload is ignored", .{});3454 const msg = try sema.errMsg(src, "error union payload is ignored", .{});
3455 errdefer msg.destroy(sema.gpa);3455 errdefer msg.destroy(sema.gpa);
...@@ -4198,7 +4198,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com...@@ -4198,7 +4198,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com
4198 _ = try replacement_block.addBr(placeholder_inst, .void_value);4198 _ = try replacement_block.addBr(placeholder_inst, .void_value);
4199 try sema.air_extra.ensureUnusedCapacity(4199 try sema.air_extra.ensureUnusedCapacity(
4200 gpa,4200 gpa,
4201 @typeInfo(Air.Block).Struct.fields.len + replacement_block.instructions.items.len,4201 @typeInfo(Air.Block).@"struct".fields.len + replacement_block.instructions.items.len,
4202 );4202 );
4203 sema.air_instructions.set(@intFromEnum(placeholder_inst), .{4203 sema.air_instructions.set(@intFromEnum(placeholder_inst), .{
4204 .tag = .block,4204 .tag = .block,
...@@ -4244,7 +4244,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4244,7 +4244,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
4244 // Each arg could be an indexable, or a range, in which case the length4244 // Each arg could be an indexable, or a range, in which case the length
4245 // is passed directly as an integer.4245 // is passed directly as an integer.
4246 const is_int = switch (object_ty.zigTypeTag(zcu)) {4246 const is_int = switch (object_ty.zigTypeTag(zcu)) {
4247 .Int, .ComptimeInt => true,4247 .int, .comptime_int => true,
4248 else => false,4248 else => false,
4249 };4249 };
4250 const arg_src = block.src(.{ .for_input = .{4250 const arg_src = block.src(.{ .for_input = .{
...@@ -4259,7 +4259,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4259,7 +4259,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
4259 errdefer msg.destroy(sema.gpa);4259 errdefer msg.destroy(sema.gpa);
4260 try sema.errNote(arg_src, msg, "for loop operand must be a range, array, slice, tuple, or vector", .{});4260 try sema.errNote(arg_src, msg, "for loop operand must be a range, array, slice, tuple, or vector", .{});
42614261
4262 if (object_ty.zigTypeTag(zcu) == .ErrorUnion) {4262 if (object_ty.zigTypeTag(zcu) == .error_union) {
4263 try sema.errNote(arg_src, msg, "consider using 'try', 'catch', or 'if'", .{});4263 try sema.errNote(arg_src, msg, "consider using 'try', 'catch', or 'if'", .{});
4264 }4264 }
42654265
...@@ -4319,7 +4319,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -4319,7 +4319,7 @@ fn zirForLen(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
4319 // Each arg could be an indexable, or a range, in which case the length4319 // Each arg could be an indexable, or a range, in which case the length
4320 // is passed directly as an integer.4320 // is passed directly as an integer.
4321 switch (object_ty.zigTypeTag(zcu)) {4321 switch (object_ty.zigTypeTag(zcu)) {
4322 .Int, .ComptimeInt => continue,4322 .int, .comptime_int => continue,
4323 else => {},4323 else => {},
4324 }4324 }
4325 const arg_src = block.src(.{ .for_input = .{4325 const arg_src = block.src(.{ .for_input = .{
...@@ -4357,8 +4357,8 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL...@@ -4357,8 +4357,8 @@ fn optEuBasePtrInit(sema: *Sema, block: *Block, ptr: Air.Inst.Ref, src: LazySrcL
4357 const zcu = pt.zcu;4357 const zcu = pt.zcu;
4358 var base_ptr = ptr;4358 var base_ptr = ptr;
4359 while (true) switch (sema.typeOf(base_ptr).childType(zcu).zigTypeTag(zcu)) {4359 while (true) switch (sema.typeOf(base_ptr).childType(zcu).zigTypeTag(zcu)) {
4360 .ErrorUnion => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true),4360 .error_union => base_ptr = try sema.analyzeErrUnionPayloadPtr(block, src, base_ptr, false, true),
4361 .Optional => base_ptr = try sema.analyzeOptionalPayloadPtr(block, src, base_ptr, false, true),4361 .optional => base_ptr = try sema.analyzeOptionalPayloadPtr(block, src, base_ptr, false, true),
4362 else => break,4362 else => break,
4363 };4363 };
4364 try sema.checkKnownAllocPtr(block, ptr, base_ptr);4364 try sema.checkKnownAllocPtr(block, ptr, base_ptr);
...@@ -4383,12 +4383,12 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -4383,12 +4383,12 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4383 else => |e| return e,4383 else => |e| return e,
4384 };4384 };
4385 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);4385 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);
4386 assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction4386 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
4387 const elem_ty = ptr_ty.childType(zcu);4387 const elem_ty = ptr_ty.childType(zcu);
4388 switch (ptr_ty.ptrSize(zcu)) {4388 switch (ptr_ty.ptrSize(zcu)) {
4389 .One => {4389 .One => {
4390 const uncoerced_ty = sema.typeOf(uncoerced_val);4390 const uncoerced_ty = sema.typeOf(uncoerced_val);
4391 if (elem_ty.zigTypeTag(zcu) == .Array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) {4391 if (elem_ty.zigTypeTag(zcu) == .array and elem_ty.childType(zcu).toIntern() == uncoerced_ty.toIntern()) {
4392 // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion.4392 // We're trying to initialize a *[1]T with a reference to a T - don't perform any coercion.
4393 return uncoerced_val;4393 return uncoerced_val;
4394 }4394 }
...@@ -4403,7 +4403,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -4403,7 +4403,7 @@ fn zirCoercePtrElemTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
4403 // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`.4403 // Our goal is to coerce `uncoerced_val` to an array of `elem_ty`.
4404 const val_ty = sema.typeOf(uncoerced_val);4404 const val_ty = sema.typeOf(uncoerced_val);
4405 switch (val_ty.zigTypeTag(zcu)) {4405 switch (val_ty.zigTypeTag(zcu)) {
4406 .Array, .Vector => {},4406 .array, .vector => {},
4407 else => if (!val_ty.isTuple(zcu)) {4407 else => if (!val_ty.isTuple(zcu)) {
4408 return sema.fail(block, src, "expected array of '{}', found '{}'", .{ elem_ty.fmt(pt), val_ty.fmt(pt) });4408 return sema.fail(block, src, "expected array of '{}', found '{}'", .{ elem_ty.fmt(pt), val_ty.fmt(pt) });
4409 },4409 },
...@@ -4439,7 +4439,7 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -4439,7 +4439,7 @@ fn zirValidateRefTy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
4439 else => |e| return e,4439 else => |e| return e,
4440 };4440 };
4441 if (ty_operand.isGenericPoison()) return;4441 if (ty_operand.isGenericPoison()) return;
4442 if (ty_operand.optEuBaseType(zcu).zigTypeTag(zcu) != .Pointer) {4442 if (ty_operand.optEuBaseType(zcu).zigTypeTag(zcu) != .pointer) {
4443 return sema.failWithOwnedErrorMsg(block, msg: {4443 return sema.failWithOwnedErrorMsg(block, msg: {
4444 const msg = try sema.errMsg(src, "expected type '{}', found pointer", .{ty_operand.fmt(pt)});4444 const msg = try sema.errMsg(src, "expected type '{}', found pointer", .{ty_operand.fmt(pt)});
4445 errdefer msg.destroy(sema.gpa);4445 errdefer msg.destroy(sema.gpa);
...@@ -4464,7 +4464,7 @@ fn zirValidateArrayInitRefTy(...@@ -4464,7 +4464,7 @@ fn zirValidateArrayInitRefTy(
4464 else => |e| return e,4464 else => |e| return e,
4465 };4465 };
4466 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);4466 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);
4467 assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction4467 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
4468 switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) {4468 switch (zcu.intern_pool.indexToKey(ptr_ty.toIntern())) {
4469 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {4469 .ptr_type => |ptr_type| switch (ptr_type.flags.size) {
4470 .Slice, .Many => {4470 .Slice, .Many => {
...@@ -4523,7 +4523,7 @@ fn validateArrayInitTy(...@@ -4523,7 +4523,7 @@ fn validateArrayInitTy(
4523 const pt = sema.pt;4523 const pt = sema.pt;
4524 const zcu = pt.zcu;4524 const zcu = pt.zcu;
4525 switch (ty.zigTypeTag(zcu)) {4525 switch (ty.zigTypeTag(zcu)) {
4526 .Array => {4526 .array => {
4527 const array_len = ty.arrayLen(zcu);4527 const array_len = ty.arrayLen(zcu);
4528 if (init_count != array_len) {4528 if (init_count != array_len) {
4529 return sema.fail(block, src, "expected {d} array elements; found {d}", .{4529 return sema.fail(block, src, "expected {d} array elements; found {d}", .{
...@@ -4532,7 +4532,7 @@ fn validateArrayInitTy(...@@ -4532,7 +4532,7 @@ fn validateArrayInitTy(
4532 }4532 }
4533 return;4533 return;
4534 },4534 },
4535 .Vector => {4535 .vector => {
4536 const array_len = ty.arrayLen(zcu);4536 const array_len = ty.arrayLen(zcu);
4537 if (init_count != array_len) {4537 if (init_count != array_len) {
4538 return sema.fail(block, src, "expected {d} vector elements; found {d}", .{4538 return sema.fail(block, src, "expected {d} vector elements; found {d}", .{
...@@ -4541,7 +4541,7 @@ fn validateArrayInitTy(...@@ -4541,7 +4541,7 @@ fn validateArrayInitTy(
4541 }4541 }
4542 return;4542 return;
4543 },4543 },
4544 .Struct => if (ty.isTuple(zcu)) {4544 .@"struct" => if (ty.isTuple(zcu)) {
4545 try ty.resolveFields(pt);4545 try ty.resolveFields(pt);
4546 const array_len = ty.arrayLen(zcu);4546 const array_len = ty.arrayLen(zcu);
4547 if (init_count > array_len) {4547 if (init_count > array_len) {
...@@ -4574,7 +4574,7 @@ fn zirValidateStructInitTy(...@@ -4574,7 +4574,7 @@ fn zirValidateStructInitTy(
4574 const struct_ty = if (is_result_ty) ty.optEuBaseType(zcu) else ty;4574 const struct_ty = if (is_result_ty) ty.optEuBaseType(zcu) else ty;
45754575
4576 switch (struct_ty.zigTypeTag(zcu)) {4576 switch (struct_ty.zigTypeTag(zcu)) {
4577 .Struct, .Union => return,4577 .@"struct", .@"union" => return,
4578 else => {},4578 else => {},
4579 }4579 }
4580 return sema.failWithStructInitNotSupported(block, src, struct_ty);4580 return sema.failWithStructInitNotSupported(block, src, struct_ty);
...@@ -4599,13 +4599,13 @@ fn zirValidatePtrStructInit(...@@ -4599,13 +4599,13 @@ fn zirValidatePtrStructInit(
4599 const object_ptr = try sema.resolveInst(field_ptr_extra.lhs);4599 const object_ptr = try sema.resolveInst(field_ptr_extra.lhs);
4600 const agg_ty = sema.typeOf(object_ptr).childType(zcu).optEuBaseType(zcu);4600 const agg_ty = sema.typeOf(object_ptr).childType(zcu).optEuBaseType(zcu);
4601 switch (agg_ty.zigTypeTag(zcu)) {4601 switch (agg_ty.zigTypeTag(zcu)) {
4602 .Struct => return sema.validateStructInit(4602 .@"struct" => return sema.validateStructInit(
4603 block,4603 block,
4604 agg_ty,4604 agg_ty,
4605 init_src,4605 init_src,
4606 instrs,4606 instrs,
4607 ),4607 ),
4608 .Union => return sema.validateUnionInit(4608 .@"union" => return sema.validateUnionInit(
4609 block,4609 block,
4610 agg_ty,4610 agg_ty,
4611 init_src,4611 init_src,
...@@ -5084,7 +5084,7 @@ fn zirValidatePtrArrayInit(...@@ -5084,7 +5084,7 @@ fn zirValidatePtrArrayInit(
5084 );5084 );
50855085
5086 if (instrs.len != array_len) switch (array_ty.zigTypeTag(zcu)) {5086 if (instrs.len != array_len) switch (array_ty.zigTypeTag(zcu)) {
5087 .Struct => {5087 .@"struct" => {
5088 var root_msg: ?*Zcu.ErrorMsg = null;5088 var root_msg: ?*Zcu.ErrorMsg = null;
5089 errdefer if (root_msg) |msg| msg.destroy(sema.gpa);5089 errdefer if (root_msg) |msg| msg.destroy(sema.gpa);
50905090
...@@ -5110,12 +5110,12 @@ fn zirValidatePtrArrayInit(...@@ -5110,12 +5110,12 @@ fn zirValidatePtrArrayInit(
5110 return sema.failWithOwnedErrorMsg(block, msg);5110 return sema.failWithOwnedErrorMsg(block, msg);
5111 }5111 }
5112 },5112 },
5113 .Array => {5113 .array => {
5114 return sema.fail(block, init_src, "expected {d} array elements; found {d}", .{5114 return sema.fail(block, init_src, "expected {d} array elements; found {d}", .{
5115 array_len, instrs.len,5115 array_len, instrs.len,
5116 });5116 });
5117 },5117 },
5118 .Vector => {5118 .vector => {
5119 return sema.fail(block, init_src, "expected {d} vector elements; found {d}", .{5119 return sema.fail(block, init_src, "expected {d} vector elements; found {d}", .{
5120 array_len, instrs.len,5120 array_len, instrs.len,
5121 });5121 });
...@@ -5277,7 +5277,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -5277,7 +5277,7 @@ fn zirValidateDeref(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErr
5277 const operand = try sema.resolveInst(inst_data.operand);5277 const operand = try sema.resolveInst(inst_data.operand);
5278 const operand_ty = sema.typeOf(operand);5278 const operand_ty = sema.typeOf(operand);
52795279
5280 if (operand_ty.zigTypeTag(zcu) != .Pointer) {5280 if (operand_ty.zigTypeTag(zcu) != .pointer) {
5281 return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)});5281 return sema.fail(block, src, "cannot dereference non-pointer type '{}'", .{operand_ty.fmt(pt)});
5282 } else switch (operand_ty.ptrSize(zcu)) {5282 } else switch (operand_ty.ptrSize(zcu)) {
5283 .One, .C => {},5283 .One, .C => {},
...@@ -5322,8 +5322,8 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -5322,8 +5322,8 @@ fn zirValidateDestructure(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
5322 const operand_ty = sema.typeOf(operand);5322 const operand_ty = sema.typeOf(operand);
53235323
5324 const can_destructure = switch (operand_ty.zigTypeTag(zcu)) {5324 const can_destructure = switch (operand_ty.zigTypeTag(zcu)) {
5325 .Array, .Vector => true,5325 .array, .vector => true,
5326 .Struct => operand_ty.isTuple(zcu),5326 .@"struct" => operand_ty.isTuple(zcu),
5327 else => false,5327 else => false,
5328 };5328 };
53295329
...@@ -5360,10 +5360,10 @@ fn failWithBadMemberAccess(...@@ -5360,10 +5360,10 @@ fn failWithBadMemberAccess(
5360 const zcu = pt.zcu;5360 const zcu = pt.zcu;
5361 const ip = &zcu.intern_pool;5361 const ip = &zcu.intern_pool;
5362 const kw_name = switch (agg_ty.zigTypeTag(zcu)) {5362 const kw_name = switch (agg_ty.zigTypeTag(zcu)) {
5363 .Union => "union",5363 .@"union" => "union",
5364 .Struct => "struct",5364 .@"struct" => "struct",
5365 .Opaque => "opaque",5365 .@"opaque" => "opaque",
5366 .Enum => "enum",5366 .@"enum" => "enum",
5367 else => unreachable,5367 else => unreachable,
5368 };5368 };
5369 if (agg_ty.typeDeclInst(zcu)) |inst| if ((inst.resolve(ip) orelse return error.AnalysisFail) == .main_struct_inst) {5369 if (agg_ty.typeDeclInst(zcu)) |inst| if ((inst.resolve(ip) orelse return error.AnalysisFail) == .main_struct_inst) {
...@@ -5432,10 +5432,10 @@ fn addDeclaredHereNote(sema: *Sema, parent: *Zcu.ErrorMsg, decl_ty: Type) !void...@@ -5432,10 +5432,10 @@ fn addDeclaredHereNote(sema: *Sema, parent: *Zcu.ErrorMsg, decl_ty: Type) !void
5432 const zcu = sema.pt.zcu;5432 const zcu = sema.pt.zcu;
5433 const src_loc = decl_ty.srcLocOrNull(zcu) orelse return;5433 const src_loc = decl_ty.srcLocOrNull(zcu) orelse return;
5434 const category = switch (decl_ty.zigTypeTag(zcu)) {5434 const category = switch (decl_ty.zigTypeTag(zcu)) {
5435 .Union => "union",5435 .@"union" => "union",
5436 .Struct => "struct",5436 .@"struct" => "struct",
5437 .Enum => "enum",5437 .@"enum" => "enum",
5438 .Opaque => "opaque",5438 .@"opaque" => "opaque",
5439 else => unreachable,5439 else => unreachable,
5440 };5440 };
5441 try sema.errNote(src_loc, parent, "{s} declared here", .{category});5441 try sema.errNote(src_loc, parent, "{s} declared here", .{category});
...@@ -5562,7 +5562,7 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v...@@ -5562,7 +5562,7 @@ fn zirStoreNode(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!v
5562 // Where %c is an error union or error set. In such case we need to add5562 // Where %c is an error union or error set. In such case we need to add
5563 // to the current function's inferred error set, if any.5563 // to the current function's inferred error set, if any.
5564 if (is_ret and sema.fn_ret_ty_ies != null) switch (sema.typeOf(operand).zigTypeTag(zcu)) {5564 if (is_ret and sema.fn_ret_ty_ies != null) switch (sema.typeOf(operand).zigTypeTag(zcu)) {
5565 .ErrorUnion, .ErrorSet => try sema.addToInferredErrorSet(operand),5565 .error_union, .error_set => try sema.addToInferredErrorSet(operand),
5566 else => {},5566 else => {},
5567 };5567 };
55685568
...@@ -5819,7 +5819,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError...@@ -5819,7 +5819,7 @@ fn zirLoop(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError
5819 } else {5819 } else {
5820 try child_block.instructions.append(gpa, loop_inst);5820 try child_block.instructions.append(gpa, loop_inst);
58215821
5822 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len + loop_block_len);5822 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len + loop_block_len);
5823 sema.air_instructions.items(.data)[@intFromEnum(loop_inst)].ty_pl.payload = sema.addExtraAssumeCapacity(5823 sema.air_instructions.items(.data)[@intFromEnum(loop_inst)].ty_pl.payload = sema.addExtraAssumeCapacity(
5824 Air.Block{ .body_len = @intCast(loop_block_len) },5824 Air.Block{ .body_len = @intCast(loop_block_len) },
5825 );5825 );
...@@ -6035,7 +6035,7 @@ fn resolveBlockBody(...@@ -6035,7 +6035,7 @@ fn resolveBlockBody(
6035 // We need a runtime block for scoping reasons.6035 // We need a runtime block for scoping reasons.
6036 _ = try child_block.addBr(merges.block_inst, .void_value);6036 _ = try child_block.addBr(merges.block_inst, .void_value);
6037 try parent_block.instructions.append(sema.gpa, merges.block_inst);6037 try parent_block.instructions.append(sema.gpa, merges.block_inst);
6038 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Block).Struct.fields.len +6038 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Block).@"struct".fields.len +
6039 child_block.instructions.items.len);6039 child_block.instructions.items.len);
6040 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{6040 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{
6041 .ty = .void_type,6041 .ty = .void_type,
...@@ -6111,7 +6111,7 @@ fn resolveAnalyzedBlock(...@@ -6111,7 +6111,7 @@ fn resolveAnalyzedBlock(
6111 .dbg_inline_block => {6111 .dbg_inline_block => {
6112 // Create a block containing all instruction from the body.6112 // Create a block containing all instruction from the body.
6113 try parent_block.instructions.append(gpa, merges.block_inst);6113 try parent_block.instructions.append(gpa, merges.block_inst);
6114 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).Struct.fields.len +6114 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".fields.len +
6115 child_block.instructions.items.len);6115 child_block.instructions.items.len);
6116 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{6116 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{
6117 .ty = .noreturn_type,6117 .ty = .noreturn_type,
...@@ -6149,7 +6149,7 @@ fn resolveAnalyzedBlock(...@@ -6149,7 +6149,7 @@ fn resolveAnalyzedBlock(
6149 try parent_block.instructions.append(gpa, merges.block_inst);6149 try parent_block.instructions.append(gpa, merges.block_inst);
6150 switch (block_tag) {6150 switch (block_tag) {
6151 .block => {6151 .block => {
6152 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +6152 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len +
6153 child_block.instructions.items.len);6153 child_block.instructions.items.len);
6154 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{6154 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{
6155 .ty = .void_type,6155 .ty = .void_type,
...@@ -6159,7 +6159,7 @@ fn resolveAnalyzedBlock(...@@ -6159,7 +6159,7 @@ fn resolveAnalyzedBlock(
6159 } };6159 } };
6160 },6160 },
6161 .dbg_inline_block => {6161 .dbg_inline_block => {
6162 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).Struct.fields.len +6162 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".fields.len +
6163 child_block.instructions.items.len);6163 child_block.instructions.items.len);
6164 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{6164 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{
6165 .ty = .void_type,6165 .ty = .void_type,
...@@ -6210,7 +6210,7 @@ fn resolveAnalyzedBlock(...@@ -6210,7 +6210,7 @@ fn resolveAnalyzedBlock(
6210 const ty_inst = Air.internedToRef(resolved_ty.toIntern());6210 const ty_inst = Air.internedToRef(resolved_ty.toIntern());
6211 switch (block_tag) {6211 switch (block_tag) {
6212 .block => {6212 .block => {
6213 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +6213 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len +
6214 child_block.instructions.items.len);6214 child_block.instructions.items.len);
6215 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{6215 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{
6216 .ty = ty_inst,6216 .ty = ty_inst,
...@@ -6220,7 +6220,7 @@ fn resolveAnalyzedBlock(...@@ -6220,7 +6220,7 @@ fn resolveAnalyzedBlock(
6220 } };6220 } };
6221 },6221 },
6222 .dbg_inline_block => {6222 .dbg_inline_block => {
6223 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).Struct.fields.len +6223 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.DbgInlineBlock).@"struct".fields.len +
6224 child_block.instructions.items.len);6224 child_block.instructions.items.len);
6225 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{6225 sema.air_instructions.items(.data)[@intFromEnum(merges.block_inst)] = .{ .ty_pl = .{
6226 .ty = ty_inst,6226 .ty = ty_inst,
...@@ -6257,7 +6257,7 @@ fn resolveAnalyzedBlock(...@@ -6257,7 +6257,7 @@ fn resolveAnalyzedBlock(
6257 // Convert the br instruction to a block instruction that has the coercion6257 // Convert the br instruction to a block instruction that has the coercion
6258 // and then a new br inside that returns the coerced instruction.6258 // and then a new br inside that returns the coerced instruction.
6259 const sub_block_len: u32 = @intCast(coerce_block.instructions.items.len + 1);6259 const sub_block_len: u32 = @intCast(coerce_block.instructions.items.len + 1);
6260 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +6260 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len +
6261 sub_block_len);6261 sub_block_len);
6262 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);6262 try sema.air_instructions.ensureUnusedCapacity(gpa, 1);
6263 const sub_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);6263 const sub_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);
...@@ -6306,7 +6306,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -6306,7 +6306,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
6306 const options = try sema.resolveExportOptions(block, options_src, extra.options);6306 const options = try sema.resolveExportOptions(block, options_src, extra.options);
63076307
6308 {6308 {
6309 if (ptr_ty.zigTypeTag(zcu) != .Pointer) {6309 if (ptr_ty.zigTypeTag(zcu) != .pointer) {
6310 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});6310 return sema.fail(block, ptr_src, "expected pointer type, found '{}'", .{ptr_ty.fmt(pt)});
6311 }6311 }
6312 const ptr_ty_info = ptr_ty.ptrInfo(zcu);6312 const ptr_ty_info = ptr_ty.ptrInfo(zcu);
...@@ -6856,7 +6856,7 @@ fn popErrorReturnTrace(...@@ -6856,7 +6856,7 @@ fn popErrorReturnTrace(
6856 // The result might be an error. If it is, we leave the error trace alone. If it isn't, we need6856 // The result might be an error. If it is, we leave the error trace alone. If it isn't, we need
6857 // to pop any error trace that may have been propagated from our arguments.6857 // to pop any error trace that may have been propagated from our arguments.
68586858
6859 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len);6859 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len);
6860 const cond_block_inst = try block.addInstAsIndex(.{6860 const cond_block_inst = try block.addInstAsIndex(.{
6861 .tag = .block,6861 .tag = .block,
6862 .data = .{6862 .data = .{
...@@ -6885,9 +6885,9 @@ fn popErrorReturnTrace(...@@ -6885,9 +6885,9 @@ fn popErrorReturnTrace(
6885 defer else_block.instructions.deinit(gpa);6885 defer else_block.instructions.deinit(gpa);
6886 _ = try else_block.addBr(cond_block_inst, .void_value);6886 _ = try else_block.addBr(cond_block_inst, .void_value);
68876887
6888 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +6888 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
6889 then_block.instructions.items.len + else_block.instructions.items.len +6889 then_block.instructions.items.len + else_block.instructions.items.len +
6890 @typeInfo(Air.Block).Struct.fields.len + 1); // +1 for the sole .cond_br instruction in the .block6890 @typeInfo(Air.Block).@"struct".fields.len + 1); // +1 for the sole .cond_br instruction in the .block
68916891
6892 const cond_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);6892 const cond_br_inst: Air.Inst.Index = @enumFromInt(sema.air_instructions.len);
6893 try sema.air_instructions.append(gpa, .{6893 try sema.air_instructions.append(gpa, .{
...@@ -7046,17 +7046,17 @@ fn checkCallArgumentCount(...@@ -7046,17 +7046,17 @@ fn checkCallArgumentCount(
7046 const zcu = pt.zcu;7046 const zcu = pt.zcu;
7047 const func_ty = func_ty: {7047 const func_ty = func_ty: {
7048 switch (callee_ty.zigTypeTag(zcu)) {7048 switch (callee_ty.zigTypeTag(zcu)) {
7049 .Fn => break :func_ty callee_ty,7049 .@"fn" => break :func_ty callee_ty,
7050 .Pointer => {7050 .pointer => {
7051 const ptr_info = callee_ty.ptrInfo(zcu);7051 const ptr_info = callee_ty.ptrInfo(zcu);
7052 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Fn) {7052 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
7053 break :func_ty Type.fromInterned(ptr_info.child);7053 break :func_ty Type.fromInterned(ptr_info.child);
7054 }7054 }
7055 },7055 },
7056 .Optional => {7056 .optional => {
7057 const opt_child = callee_ty.optionalChild(zcu);7057 const opt_child = callee_ty.optionalChild(zcu);
7058 if (opt_child.zigTypeTag(zcu) == .Fn or (opt_child.isSinglePointer(zcu) and7058 if (opt_child.zigTypeTag(zcu) == .@"fn" or (opt_child.isSinglePointer(zcu) and
7059 opt_child.childType(zcu).zigTypeTag(zcu) == .Fn))7059 opt_child.childType(zcu).zigTypeTag(zcu) == .@"fn"))
7060 {7060 {
7061 const msg = msg: {7061 const msg = msg: {
7062 const msg = try sema.errMsg(func_src, "cannot call optional type '{}'", .{7062 const msg = try sema.errMsg(func_src, "cannot call optional type '{}'", .{
...@@ -7125,10 +7125,10 @@ fn callBuiltin(...@@ -7125,10 +7125,10 @@ fn callBuiltin(
7125 const callee_ty = sema.typeOf(builtin_fn);7125 const callee_ty = sema.typeOf(builtin_fn);
7126 const func_ty = func_ty: {7126 const func_ty = func_ty: {
7127 switch (callee_ty.zigTypeTag(zcu)) {7127 switch (callee_ty.zigTypeTag(zcu)) {
7128 .Fn => break :func_ty callee_ty,7128 .@"fn" => break :func_ty callee_ty,
7129 .Pointer => {7129 .pointer => {
7130 const ptr_info = callee_ty.ptrInfo(zcu);7130 const ptr_info = callee_ty.ptrInfo(zcu);
7131 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Fn) {7131 if (ptr_info.flags.size == .One and Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .@"fn") {
7132 break :func_ty Type.fromInterned(ptr_info.child);7132 break :func_ty Type.fromInterned(ptr_info.child);
7133 }7133 }
7134 },7134 },
...@@ -7276,7 +7276,7 @@ const CallArgsInfo = union(enum) {...@@ -7276,7 +7276,7 @@ const CallArgsInfo = union(enum) {
7276 // Resolve the arg!7276 // Resolve the arg!
7277 const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst);7277 const uncoerced_arg = try sema.resolveInlineBody(block, arg_body, zir_call.call_inst);
72787278
7279 if (sema.typeOf(uncoerced_arg).zigTypeTag(zcu) == .NoReturn) {7279 if (sema.typeOf(uncoerced_arg).zigTypeTag(zcu) == .noreturn) {
7280 // This terminates resolution of arguments. The caller should7280 // This terminates resolution of arguments. The caller should
7281 // propagate this.7281 // propagate this.
7282 return uncoerced_arg;7282 return uncoerced_arg;
...@@ -7863,7 +7863,7 @@ fn analyzeCall(...@@ -7863,7 +7863,7 @@ fn analyzeCall(
7863 if (param_ty) |t| assert(!t.isGenericPoison());7863 if (param_ty) |t| assert(!t.isGenericPoison());
7864 arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);7864 arg_out.* = try args_info.analyzeArg(sema, block, arg_idx, param_ty, func_ty_info, func);
7865 try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg_out.*);7865 try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_idx), arg_out.*);
7866 if (sema.typeOf(arg_out.*).zigTypeTag(zcu) == .NoReturn) {7866 if (sema.typeOf(arg_out.*).zigTypeTag(zcu) == .noreturn) {
7867 return arg_out.*;7867 return arg_out.*;
7868 }7868 }
7869 }7869 }
...@@ -7884,7 +7884,7 @@ fn analyzeCall(...@@ -7884,7 +7884,7 @@ fn analyzeCall(
7884 }7884 }
7885 }7885 }
78867886
7887 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Call).Struct.fields.len +7887 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Call).@"struct".fields.len +
7888 args.len);7888 args.len);
7889 const func_inst = try block.addInst(.{7889 const func_inst = try block.addInst(.{
7890 .tag = call_tag,7890 .tag = call_tag,
...@@ -7991,7 +7991,7 @@ fn analyzeInlineCallArg(...@@ -7991,7 +7991,7 @@ fn analyzeInlineCallArg(
7991 };7991 };
7992 new_param_types[arg_i.*] = param_ty;7992 new_param_types[arg_i.*] = param_ty;
7993 const casted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.fromInterned(param_ty), func_ty_info, func_inst);7993 const casted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.fromInterned(param_ty), func_ty_info, func_inst);
7994 if (ics.caller().typeOf(casted_arg).zigTypeTag(zcu) == .NoReturn) {7994 if (ics.caller().typeOf(casted_arg).zigTypeTag(zcu) == .noreturn) {
7995 return casted_arg;7995 return casted_arg;
7996 }7996 }
7997 const arg_src = args_info.argSrc(arg_block, arg_i.*);7997 const arg_src = args_info.argSrc(arg_block, arg_i.*);
...@@ -8039,7 +8039,7 @@ fn analyzeInlineCallArg(...@@ -8039,7 +8039,7 @@ fn analyzeInlineCallArg(
8039 .param_anytype, .param_anytype_comptime => {8039 .param_anytype, .param_anytype_comptime => {
8040 // No coercion needed.8040 // No coercion needed.
8041 const uncasted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.generic_poison, func_ty_info, func_inst);8041 const uncasted_arg = try args_info.analyzeArg(ics.caller(), arg_block, arg_i.*, Type.generic_poison, func_ty_info, func_inst);
8042 if (ics.caller().typeOf(uncasted_arg).zigTypeTag(zcu) == .NoReturn) {8042 if (ics.caller().typeOf(uncasted_arg).zigTypeTag(zcu) == .noreturn) {
8043 return uncasted_arg;8043 return uncasted_arg;
8044 }8044 }
8045 const arg_src = args_info.argSrc(arg_block, arg_i.*);8045 const arg_src = args_info.argSrc(arg_block, arg_i.*);
...@@ -8228,7 +8228,7 @@ fn instantiateGenericCall(...@@ -8228,7 +8228,7 @@ fn instantiateGenericCall(
8228 const arg_ref = try args_info.analyzeArg(sema, block, arg_index, param_ty, generic_owner_ty_info, func);8228 const arg_ref = try args_info.analyzeArg(sema, block, arg_index, param_ty, generic_owner_ty_info, func);
8229 try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_index), arg_ref);8229 try sema.validateRuntimeValue(block, args_info.argSrc(block, arg_index), arg_ref);
8230 const arg_ty = sema.typeOf(arg_ref);8230 const arg_ty = sema.typeOf(arg_ref);
8231 if (arg_ty.zigTypeTag(zcu) == .NoReturn) {8231 if (arg_ty.zigTypeTag(zcu) == .noreturn) {
8232 // This terminates argument analysis.8232 // This terminates argument analysis.
8233 return arg_ref;8233 return arg_ref;
8234 }8234 }
...@@ -8345,7 +8345,7 @@ fn instantiateGenericCall(...@@ -8345,7 +8345,7 @@ fn instantiateGenericCall(
8345 try sema.addReferenceEntry(call_src, AnalUnit.wrap(.{ .func = callee_index }));8345 try sema.addReferenceEntry(call_src, AnalUnit.wrap(.{ .func = callee_index }));
8346 try zcu.ensureFuncBodyAnalysisQueued(callee_index);8346 try zcu.ensureFuncBodyAnalysisQueued(callee_index);
83478347
8348 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Call).Struct.fields.len + runtime_args.items.len);8348 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Call).@"struct".fields.len + runtime_args.items.len);
8349 const result = try block.addInst(.{8349 const result = try block.addInst(.{
8350 .tag = call_tag,8350 .tag = call_tag,
8351 .data = .{ .pl_op = .{8351 .data = .{ .pl_op = .{
...@@ -8404,9 +8404,9 @@ fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -8404,9 +8404,9 @@ fn zirOptionalType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
8404 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;8404 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node;
8405 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });8405 const operand_src = block.src(.{ .node_offset_un_op = inst_data.src_node });
8406 const child_type = try sema.resolveType(block, operand_src, inst_data.operand);8406 const child_type = try sema.resolveType(block, operand_src, inst_data.operand);
8407 if (child_type.zigTypeTag(zcu) == .Opaque) {8407 if (child_type.zigTypeTag(zcu) == .@"opaque") {
8408 return sema.fail(block, operand_src, "opaque type '{}' cannot be optional", .{child_type.fmt(pt)});8408 return sema.fail(block, operand_src, "opaque type '{}' cannot be optional", .{child_type.fmt(pt)});
8409 } else if (child_type.zigTypeTag(zcu) == .Null) {8409 } else if (child_type.zigTypeTag(zcu) == .null) {
8410 return sema.fail(block, operand_src, "type '{}' cannot be optional", .{child_type.fmt(pt)});8410 return sema.fail(block, operand_src, "type '{}' cannot be optional", .{child_type.fmt(pt)});
8411 }8411 }
8412 const opt_type = try pt.optionalType(child_type.toIntern());8412 const opt_type = try pt.optionalType(child_type.toIntern());
...@@ -8429,7 +8429,7 @@ fn zirArrayInitElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil...@@ -8429,7 +8429,7 @@ fn zirArrayInitElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
8429 const indexable_ty = maybe_wrapped_indexable_ty.optEuBaseType(zcu);8429 const indexable_ty = maybe_wrapped_indexable_ty.optEuBaseType(zcu);
8430 try indexable_ty.resolveFields(pt);8430 try indexable_ty.resolveFields(pt);
8431 assert(indexable_ty.isIndexable(zcu)); // validated by a previous instruction8431 assert(indexable_ty.isIndexable(zcu)); // validated by a previous instruction
8432 if (indexable_ty.zigTypeTag(zcu) == .Struct) {8432 if (indexable_ty.zigTypeTag(zcu) == .@"struct") {
8433 const elem_type = indexable_ty.fieldType(@intFromEnum(bin.rhs), zcu);8433 const elem_type = indexable_ty.fieldType(@intFromEnum(bin.rhs), zcu);
8434 return Air.internedToRef(elem_type.toIntern());8434 return Air.internedToRef(elem_type.toIntern());
8435 } else {8435 } else {
...@@ -8447,7 +8447,7 @@ fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -8447,7 +8447,7 @@ fn zirElemType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
8447 else => |e| return e,8447 else => |e| return e,
8448 };8448 };
8449 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);8449 const ptr_ty = maybe_wrapped_ptr_ty.optEuBaseType(zcu);
8450 assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction8450 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
8451 const elem_ty = ptr_ty.childType(zcu);8451 const elem_ty = ptr_ty.childType(zcu);
8452 if (elem_ty.toIntern() == .anyopaque_type) {8452 if (elem_ty.toIntern() == .anyopaque_type) {
8453 // The pointer's actual child type is effectively unknown, so it makes8453 // The pointer's actual child type is effectively unknown, so it makes
...@@ -8561,9 +8561,9 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil...@@ -8561,9 +8561,9 @@ fn zirArrayTypeSentinel(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compil
8561fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: LazySrcLoc) !void {8561fn validateArrayElemType(sema: *Sema, block: *Block, elem_type: Type, elem_src: LazySrcLoc) !void {
8562 const pt = sema.pt;8562 const pt = sema.pt;
8563 const zcu = pt.zcu;8563 const zcu = pt.zcu;
8564 if (elem_type.zigTypeTag(zcu) == .Opaque) {8564 if (elem_type.zigTypeTag(zcu) == .@"opaque") {
8565 return sema.fail(block, elem_src, "array of opaque type '{}' not allowed", .{elem_type.fmt(pt)});8565 return sema.fail(block, elem_src, "array of opaque type '{}' not allowed", .{elem_type.fmt(pt)});
8566 } else if (elem_type.zigTypeTag(zcu) == .NoReturn) {8566 } else if (elem_type.zigTypeTag(zcu) == .noreturn) {
8567 return sema.fail(block, elem_src, "array of 'noreturn' not allowed", .{});8567 return sema.fail(block, elem_src, "array of 'noreturn' not allowed", .{});
8568 }8568 }
8569}8569}
...@@ -8597,7 +8597,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -8597,7 +8597,7 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
8597 const error_set = try sema.resolveType(block, lhs_src, extra.lhs);8597 const error_set = try sema.resolveType(block, lhs_src, extra.lhs);
8598 const payload = try sema.resolveType(block, rhs_src, extra.rhs);8598 const payload = try sema.resolveType(block, rhs_src, extra.rhs);
85998599
8600 if (error_set.zigTypeTag(zcu) != .ErrorSet) {8600 if (error_set.zigTypeTag(zcu) != .error_set) {
8601 return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{8601 return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{
8602 error_set.fmt(pt),8602 error_set.fmt(pt),
8603 });8603 });
...@@ -8610,11 +8610,11 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -8610,11 +8610,11 @@ fn zirErrorUnionType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
8610fn validateErrorUnionPayloadType(sema: *Sema, block: *Block, payload_ty: Type, payload_src: LazySrcLoc) !void {8610fn validateErrorUnionPayloadType(sema: *Sema, block: *Block, payload_ty: Type, payload_src: LazySrcLoc) !void {
8611 const pt = sema.pt;8611 const pt = sema.pt;
8612 const zcu = pt.zcu;8612 const zcu = pt.zcu;
8613 if (payload_ty.zigTypeTag(zcu) == .Opaque) {8613 if (payload_ty.zigTypeTag(zcu) == .@"opaque") {
8614 return sema.fail(block, payload_src, "error union with payload of opaque type '{}' not allowed", .{8614 return sema.fail(block, payload_src, "error union with payload of opaque type '{}' not allowed", .{
8615 payload_ty.fmt(pt),8615 payload_ty.fmt(pt),
8616 });8616 });
8617 } else if (payload_ty.zigTypeTag(zcu) == .ErrorSet) {8617 } else if (payload_ty.zigTypeTag(zcu) == .error_set) {
8618 return sema.fail(block, payload_src, "error union with payload of error set type '{}' not allowed", .{8618 return sema.fail(block, payload_src, "error union with payload of error set type '{}' not allowed", .{
8619 payload_ty.fmt(pt),8619 payload_ty.fmt(pt),
8620 });8620 });
...@@ -8741,7 +8741,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -8741,7 +8741,7 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
8741 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });8741 const rhs_src = block.src(.{ .node_offset_bin_rhs = inst_data.src_node });
8742 const lhs = try sema.resolveInst(extra.lhs);8742 const lhs = try sema.resolveInst(extra.lhs);
8743 const rhs = try sema.resolveInst(extra.rhs);8743 const rhs = try sema.resolveInst(extra.rhs);
8744 if (sema.typeOf(lhs).zigTypeTag(zcu) == .Bool and sema.typeOf(rhs).zigTypeTag(zcu) == .Bool) {8744 if (sema.typeOf(lhs).zigTypeTag(zcu) == .bool and sema.typeOf(rhs).zigTypeTag(zcu) == .bool) {
8745 const msg = msg: {8745 const msg = msg: {
8746 const msg = try sema.errMsg(lhs_src, "expected error set type, found 'bool'", .{});8746 const msg = try sema.errMsg(lhs_src, "expected error set type, found 'bool'", .{});
8747 errdefer msg.destroy(sema.gpa);8747 errdefer msg.destroy(sema.gpa);
...@@ -8752,9 +8752,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr...@@ -8752,9 +8752,9 @@ fn zirMergeErrorSets(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
8752 }8752 }
8753 const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs);8753 const lhs_ty = try sema.analyzeAsType(block, lhs_src, lhs);
8754 const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs);8754 const rhs_ty = try sema.analyzeAsType(block, rhs_src, rhs);
8755 if (lhs_ty.zigTypeTag(zcu) != .ErrorSet)8755 if (lhs_ty.zigTypeTag(zcu) != .error_set)
8756 return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{lhs_ty.fmt(pt)});8756 return sema.fail(block, lhs_src, "expected error set type, found '{}'", .{lhs_ty.fmt(pt)});
8757 if (rhs_ty.zigTypeTag(zcu) != .ErrorSet)8757 if (rhs_ty.zigTypeTag(zcu) != .error_set)
8758 return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(pt)});8758 return sema.fail(block, rhs_src, "expected error set type, found '{}'", .{rhs_ty.fmt(pt)});
87598759
8760 // Anything merged with anyerror is anyerror.8760 // Anything merged with anyerror is anyerror.
...@@ -8807,8 +8807,8 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8807,8 +8807,8 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8807 const operand_ty = sema.typeOf(operand);8807 const operand_ty = sema.typeOf(operand);
88088808
8809 const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(zcu)) {8809 const enum_tag: Air.Inst.Ref = switch (operand_ty.zigTypeTag(zcu)) {
8810 .Enum => operand,8810 .@"enum" => operand,
8811 .Union => blk: {8811 .@"union" => blk: {
8812 try operand_ty.resolveFields(pt);8812 try operand_ty.resolveFields(pt);
8813 const tag_ty = operand_ty.unionTagType(zcu) orelse {8813 const tag_ty = operand_ty.unionTagType(zcu) orelse {
8814 return sema.fail(8814 return sema.fail(
...@@ -8865,7 +8865,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8865,7 +8865,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8865 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");8865 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu_opt, "@enumFromInt");
8866 const operand = try sema.resolveInst(extra.rhs);8866 const operand = try sema.resolveInst(extra.rhs);
88678867
8868 if (dest_ty.zigTypeTag(zcu) != .Enum) {8868 if (dest_ty.zigTypeTag(zcu) != .@"enum") {
8869 return sema.fail(block, src, "expected enum, found '{}'", .{dest_ty.fmt(pt)});8869 return sema.fail(block, src, "expected enum, found '{}'", .{dest_ty.fmt(pt)});
8870 }8870 }
8871 _ = try sema.checkIntType(block, operand_src, sema.typeOf(operand));8871 _ = try sema.checkIntType(block, operand_src, sema.typeOf(operand));
...@@ -8891,7 +8891,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -8891,7 +8891,7 @@ fn zirEnumFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
8891 return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern());8891 return Air.internedToRef((try pt.getCoerced(int_val, dest_ty)).toIntern());
8892 }8892 }
88938893
8894 if (dest_ty.intTagType(zcu).zigTypeTag(zcu) == .ComptimeInt) {8894 if (dest_ty.intTagType(zcu).zigTypeTag(zcu) == .comptime_int) {
8895 return sema.failWithNeededComptime(block, operand_src, .{8895 return sema.failWithNeededComptime(block, operand_src, .{
8896 .needed_comptime_reason = "value being casted to enum with 'comptime_int' tag type must be comptime-known",8896 .needed_comptime_reason = "value being casted to enum with 'comptime_int' tag type must be comptime-known",
8897 });8897 });
...@@ -8945,10 +8945,10 @@ fn analyzeOptionalPayloadPtr(...@@ -8945,10 +8945,10 @@ fn analyzeOptionalPayloadPtr(
8945 const pt = sema.pt;8945 const pt = sema.pt;
8946 const zcu = pt.zcu;8946 const zcu = pt.zcu;
8947 const optional_ptr_ty = sema.typeOf(optional_ptr);8947 const optional_ptr_ty = sema.typeOf(optional_ptr);
8948 assert(optional_ptr_ty.zigTypeTag(zcu) == .Pointer);8948 assert(optional_ptr_ty.zigTypeTag(zcu) == .pointer);
89498949
8950 const opt_type = optional_ptr_ty.childType(zcu);8950 const opt_type = optional_ptr_ty.childType(zcu);
8951 if (opt_type.zigTypeTag(zcu) != .Optional) {8951 if (opt_type.zigTypeTag(zcu) != .optional) {
8952 return sema.failWithExpectedOptionalType(block, src, opt_type);8952 return sema.failWithExpectedOptionalType(block, src, opt_type);
8953 }8953 }
89548954
...@@ -9019,8 +9019,8 @@ fn zirOptionalPayload(...@@ -9019,8 +9019,8 @@ fn zirOptionalPayload(
9019 const operand = try sema.resolveInst(inst_data.operand);9019 const operand = try sema.resolveInst(inst_data.operand);
9020 const operand_ty = sema.typeOf(operand);9020 const operand_ty = sema.typeOf(operand);
9021 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {9021 const result_ty = switch (operand_ty.zigTypeTag(zcu)) {
9022 .Optional => operand_ty.optionalChild(zcu),9022 .optional => operand_ty.optionalChild(zcu),
9023 .Pointer => t: {9023 .pointer => t: {
9024 if (operand_ty.ptrSize(zcu) != .C) {9024 if (operand_ty.ptrSize(zcu) != .C) {
9025 return sema.failWithExpectedOptionalType(block, src, operand_ty);9025 return sema.failWithExpectedOptionalType(block, src, operand_ty);
9026 }9026 }
...@@ -9072,7 +9072,7 @@ fn zirErrUnionPayload(...@@ -9072,7 +9072,7 @@ fn zirErrUnionPayload(
9072 const operand = try sema.resolveInst(inst_data.operand);9072 const operand = try sema.resolveInst(inst_data.operand);
9073 const operand_src = src;9073 const operand_src = src;
9074 const err_union_ty = sema.typeOf(operand);9074 const err_union_ty = sema.typeOf(operand);
9075 if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) {9075 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
9076 return sema.fail(block, operand_src, "expected error union type, found '{}'", .{9076 return sema.fail(block, operand_src, "expected error union type, found '{}'", .{
9077 err_union_ty.fmt(pt),9077 err_union_ty.fmt(pt),
9078 });9078 });
...@@ -9138,9 +9138,9 @@ fn analyzeErrUnionPayloadPtr(...@@ -9138,9 +9138,9 @@ fn analyzeErrUnionPayloadPtr(
9138 const pt = sema.pt;9138 const pt = sema.pt;
9139 const zcu = pt.zcu;9139 const zcu = pt.zcu;
9140 const operand_ty = sema.typeOf(operand);9140 const operand_ty = sema.typeOf(operand);
9141 assert(operand_ty.zigTypeTag(zcu) == .Pointer);9141 assert(operand_ty.zigTypeTag(zcu) == .pointer);
91429142
9143 if (operand_ty.childType(zcu).zigTypeTag(zcu) != .ErrorUnion) {9143 if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) {
9144 return sema.fail(block, src, "expected error union type, found '{}'", .{9144 return sema.fail(block, src, "expected error union type, found '{}'", .{
9145 operand_ty.childType(zcu).fmt(pt),9145 operand_ty.childType(zcu).fmt(pt),
9146 });9146 });
...@@ -9216,7 +9216,7 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air...@@ -9216,7 +9216,7 @@ fn analyzeErrUnionCode(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air
9216 const pt = sema.pt;9216 const pt = sema.pt;
9217 const zcu = pt.zcu;9217 const zcu = pt.zcu;
9218 const operand_ty = sema.typeOf(operand);9218 const operand_ty = sema.typeOf(operand);
9219 if (operand_ty.zigTypeTag(zcu) != .ErrorUnion) {9219 if (operand_ty.zigTypeTag(zcu) != .error_union) {
9220 return sema.fail(block, src, "expected error union type, found '{}'", .{9220 return sema.fail(block, src, "expected error union type, found '{}'", .{
9221 operand_ty.fmt(pt),9221 operand_ty.fmt(pt),
9222 });9222 });
...@@ -9250,9 +9250,9 @@ fn analyzeErrUnionCodePtr(sema: *Sema, block: *Block, src: LazySrcLoc, operand:...@@ -9250,9 +9250,9 @@ fn analyzeErrUnionCodePtr(sema: *Sema, block: *Block, src: LazySrcLoc, operand:
9250 const pt = sema.pt;9250 const pt = sema.pt;
9251 const zcu = pt.zcu;9251 const zcu = pt.zcu;
9252 const operand_ty = sema.typeOf(operand);9252 const operand_ty = sema.typeOf(operand);
9253 assert(operand_ty.zigTypeTag(zcu) == .Pointer);9253 assert(operand_ty.zigTypeTag(zcu) == .pointer);
92549254
9255 if (operand_ty.childType(zcu).zigTypeTag(zcu) != .ErrorUnion) {9255 if (operand_ty.childType(zcu).zigTypeTag(zcu) != .error_union) {
9256 return sema.fail(block, src, "expected error union type, found '{}'", .{9256 return sema.fail(block, src, "expected error union type, found '{}'", .{
9257 operand_ty.childType(zcu).fmt(pt),9257 operand_ty.childType(zcu).fmt(pt),
9258 });9258 });
...@@ -9587,7 +9587,7 @@ fn funcCommon(...@@ -9587,7 +9587,7 @@ fn funcCommon(
9587 return sema.fail(block, param_src, "generic parameters not allowed in function with calling convention '{s}'", .{@tagName(cc_resolved)});9587 return sema.fail(block, param_src, "generic parameters not allowed in function with calling convention '{s}'", .{@tagName(cc_resolved)});
9588 }9588 }
9589 if (!param_ty.isValidParamType(zcu)) {9589 if (!param_ty.isValidParamType(zcu)) {
9590 const opaque_str = if (param_ty.zigTypeTag(zcu) == .Opaque) "opaque " else "";9590 const opaque_str = if (param_ty.zigTypeTag(zcu) == .@"opaque") "opaque " else "";
9591 return sema.fail(block, param_src, "parameter of {s}type '{}' not allowed", .{9591 return sema.fail(block, param_src, "parameter of {s}type '{}' not allowed", .{
9592 opaque_str, param_ty.fmt(pt),9592 opaque_str, param_ty.fmt(pt),
9593 });9593 });
...@@ -9621,7 +9621,7 @@ fn funcCommon(...@@ -9621,7 +9621,7 @@ fn funcCommon(
9621 return sema.failWithOwnedErrorMsg(block, msg);9621 return sema.failWithOwnedErrorMsg(block, msg);
9622 }9622 }
9623 if (is_source_decl and !this_generic and is_noalias and9623 if (is_source_decl and !this_generic and is_noalias and
9624 !(param_ty.zigTypeTag(zcu) == .Pointer or param_ty.isPtrLikeOptional(zcu)))9624 !(param_ty.zigTypeTag(zcu) == .pointer or param_ty.isPtrLikeOptional(zcu)))
9625 {9625 {
9626 return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{});9626 return sema.fail(block, param_src, "non-pointer parameter declared noalias", .{});
9627 }9627 }
...@@ -9629,7 +9629,7 @@ fn funcCommon(...@@ -9629,7 +9629,7 @@ fn funcCommon(
9629 .Interrupt => if (target.cpu.arch.isX86()) {9629 .Interrupt => if (target.cpu.arch.isX86()) {
9630 const err_code_size = target.ptrBitWidth();9630 const err_code_size = target.ptrBitWidth();
9631 switch (i) {9631 switch (i) {
9632 0 => if (param_ty.zigTypeTag(zcu) != .Pointer) return sema.fail(block, param_src, "first parameter of function with 'Interrupt' calling convention must be a pointer type", .{}),9632 0 => if (param_ty.zigTypeTag(zcu) != .pointer) return sema.fail(block, param_src, "first parameter of function with 'Interrupt' calling convention must be a pointer type", .{}),
9633 1 => if (param_ty.bitSize(zcu) != err_code_size) return sema.fail(block, param_src, "second parameter of function with 'Interrupt' calling convention must be a {d}-bit integer", .{err_code_size}),9633 1 => if (param_ty.bitSize(zcu) != err_code_size) return sema.fail(block, param_src, "second parameter of function with 'Interrupt' calling convention must be a {d}-bit integer", .{err_code_size}),
9634 else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}),9634 else => return sema.fail(block, param_src, "'Interrupt' calling convention supports up to 2 parameters, found {d}", .{i + 1}),
9635 }9635 }
...@@ -9891,7 +9891,7 @@ fn finishFunc(...@@ -9891,7 +9891,7 @@ fn finishFunc(
9891 Type.fromInterned(ip.funcTypeReturnType(ip.typeOf(opt_func_index)));9891 Type.fromInterned(ip.funcTypeReturnType(ip.typeOf(opt_func_index)));
98929892
9893 if (!return_type.isValidReturnType(zcu)) {9893 if (!return_type.isValidReturnType(zcu)) {
9894 const opaque_str = if (return_type.zigTypeTag(zcu) == .Opaque) "opaque " else "";9894 const opaque_str = if (return_type.zigTypeTag(zcu) == .@"opaque") "opaque " else "";
9895 return sema.fail(block, ret_ty_src, "{s}return type '{}' not allowed", .{9895 return sema.fail(block, ret_ty_src, "{s}return type '{}' not allowed", .{
9896 opaque_str, return_type.fmt(pt),9896 opaque_str, return_type.fmt(pt),
9897 });9897 });
...@@ -9953,7 +9953,7 @@ fn finishFunc(...@@ -9953,7 +9953,7 @@ fn finishFunc(
9953 }9953 }
99549954
9955 switch (cc_resolved) {9955 switch (cc_resolved) {
9956 .Interrupt, .Signal => if (return_type.zigTypeTag(zcu) != .Void and return_type.zigTypeTag(zcu) != .NoReturn) {9956 .Interrupt, .Signal => if (return_type.zigTypeTag(zcu) != .void and return_type.zigTypeTag(zcu) != .noreturn) {
9957 return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)});9957 return sema.fail(block, ret_ty_src, "function with calling convention '{s}' must return 'void' or 'noreturn'", .{@tagName(cc_resolved)});
9958 },9958 },
9959 .Inline => if (is_noinline) {9959 .Inline => if (is_noinline) {
...@@ -10154,11 +10154,11 @@ fn analyzeAs(...@@ -10154,11 +10154,11 @@ fn analyzeAs(
10154 error.GenericPoison => return operand,10154 error.GenericPoison => return operand,
10155 };10155 };
1015610156
10157 if (dest_ty_tag == .Opaque) {10157 if (dest_ty_tag == .@"opaque") {
10158 return sema.fail(block, src, "cannot cast to opaque type '{}'", .{dest_ty.fmt(pt)});10158 return sema.fail(block, src, "cannot cast to opaque type '{}'", .{dest_ty.fmt(pt)});
10159 }10159 }
1016010160
10161 if (dest_ty_tag == .NoReturn) {10161 if (dest_ty_tag == .noreturn) {
10162 return sema.fail(block, src, "cannot cast to noreturn", .{});10162 return sema.fail(block, src, "cannot cast to noreturn", .{});
10163 }10163 }
1016410164
...@@ -10183,7 +10183,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -10183,7 +10183,7 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
10183 const operand = try sema.resolveInst(inst_data.operand);10183 const operand = try sema.resolveInst(inst_data.operand);
10184 const operand_ty = sema.typeOf(operand);10184 const operand_ty = sema.typeOf(operand);
10185 const ptr_ty = operand_ty.scalarType(zcu);10185 const ptr_ty = operand_ty.scalarType(zcu);
10186 const is_vector = operand_ty.zigTypeTag(zcu) == .Vector;10186 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
10187 if (!ptr_ty.isPtrAtRuntime(zcu)) {10187 if (!ptr_ty.isPtrAtRuntime(zcu)) {
10188 return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(pt)});10188 return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(pt)});
10189 }10189 }
...@@ -10305,7 +10305,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi...@@ -10305,7 +10305,7 @@ fn zirStructInitFieldPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compi
10305 const object_ptr = try sema.resolveInst(extra.lhs);10305 const object_ptr = try sema.resolveInst(extra.lhs);
10306 const struct_ty = sema.typeOf(object_ptr).childType(zcu);10306 const struct_ty = sema.typeOf(object_ptr).childType(zcu);
10307 switch (struct_ty.zigTypeTag(zcu)) {10307 switch (struct_ty.zigTypeTag(zcu)) {
10308 .Struct, .Union => {10308 .@"struct", .@"union" => {
10309 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, true);10309 return sema.fieldPtr(block, src, object_ptr, field_name, field_name_src, true);
10310 },10310 },
10311 else => {10311 else => {
...@@ -10377,12 +10377,12 @@ fn intCast(...@@ -10377,12 +10377,12 @@ fn intCast(
1037710377
10378 if (try sema.isComptimeKnown(operand)) {10378 if (try sema.isComptimeKnown(operand)) {
10379 return sema.coerce(block, dest_ty, operand, operand_src);10379 return sema.coerce(block, dest_ty, operand, operand_src);
10380 } else if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeInt) {10380 } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) {
10381 return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_int'", .{});10381 return sema.fail(block, operand_src, "unable to cast runtime value to 'comptime_int'", .{});
10382 }10382 }
1038310383
10384 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, dest_ty_src, operand_src);10384 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, dest_ty_src, operand_src);
10385 const is_vector = dest_ty.zigTypeTag(zcu) == .Vector;10385 const is_vector = dest_ty.zigTypeTag(zcu) == .vector;
1038610386
10387 if ((try sema.typeHasOnePossibleValue(dest_ty))) |opv| {10387 if ((try sema.typeHasOnePossibleValue(dest_ty))) |opv| {
10388 // requirement: intCast(u0, input) iff input == 010388 // requirement: intCast(u0, input) iff input == 0
...@@ -10529,29 +10529,29 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10529,29 +10529,29 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10529 const operand = try sema.resolveInst(extra.rhs);10529 const operand = try sema.resolveInst(extra.rhs);
10530 const operand_ty = sema.typeOf(operand);10530 const operand_ty = sema.typeOf(operand);
10531 switch (dest_ty.zigTypeTag(zcu)) {10531 switch (dest_ty.zigTypeTag(zcu)) {
10532 .AnyFrame,10532 .@"anyframe",
10533 .ComptimeFloat,10533 .comptime_float,
10534 .ComptimeInt,10534 .comptime_int,
10535 .EnumLiteral,10535 .enum_literal,
10536 .ErrorSet,10536 .error_set,
10537 .ErrorUnion,10537 .error_union,
10538 .Fn,10538 .@"fn",
10539 .Frame,10539 .frame,
10540 .NoReturn,10540 .noreturn,
10541 .Null,10541 .null,
10542 .Opaque,10542 .@"opaque",
10543 .Optional,10543 .optional,
10544 .Type,10544 .type,
10545 .Undefined,10545 .undefined,
10546 .Void,10546 .void,
10547 => return sema.fail(block, src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)}),10547 => return sema.fail(block, src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)}),
1054810548
10549 .Enum => {10549 .@"enum" => {
10550 const msg = msg: {10550 const msg = msg: {
10551 const msg = try sema.errMsg(src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)});10551 const msg = try sema.errMsg(src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)});
10552 errdefer msg.destroy(sema.gpa);10552 errdefer msg.destroy(sema.gpa);
10553 switch (operand_ty.zigTypeTag(zcu)) {10553 switch (operand_ty.zigTypeTag(zcu)) {
10554 .Int, .ComptimeInt => try sema.errNote(src, msg, "use @enumFromInt to cast from '{}'", .{operand_ty.fmt(pt)}),10554 .int, .comptime_int => try sema.errNote(src, msg, "use @enumFromInt to cast from '{}'", .{operand_ty.fmt(pt)}),
10555 else => {},10555 else => {},
10556 }10556 }
1055710557
...@@ -10560,13 +10560,13 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10560,13 +10560,13 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10560 return sema.failWithOwnedErrorMsg(block, msg);10560 return sema.failWithOwnedErrorMsg(block, msg);
10561 },10561 },
1056210562
10563 .Pointer => {10563 .pointer => {
10564 const msg = msg: {10564 const msg = msg: {
10565 const msg = try sema.errMsg(src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)});10565 const msg = try sema.errMsg(src, "cannot @bitCast to '{}'", .{dest_ty.fmt(pt)});
10566 errdefer msg.destroy(sema.gpa);10566 errdefer msg.destroy(sema.gpa);
10567 switch (operand_ty.zigTypeTag(zcu)) {10567 switch (operand_ty.zigTypeTag(zcu)) {
10568 .Int, .ComptimeInt => try sema.errNote(src, msg, "use @ptrFromInt to cast from '{}'", .{operand_ty.fmt(pt)}),10568 .int, .comptime_int => try sema.errNote(src, msg, "use @ptrFromInt to cast from '{}'", .{operand_ty.fmt(pt)}),
10569 .Pointer => try sema.errNote(src, msg, "use @ptrCast to cast from '{}'", .{operand_ty.fmt(pt)}),10569 .pointer => try sema.errNote(src, msg, "use @ptrCast to cast from '{}'", .{operand_ty.fmt(pt)}),
10570 else => {},10570 else => {},
10571 }10571 }
1057210572
...@@ -10574,10 +10574,10 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10574,10 +10574,10 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10574 };10574 };
10575 return sema.failWithOwnedErrorMsg(block, msg);10575 return sema.failWithOwnedErrorMsg(block, msg);
10576 },10576 },
10577 .Struct, .Union => if (dest_ty.containerLayout(zcu) == .auto) {10577 .@"struct", .@"union" => if (dest_ty.containerLayout(zcu) == .auto) {
10578 const container = switch (dest_ty.zigTypeTag(zcu)) {10578 const container = switch (dest_ty.zigTypeTag(zcu)) {
10579 .Struct => "struct",10579 .@"struct" => "struct",
10580 .Union => "union",10580 .@"union" => "union",
10581 else => unreachable,10581 else => unreachable,
10582 };10582 };
10583 return sema.fail(block, src, "cannot @bitCast to '{}'; {s} does not have a guaranteed in-memory layout", .{10583 return sema.fail(block, src, "cannot @bitCast to '{}'; {s} does not have a guaranteed in-memory layout", .{
...@@ -10585,37 +10585,37 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10585,37 +10585,37 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10585 });10585 });
10586 },10586 },
1058710587
10588 .Array,10588 .array,
10589 .Bool,10589 .bool,
10590 .Float,10590 .float,
10591 .Int,10591 .int,
10592 .Vector,10592 .vector,
10593 => {},10593 => {},
10594 }10594 }
10595 switch (operand_ty.zigTypeTag(zcu)) {10595 switch (operand_ty.zigTypeTag(zcu)) {
10596 .AnyFrame,10596 .@"anyframe",
10597 .ComptimeFloat,10597 .comptime_float,
10598 .ComptimeInt,10598 .comptime_int,
10599 .EnumLiteral,10599 .enum_literal,
10600 .ErrorSet,10600 .error_set,
10601 .ErrorUnion,10601 .error_union,
10602 .Fn,10602 .@"fn",
10603 .Frame,10603 .frame,
10604 .NoReturn,10604 .noreturn,
10605 .Null,10605 .null,
10606 .Opaque,10606 .@"opaque",
10607 .Optional,10607 .optional,
10608 .Type,10608 .type,
10609 .Undefined,10609 .undefined,
10610 .Void,10610 .void,
10611 => return sema.fail(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)}),10611 => return sema.fail(block, operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)}),
1061210612
10613 .Enum => {10613 .@"enum" => {
10614 const msg = msg: {10614 const msg = msg: {
10615 const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)});10615 const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)});
10616 errdefer msg.destroy(sema.gpa);10616 errdefer msg.destroy(sema.gpa);
10617 switch (dest_ty.zigTypeTag(zcu)) {10617 switch (dest_ty.zigTypeTag(zcu)) {
10618 .Int, .ComptimeInt => try sema.errNote(operand_src, msg, "use @intFromEnum to cast to '{}'", .{dest_ty.fmt(pt)}),10618 .int, .comptime_int => try sema.errNote(operand_src, msg, "use @intFromEnum to cast to '{}'", .{dest_ty.fmt(pt)}),
10619 else => {},10619 else => {},
10620 }10620 }
1062110621
...@@ -10623,13 +10623,13 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10623,13 +10623,13 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10623 };10623 };
10624 return sema.failWithOwnedErrorMsg(block, msg);10624 return sema.failWithOwnedErrorMsg(block, msg);
10625 },10625 },
10626 .Pointer => {10626 .pointer => {
10627 const msg = msg: {10627 const msg = msg: {
10628 const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)});10628 const msg = try sema.errMsg(operand_src, "cannot @bitCast from '{}'", .{operand_ty.fmt(pt)});
10629 errdefer msg.destroy(sema.gpa);10629 errdefer msg.destroy(sema.gpa);
10630 switch (dest_ty.zigTypeTag(zcu)) {10630 switch (dest_ty.zigTypeTag(zcu)) {
10631 .Int, .ComptimeInt => try sema.errNote(operand_src, msg, "use @intFromPtr to cast to '{}'", .{dest_ty.fmt(pt)}),10631 .int, .comptime_int => try sema.errNote(operand_src, msg, "use @intFromPtr to cast to '{}'", .{dest_ty.fmt(pt)}),
10632 .Pointer => try sema.errNote(operand_src, msg, "use @ptrCast to cast to '{}'", .{dest_ty.fmt(pt)}),10632 .pointer => try sema.errNote(operand_src, msg, "use @ptrCast to cast to '{}'", .{dest_ty.fmt(pt)}),
10633 else => {},10633 else => {},
10634 }10634 }
1063510635
...@@ -10637,10 +10637,10 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10637,10 +10637,10 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10637 };10637 };
10638 return sema.failWithOwnedErrorMsg(block, msg);10638 return sema.failWithOwnedErrorMsg(block, msg);
10639 },10639 },
10640 .Struct, .Union => if (operand_ty.containerLayout(zcu) == .auto) {10640 .@"struct", .@"union" => if (operand_ty.containerLayout(zcu) == .auto) {
10641 const container = switch (operand_ty.zigTypeTag(zcu)) {10641 const container = switch (operand_ty.zigTypeTag(zcu)) {
10642 .Struct => "struct",10642 .@"struct" => "struct",
10643 .Union => "union",10643 .@"union" => "union",
10644 else => unreachable,10644 else => unreachable,
10645 };10645 };
10646 return sema.fail(block, operand_src, "cannot @bitCast from '{}'; {s} does not have a guaranteed in-memory layout", .{10646 return sema.fail(block, operand_src, "cannot @bitCast from '{}'; {s} does not have a guaranteed in-memory layout", .{
...@@ -10648,11 +10648,11 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10648,11 +10648,11 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10648 });10648 });
10649 },10649 },
1065010650
10651 .Array,10651 .array,
10652 .Bool,10652 .bool,
10653 .Float,10653 .float,
10654 .Int,10654 .int,
10655 .Vector,10655 .vector,
10656 => {},10656 => {},
10657 }10657 }
10658 return sema.bitCast(block, dest_ty, operand, block.nodeOffset(inst_data.src_node), operand_src);10658 return sema.bitCast(block, dest_ty, operand, block.nodeOffset(inst_data.src_node), operand_src);
...@@ -10677,12 +10677,12 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -10677,12 +10677,12 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
10677 const operand_scalar_ty = operand_ty.scalarType(zcu);10677 const operand_scalar_ty = operand_ty.scalarType(zcu);
1067810678
10679 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);10679 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
10680 const is_vector = dest_ty.zigTypeTag(zcu) == .Vector;10680 const is_vector = dest_ty.zigTypeTag(zcu) == .vector;
1068110681
10682 const target = zcu.getTarget();10682 const target = zcu.getTarget();
10683 const dest_is_comptime_float = switch (dest_scalar_ty.zigTypeTag(zcu)) {10683 const dest_is_comptime_float = switch (dest_scalar_ty.zigTypeTag(zcu)) {
10684 .ComptimeFloat => true,10684 .comptime_float => true,
10685 .Float => false,10685 .float => false,
10686 else => return sema.fail(10686 else => return sema.fail(
10687 block,10687 block,
10688 src,10688 src,
...@@ -10692,7 +10692,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -10692,7 +10692,7 @@ fn zirFloatCast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
10692 };10692 };
1069310693
10694 switch (operand_scalar_ty.zigTypeTag(zcu)) {10694 switch (operand_scalar_ty.zigTypeTag(zcu)) {
10695 .ComptimeFloat, .Float, .ComptimeInt => {},10695 .comptime_float, .float, .comptime_int => {},
10696 else => return sema.fail(10696 else => return sema.fail(
10697 block,10697 block,
10698 operand_src,10698 operand_src,
...@@ -10787,7 +10787,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -10787,7 +10787,7 @@ fn zirElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
10787 const array_ptr = try sema.resolveInst(extra.lhs);10787 const array_ptr = try sema.resolveInst(extra.lhs);
10788 const elem_index = try sema.resolveInst(extra.rhs);10788 const elem_index = try sema.resolveInst(extra.rhs);
10789 const indexable_ty = sema.typeOf(array_ptr);10789 const indexable_ty = sema.typeOf(array_ptr);
10790 if (indexable_ty.zigTypeTag(zcu) != .Pointer) {10790 if (indexable_ty.zigTypeTag(zcu) != .pointer) {
10791 const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node });10791 const capture_src = block.src(.{ .for_capture_from_input = inst_data.src_node });
10792 const msg = msg: {10792 const msg = msg: {
10793 const msg = try sema.errMsg(capture_src, "pointer capture of non pointer type '{}'", .{10793 const msg = try sema.errMsg(capture_src, "pointer capture of non pointer type '{}'", .{
...@@ -10831,7 +10831,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile...@@ -10831,7 +10831,7 @@ fn zirArrayInitElemPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Compile
10831 const elem_index = try pt.intRef(Type.usize, extra.index);10831 const elem_index = try pt.intRef(Type.usize, extra.index);
10832 const array_ty = sema.typeOf(array_ptr).childType(zcu);10832 const array_ty = sema.typeOf(array_ptr).childType(zcu);
10833 switch (array_ty.zigTypeTag(zcu)) {10833 switch (array_ty.zigTypeTag(zcu)) {
10834 .Array, .Vector => {},10834 .array, .vector => {},
10835 else => if (!array_ty.isTuple(zcu)) {10835 else => if (!array_ty.isTuple(zcu)) {
10836 return sema.failWithArrayInitNotSupported(block, src, array_ty);10836 return sema.failWithArrayInitNotSupported(block, src, array_ty);
10837 },10837 },
...@@ -11066,7 +11066,7 @@ const SwitchProngAnalysis = struct {...@@ -11066,7 +11066,7 @@ const SwitchProngAnalysis = struct {
11066 const pt = sema.pt;11066 const pt = sema.pt;
11067 const zcu = pt.zcu;11067 const zcu = pt.zcu;
11068 const operand_ty = sema.typeOf(spa.operand);11068 const operand_ty = sema.typeOf(spa.operand);
11069 if (operand_ty.zigTypeTag(zcu) != .Union) {11069 if (operand_ty.zigTypeTag(zcu) != .@"union") {
11070 const tag_capture_src: LazySrcLoc = .{11070 const tag_capture_src: LazySrcLoc = .{
11071 .base_node_inst = capture_src.base_node_inst,11071 .base_node_inst = capture_src.base_node_inst,
11072 .offset = .{ .switch_tag_capture = capture_src.offset.switch_capture },11072 .offset = .{ .switch_tag_capture = capture_src.offset.switch_capture },
...@@ -11102,7 +11102,7 @@ const SwitchProngAnalysis = struct {...@@ -11102,7 +11102,7 @@ const SwitchProngAnalysis = struct {
1110211102
11103 if (inline_case_capture != .none) {11103 if (inline_case_capture != .none) {
11104 const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inline_case_capture, undefined) catch unreachable;11104 const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inline_case_capture, undefined) catch unreachable;
11105 if (operand_ty.zigTypeTag(zcu) == .Union) {11105 if (operand_ty.zigTypeTag(zcu) == .@"union") {
11106 const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, zcu).?);11106 const field_index: u32 = @intCast(operand_ty.unionTagFieldIndex(item_val, zcu).?);
11107 const union_obj = zcu.typeToUnion(operand_ty).?;11107 const union_obj = zcu.typeToUnion(operand_ty).?;
11108 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);11108 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
...@@ -11139,7 +11139,7 @@ const SwitchProngAnalysis = struct {...@@ -11139,7 +11139,7 @@ const SwitchProngAnalysis = struct {
11139 }11139 }
1114011140
11141 switch (operand_ty.zigTypeTag(zcu)) {11141 switch (operand_ty.zigTypeTag(zcu)) {
11142 .ErrorSet => if (spa.else_error_ty) |ty| {11142 .error_set => if (spa.else_error_ty) |ty| {
11143 return sema.bitCast(block, ty, spa.operand, operand_src, null);11143 return sema.bitCast(block, ty, spa.operand, operand_src, null);
11144 } else {11144 } else {
11145 try sema.analyzeUnreachable(block, operand_src, false);11145 try sema.analyzeUnreachable(block, operand_src, false);
...@@ -11150,7 +11150,7 @@ const SwitchProngAnalysis = struct {...@@ -11150,7 +11150,7 @@ const SwitchProngAnalysis = struct {
11150 }11150 }
1115111151
11152 switch (operand_ty.zigTypeTag(zcu)) {11152 switch (operand_ty.zigTypeTag(zcu)) {
11153 .Union => {11153 .@"union" => {
11154 const union_obj = zcu.typeToUnion(operand_ty).?;11154 const union_obj = zcu.typeToUnion(operand_ty).?;
11155 const first_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, case_vals[0], undefined) catch unreachable;11155 const first_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, case_vals[0], undefined) catch unreachable;
1115611156
...@@ -11370,9 +11370,9 @@ const SwitchProngAnalysis = struct {...@@ -11370,9 +11370,9 @@ const SwitchProngAnalysis = struct {
11370 break :len coerce_block.instructions.items.len;11370 break :len coerce_block.instructions.items.len;
11371 };11371 };
1137211372
11373 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.SwitchBr).Struct.fields.len +11373 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.SwitchBr).@"struct".fields.len +
11374 cases_extra.items.len +11374 cases_extra.items.len +
11375 @typeInfo(Air.Block).Struct.fields.len +11375 @typeInfo(Air.Block).@"struct".fields.len +
11376 1);11376 1);
1137711377
11378 const switch_br_inst: u32 = @intCast(sema.air_instructions.len);11378 const switch_br_inst: u32 = @intCast(sema.air_instructions.len);
...@@ -11396,7 +11396,7 @@ const SwitchProngAnalysis = struct {...@@ -11396,7 +11396,7 @@ const SwitchProngAnalysis = struct {
1139611396
11397 return capture_block_inst.toRef();11397 return capture_block_inst.toRef();
11398 },11398 },
11399 .ErrorSet => {11399 .error_set => {
11400 if (capture_byref) {11400 if (capture_byref) {
11401 return sema.fail(11401 return sema.fail(
11402 block,11402 block,
...@@ -11444,18 +11444,18 @@ fn switchCond(...@@ -11444,18 +11444,18 @@ fn switchCond(
11444 const zcu = pt.zcu;11444 const zcu = pt.zcu;
11445 const operand_ty = sema.typeOf(operand);11445 const operand_ty = sema.typeOf(operand);
11446 switch (operand_ty.zigTypeTag(zcu)) {11446 switch (operand_ty.zigTypeTag(zcu)) {
11447 .Type,11447 .type,
11448 .Void,11448 .void,
11449 .Bool,11449 .bool,
11450 .Int,11450 .int,
11451 .Float,11451 .float,
11452 .ComptimeFloat,11452 .comptime_float,
11453 .ComptimeInt,11453 .comptime_int,
11454 .EnumLiteral,11454 .enum_literal,
11455 .Pointer,11455 .pointer,
11456 .Fn,11456 .@"fn",
11457 .ErrorSet,11457 .error_set,
11458 .Enum,11458 .@"enum",
11459 => {11459 => {
11460 if (operand_ty.isSlice(zcu)) {11460 if (operand_ty.isSlice(zcu)) {
11461 return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(pt)});11461 return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(pt)});
...@@ -11466,7 +11466,7 @@ fn switchCond(...@@ -11466,7 +11466,7 @@ fn switchCond(
11466 return operand;11466 return operand;
11467 },11467 },
1146811468
11469 .Union => {11469 .@"union" => {
11470 try operand_ty.resolveFields(pt);11470 try operand_ty.resolveFields(pt);
11471 const enum_ty = operand_ty.unionTagType(zcu) orelse {11471 const enum_ty = operand_ty.unionTagType(zcu) orelse {
11472 const msg = msg: {11472 const msg = msg: {
...@@ -11482,17 +11482,17 @@ fn switchCond(...@@ -11482,17 +11482,17 @@ fn switchCond(
11482 return sema.unionToTag(block, enum_ty, operand, src);11482 return sema.unionToTag(block, enum_ty, operand, src);
11483 },11483 },
1148411484
11485 .ErrorUnion,11485 .error_union,
11486 .NoReturn,11486 .noreturn,
11487 .Array,11487 .array,
11488 .Struct,11488 .@"struct",
11489 .Undefined,11489 .undefined,
11490 .Null,11490 .null,
11491 .Optional,11491 .optional,
11492 .Opaque,11492 .@"opaque",
11493 .Vector,11493 .vector,
11494 .Frame,11494 .frame,
11495 .AnyFrame,11495 .@"anyframe",
11496 => return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(pt)}),11496 => return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(pt)}),
11497 }11497 }
11498}11498}
...@@ -11593,7 +11593,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -11593,7 +11593,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
11593 else11593 else
11594 operand_ty;11594 operand_ty;
1159511595
11596 if (operand_err_set.zigTypeTag(zcu) != .ErrorUnion) {11596 if (operand_err_set.zigTypeTag(zcu) != .error_union) {
11597 return sema.fail(block, switch_src, "expected error union type, found '{}'", .{11597 return sema.fail(block, switch_src, "expected error union type, found '{}'", .{
11598 operand_ty.fmt(pt),11598 operand_ty.fmt(pt),
11599 });11599 });
...@@ -11791,7 +11791,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp...@@ -11791,7 +11791,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
11791 true,11791 true,
11792 );11792 );
1179311793
11794 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +11794 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
11795 true_instructions.len + sub_block.instructions.items.len);11795 true_instructions.len + sub_block.instructions.items.len);
1179611796
11797 _ = try child_block.addInst(.{11797 _ = try child_block.addInst(.{
...@@ -11886,7 +11886,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -11886,7 +11886,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
11886 };11886 };
1188711887
11888 const maybe_union_ty = sema.typeOf(raw_operand_val);11888 const maybe_union_ty = sema.typeOf(raw_operand_val);
11889 const union_originally = maybe_union_ty.zigTypeTag(zcu) == .Union;11889 const union_originally = maybe_union_ty.zigTypeTag(zcu) == .@"union";
1189011890
11891 // Duplicate checking variables later also used for `inline else`.11891 // Duplicate checking variables later also used for `inline else`.
11892 var seen_enum_fields: []?LazySrcLoc = &.{};11892 var seen_enum_fields: []?LazySrcLoc = &.{};
...@@ -11904,7 +11904,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -11904,7 +11904,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
11904 var empty_enum = false;11904 var empty_enum = false;
1190511905
11906 const operand_ty = sema.typeOf(operand);11906 const operand_ty = sema.typeOf(operand);
11907 const err_set = operand_ty.zigTypeTag(zcu) == .ErrorSet;11907 const err_set = operand_ty.zigTypeTag(zcu) == .error_set;
1190811908
11909 var else_error_ty: ?Type = null;11909 var else_error_ty: ?Type = null;
1191011910
...@@ -11936,8 +11936,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -11936,8 +11936,8 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
1193611936
11937 // Validate for duplicate items, missing else prong, and invalid range.11937 // Validate for duplicate items, missing else prong, and invalid range.
11938 switch (operand_ty.zigTypeTag(zcu)) {11938 switch (operand_ty.zigTypeTag(zcu)) {
11939 .Union => unreachable, // handled in `switchCond`11939 .@"union" => unreachable, // handled in `switchCond`
11940 .Enum => {11940 .@"enum" => {
11941 seen_enum_fields = try gpa.alloc(?LazySrcLoc, operand_ty.enumFieldCount(zcu));11941 seen_enum_fields = try gpa.alloc(?LazySrcLoc, operand_ty.enumFieldCount(zcu));
11942 empty_enum = seen_enum_fields.len == 0 and !operand_ty.isNonexhaustiveEnum(zcu);11942 empty_enum = seen_enum_fields.len == 0 and !operand_ty.isNonexhaustiveEnum(zcu);
11943 @memset(seen_enum_fields, null);11943 @memset(seen_enum_fields, null);
...@@ -12046,7 +12046,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12046,7 +12046,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12046 );12046 );
12047 }12047 }
12048 },12048 },
12049 .ErrorSet => else_error_ty = try validateErrSetSwitch(12049 .error_set => else_error_ty = try validateErrSetSwitch(
12050 sema,12050 sema,
12051 block,12051 block,
12052 &seen_errors,12052 &seen_errors,
...@@ -12058,7 +12058,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12058,7 +12058,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12058 .{ .body = special.body, .end = special.end, .src = special_prong_src },12058 .{ .body = special.body, .end = special.end, .src = special_prong_src },
12059 special_prong == .@"else",12059 special_prong == .@"else",
12060 ),12060 ),
12061 .Int, .ComptimeInt => {12061 .int, .comptime_int => {
12062 var extra_index: usize = special.end;12062 var extra_index: usize = special.end;
12063 {12063 {
12064 var scalar_i: u32 = 0;12064 var scalar_i: u32 = 0;
...@@ -12137,7 +12137,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12137,7 +12137,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12137 }12137 }
1213812138
12139 check_range: {12139 check_range: {
12140 if (operand_ty.zigTypeTag(zcu) == .Int) {12140 if (operand_ty.zigTypeTag(zcu) == .int) {
12141 const min_int = try operand_ty.minInt(pt, operand_ty);12141 const min_int = try operand_ty.minInt(pt, operand_ty);
12142 const max_int = try operand_ty.maxInt(pt, operand_ty);12142 const max_int = try operand_ty.maxInt(pt, operand_ty);
12143 if (try range_set.spans(min_int.toIntern(), max_int.toIntern())) {12143 if (try range_set.spans(min_int.toIntern(), max_int.toIntern())) {
...@@ -12162,7 +12162,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12162,7 +12162,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12162 }12162 }
12163 }12163 }
12164 },12164 },
12165 .Bool => {12165 .bool => {
12166 var extra_index: usize = special.end;12166 var extra_index: usize = special.end;
12167 {12167 {
12168 var scalar_i: u32 = 0;12168 var scalar_i: u32 = 0;
...@@ -12238,7 +12238,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12238,7 +12238,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12238 },12238 },
12239 }12239 }
12240 },12240 },
12241 .EnumLiteral, .Void, .Fn, .Pointer, .Type => {12241 .enum_literal, .void, .@"fn", .pointer, .type => {
12242 if (special_prong != .@"else") {12242 if (special_prong != .@"else") {
12243 return sema.fail(12243 return sema.fail(
12244 block,12244 block,
...@@ -12306,19 +12306,19 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12306,19 +12306,19 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12306 }12306 }
12307 },12307 },
1230812308
12309 .ErrorUnion,12309 .error_union,
12310 .NoReturn,12310 .noreturn,
12311 .Array,12311 .array,
12312 .Struct,12312 .@"struct",
12313 .Undefined,12313 .undefined,
12314 .Null,12314 .null,
12315 .Optional,12315 .optional,
12316 .Opaque,12316 .@"opaque",
12317 .Vector,12317 .vector,
12318 .Frame,12318 .frame,
12319 .AnyFrame,12319 .@"anyframe",
12320 .ComptimeFloat,12320 .comptime_float,
12321 .Float,12321 .float,
12322 => return sema.fail(block, operand_src, "invalid switch operand type '{}'", .{12322 => return sema.fail(block, operand_src, "invalid switch operand type '{}'", .{
12323 operand_ty.fmt(pt),12323 operand_ty.fmt(pt),
12324 }),12324 }),
...@@ -12401,7 +12401,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r...@@ -12401,7 +12401,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r
12401 if (err_set and try sema.maybeErrorUnwrap(block, special.body, operand, operand_src, false)) {12401 if (err_set and try sema.maybeErrorUnwrap(block, special.body, operand, operand_src, false)) {
12402 return .unreachable_value;12402 return .unreachable_value;
12403 }12403 }
12404 if (zcu.backendSupportsFeature(.is_named_enum_value) and block.wantSafety() and operand_ty.zigTypeTag(zcu) == .Enum and12404 if (zcu.backendSupportsFeature(.is_named_enum_value) and block.wantSafety() and operand_ty.zigTypeTag(zcu) == .@"enum" and
12405 (!operand_ty.isNonexhaustiveEnum(zcu) or union_originally))12405 (!operand_ty.isNonexhaustiveEnum(zcu) or union_originally))
12406 {12406 {
12407 try sema.zirDbgStmt(block, cond_dbg_node_index);12407 try sema.zirDbgStmt(block, cond_dbg_node_index);
...@@ -12502,7 +12502,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12502,7 +12502,7 @@ fn analyzeSwitchRuntimeBlock(
12502 const block = child_block.parent.?;12502 const block = child_block.parent.?;
1250312503
12504 const estimated_cases_extra = (scalar_cases_len + multi_cases_len) *12504 const estimated_cases_extra = (scalar_cases_len + multi_cases_len) *
12505 @typeInfo(Air.SwitchBr.Case).Struct.fields.len + 2;12505 @typeInfo(Air.SwitchBr.Case).@"struct".fields.len + 2;
12506 var cases_extra = try std.ArrayListUnmanaged(u32).initCapacity(gpa, estimated_cases_extra);12506 var cases_extra = try std.ArrayListUnmanaged(u32).initCapacity(gpa, estimated_cases_extra);
12507 defer cases_extra.deinit(gpa);12507 defer cases_extra.deinit(gpa);
1250812508
...@@ -12536,7 +12536,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12536,7 +12536,7 @@ fn analyzeSwitchRuntimeBlock(
12536 const unresolved_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable;12536 const unresolved_item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable;
12537 const item_val = sema.resolveLazyValue(unresolved_item_val) catch unreachable;12537 const item_val = sema.resolveLazyValue(unresolved_item_val) catch unreachable;
12538 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;12538 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;
12539 break :blk field_ty.zigTypeTag(zcu) != .NoReturn;12539 break :blk field_ty.zigTypeTag(zcu) != .noreturn;
12540 } else true;12540 } else true;
1254112541
12542 const prong_hint: std.builtin.BranchHint = if (err_set and12542 const prong_hint: std.builtin.BranchHint = if (err_set and
...@@ -12669,7 +12669,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12669,7 +12669,7 @@ fn analyzeSwitchRuntimeBlock(
12669 const analyze_body = if (union_originally) blk: {12669 const analyze_body = if (union_originally) blk: {
12670 const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable;12670 const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable;
12671 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;12671 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;
12672 break :blk field_ty.zigTypeTag(zcu) != .NoReturn;12672 break :blk field_ty.zigTypeTag(zcu) != .noreturn;
12673 } else true;12673 } else true;
1267412674
12675 if (emit_bb) try sema.emitBackwardBranch(block, block.src(.{ .switch_case_item = .{12675 if (emit_bb) try sema.emitBackwardBranch(block, block.src(.{ .switch_case_item = .{
...@@ -12722,7 +12722,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12722,7 +12722,7 @@ fn analyzeSwitchRuntimeBlock(
12722 for (items) |item| {12722 for (items) |item| {
12723 const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable;12723 const item_val = sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, item, undefined) catch unreachable;
12724 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;12724 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;
12725 if (field_ty.zigTypeTag(zcu) != .NoReturn) break true;12725 if (field_ty.zigTypeTag(zcu) != .noreturn) break true;
12726 } else false12726 } else false
12727 else12727 else
12728 true;12728 true;
...@@ -12847,7 +12847,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12847,7 +12847,7 @@ fn analyzeSwitchRuntimeBlock(
12847 } else {12847 } else {
12848 try sema.air_extra.ensureUnusedCapacity(12848 try sema.air_extra.ensureUnusedCapacity(
12849 gpa,12849 gpa,
12850 @typeInfo(Air.CondBr).Struct.fields.len + prev_then_body.len + cond_body.len,12850 @typeInfo(Air.CondBr).@"struct".fields.len + prev_then_body.len + cond_body.len,
12851 );12851 );
1285212852
12853 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{12853 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{
...@@ -12869,7 +12869,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12869,7 +12869,7 @@ fn analyzeSwitchRuntimeBlock(
12869 if (special.body.len != 0 or !is_first or case_block.wantSafety()) {12869 if (special.body.len != 0 or !is_first or case_block.wantSafety()) {
12870 var emit_bb = false;12870 var emit_bb = false;
12871 if (special.is_inline) switch (operand_ty.zigTypeTag(zcu)) {12871 if (special.is_inline) switch (operand_ty.zigTypeTag(zcu)) {
12872 .Enum => {12872 .@"enum" => {
12873 if (operand_ty.isNonexhaustiveEnum(zcu) and !union_originally) {12873 if (operand_ty.isNonexhaustiveEnum(zcu) and !union_originally) {
12874 return sema.fail(block, special_prong_src, "cannot enumerate values of type '{}' for 'inline else'", .{12874 return sema.fail(block, special_prong_src, "cannot enumerate values of type '{}' for 'inline else'", .{
12875 operand_ty.fmt(pt),12875 operand_ty.fmt(pt),
...@@ -12887,7 +12887,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12887,7 +12887,7 @@ fn analyzeSwitchRuntimeBlock(
1288712887
12888 const analyze_body = if (union_originally) blk: {12888 const analyze_body = if (union_originally) blk: {
12889 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;12889 const field_ty = maybe_union_ty.unionFieldType(item_val, zcu).?;
12890 break :blk field_ty.zigTypeTag(zcu) != .NoReturn;12890 break :blk field_ty.zigTypeTag(zcu) != .noreturn;
12891 } else true;12891 } else true;
1289212892
12893 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);12893 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
...@@ -12920,7 +12920,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12920,7 +12920,7 @@ fn analyzeSwitchRuntimeBlock(
12920 cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));12920 cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));
12921 }12921 }
12922 },12922 },
12923 .ErrorSet => {12923 .error_set => {
12924 if (operand_ty.isAnyError(zcu)) {12924 if (operand_ty.isAnyError(zcu)) {
12925 return sema.fail(block, special_prong_src, "cannot enumerate values of type '{}' for 'inline else'", .{12925 return sema.fail(block, special_prong_src, "cannot enumerate values of type '{}' for 'inline else'", .{
12926 operand_ty.fmt(pt),12926 operand_ty.fmt(pt),
...@@ -12966,7 +12966,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -12966,7 +12966,7 @@ fn analyzeSwitchRuntimeBlock(
12966 cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));12966 cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));
12967 }12967 }
12968 },12968 },
12969 .Int => {12969 .int => {
12970 var it = try RangeSetUnhandledIterator.init(sema, operand_ty, range_set);12970 var it = try RangeSetUnhandledIterator.init(sema, operand_ty, range_set);
12971 while (try it.next()) |cur| {12971 while (try it.next()) |cur| {
12972 cases_len += 1;12972 cases_len += 1;
...@@ -13001,7 +13001,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13001,7 +13001,7 @@ fn analyzeSwitchRuntimeBlock(
13001 cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));13001 cases_extra.appendSliceAssumeCapacity(@ptrCast(case_block.instructions.items));
13002 }13002 }
13003 },13003 },
13004 .Bool => {13004 .bool => {
13005 if (true_count == 0) {13005 if (true_count == 0) {
13006 cases_len += 1;13006 cases_len += 1;
1300713007
...@@ -13073,7 +13073,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13073,7 +13073,7 @@ fn analyzeSwitchRuntimeBlock(
1307313073
13074 if (zcu.backendSupportsFeature(.is_named_enum_value) and13074 if (zcu.backendSupportsFeature(.is_named_enum_value) and
13075 special.body.len != 0 and block.wantSafety() and13075 special.body.len != 0 and block.wantSafety() and
13076 operand_ty.zigTypeTag(zcu) == .Enum and13076 operand_ty.zigTypeTag(zcu) == .@"enum" and
13077 (!operand_ty.isNonexhaustiveEnum(zcu) or union_originally))13077 (!operand_ty.isNonexhaustiveEnum(zcu) or union_originally))
13078 {13078 {
13079 try sema.zirDbgStmt(&case_block, cond_dbg_node_index);13079 try sema.zirDbgStmt(&case_block, cond_dbg_node_index);
...@@ -13086,7 +13086,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13086,7 +13086,7 @@ fn analyzeSwitchRuntimeBlock(
13086 if (seen_field != null) continue;13086 if (seen_field != null) continue;
13087 const union_obj = zcu.typeToUnion(maybe_union_ty).?;13087 const union_obj = zcu.typeToUnion(maybe_union_ty).?;
13088 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[index]);13088 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[index]);
13089 if (field_ty.zigTypeTag(zcu) != .NoReturn) break true;13089 if (field_ty.zigTypeTag(zcu) != .noreturn) break true;
13090 } else false13090 } else false
13091 else13091 else
13092 true;13092 true;
...@@ -13128,7 +13128,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13128,7 +13128,7 @@ fn analyzeSwitchRuntimeBlock(
13128 } else {13128 } else {
13129 try branch_hints.append(gpa, .none); // we have the range conditionals first13129 try branch_hints.append(gpa, .none); // we have the range conditionals first
13130 try sema.air_extra.ensureUnusedCapacity(gpa, prev_then_body.len +13130 try sema.air_extra.ensureUnusedCapacity(gpa, prev_then_body.len +
13131 @typeInfo(Air.CondBr).Struct.fields.len + case_block.instructions.items.len);13131 @typeInfo(Air.CondBr).@"struct".fields.len + case_block.instructions.items.len);
1313213132
13133 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{13133 sema.air_instructions.items(.data)[@intFromEnum(prev_cond_br)].pl_op.payload = sema.addExtraAssumeCapacity(Air.CondBr{
13134 .then_body_len = @intCast(prev_then_body.len),13134 .then_body_len = @intCast(prev_then_body.len),
...@@ -13145,7 +13145,7 @@ fn analyzeSwitchRuntimeBlock(...@@ -13145,7 +13145,7 @@ fn analyzeSwitchRuntimeBlock(
1314513145
13146 assert(branch_hints.items.len == cases_len + 1);13146 assert(branch_hints.items.len == cases_len + 1);
1314713147
13148 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).Struct.fields.len +13148 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.SwitchBr).@"struct".fields.len +
13149 cases_extra.items.len + final_else_body.len +13149 cases_extra.items.len + final_else_body.len +
13150 (std.math.divCeil(usize, branch_hints.items.len, 10) catch unreachable)); // branch hints13150 (std.math.divCeil(usize, branch_hints.items.len, 10) catch unreachable)); // branch hints
1315113151
...@@ -13847,7 +13847,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind...@@ -13847,7 +13847,7 @@ fn maybeErrorUnwrapCondbr(sema: *Sema, block: *Block, body: []const Zir.Inst.Ind
13847 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;13847 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;
13848 const err_operand = try sema.resolveInst(err_inst_data.operand);13848 const err_operand = try sema.resolveInst(err_inst_data.operand);
13849 const operand_ty = sema.typeOf(err_operand);13849 const operand_ty = sema.typeOf(err_operand);
13850 if (operand_ty.zigTypeTag(zcu) == .ErrorSet) {13850 if (operand_ty.zigTypeTag(zcu) == .error_set) {
13851 try sema.maybeErrorUnwrapComptime(block, body, err_operand);13851 try sema.maybeErrorUnwrapComptime(block, body, err_operand);
13852 return;13852 return;
13853 }13853 }
...@@ -14076,9 +14076,9 @@ fn zirShl(...@@ -14076,9 +14076,9 @@ fn zirShl(
14076 if (try rhs_val.compareAllWithZeroSema(.eq, pt)) {14076 if (try rhs_val.compareAllWithZeroSema(.eq, pt)) {
14077 return lhs;14077 return lhs;
14078 }14078 }
14079 if (scalar_ty.zigTypeTag(zcu) != .ComptimeInt and air_tag != .shl_sat) {14079 if (scalar_ty.zigTypeTag(zcu) != .comptime_int and air_tag != .shl_sat) {
14080 const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits);14080 const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits);
14081 if (rhs_ty.zigTypeTag(zcu) == .Vector) {14081 if (rhs_ty.zigTypeTag(zcu) == .vector) {
14082 var i: usize = 0;14082 var i: usize = 0;
14083 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {14083 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {
14084 const rhs_elem = try rhs_val.elemValue(pt, i);14084 const rhs_elem = try rhs_val.elemValue(pt, i);
...@@ -14097,7 +14097,7 @@ fn zirShl(...@@ -14097,7 +14097,7 @@ fn zirShl(
14097 });14097 });
14098 }14098 }
14099 }14099 }
14100 if (rhs_ty.zigTypeTag(zcu) == .Vector) {14100 if (rhs_ty.zigTypeTag(zcu) == .vector) {
14101 var i: usize = 0;14101 var i: usize = 0;
14102 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {14102 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {
14103 const rhs_elem = try rhs_val.elemValue(pt, i);14103 const rhs_elem = try rhs_val.elemValue(pt, i);
...@@ -14118,12 +14118,12 @@ fn zirShl(...@@ -14118,12 +14118,12 @@ fn zirShl(
14118 const runtime_src = if (maybe_lhs_val) |lhs_val| rs: {14118 const runtime_src = if (maybe_lhs_val) |lhs_val| rs: {
14119 if (lhs_val.isUndef(zcu)) return pt.undefRef(lhs_ty);14119 if (lhs_val.isUndef(zcu)) return pt.undefRef(lhs_ty);
14120 const rhs_val = maybe_rhs_val orelse {14120 const rhs_val = maybe_rhs_val orelse {
14121 if (scalar_ty.zigTypeTag(zcu) == .ComptimeInt) {14121 if (scalar_ty.zigTypeTag(zcu) == .comptime_int) {
14122 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});14122 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});
14123 }14123 }
14124 break :rs rhs_src;14124 break :rs rhs_src;
14125 };14125 };
14126 const val = if (scalar_ty.zigTypeTag(zcu) == .ComptimeInt)14126 const val = if (scalar_ty.zigTypeTag(zcu) == .comptime_int)
14127 try lhs_val.shl(rhs_val, lhs_ty, sema.arena, pt)14127 try lhs_val.shl(rhs_val, lhs_ty, sema.arena, pt)
14128 else switch (air_tag) {14128 else switch (air_tag) {
14129 .shl_exact => val: {14129 .shl_exact => val: {
...@@ -14158,7 +14158,7 @@ fn zirShl(...@@ -14158,7 +14158,7 @@ fn zirShl(
14158 const bit_count = scalar_ty.intInfo(zcu).bits;14158 const bit_count = scalar_ty.intInfo(zcu).bits;
14159 if (!std.math.isPowerOfTwo(bit_count)) {14159 if (!std.math.isPowerOfTwo(bit_count)) {
14160 const bit_count_val = try pt.intValue(scalar_rhs_ty, bit_count);14160 const bit_count_val = try pt.intValue(scalar_rhs_ty, bit_count);
14161 const ok = if (rhs_ty.zigTypeTag(zcu) == .Vector) ok: {14161 const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: {
14162 const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());14162 const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());
14163 const lt = try block.addCmpVector(rhs, bit_count_inst, .lt);14163 const lt = try block.addCmpVector(rhs, bit_count_inst, .lt);
14164 break :ok try block.addInst(.{14164 break :ok try block.addInst(.{
...@@ -14188,7 +14188,7 @@ fn zirShl(...@@ -14188,7 +14188,7 @@ fn zirShl(
14188 } },14188 } },
14189 });14189 });
14190 const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty);14190 const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty);
14191 const any_ov_bit = if (lhs_ty.zigTypeTag(zcu) == .Vector)14191 const any_ov_bit = if (lhs_ty.zigTypeTag(zcu) == .vector)
14192 try block.addInst(.{14192 try block.addInst(.{
14193 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,14193 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,
14194 .data = .{ .reduce = .{14194 .data = .{ .reduce = .{
...@@ -14242,9 +14242,9 @@ fn zirShr(...@@ -14242,9 +14242,9 @@ fn zirShr(
14242 if (try rhs_val.compareAllWithZeroSema(.eq, pt)) {14242 if (try rhs_val.compareAllWithZeroSema(.eq, pt)) {
14243 return lhs;14243 return lhs;
14244 }14244 }
14245 if (scalar_ty.zigTypeTag(zcu) != .ComptimeInt) {14245 if (scalar_ty.zigTypeTag(zcu) != .comptime_int) {
14246 const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits);14246 const bit_value = try pt.intValue(Type.comptime_int, scalar_ty.intInfo(zcu).bits);
14247 if (rhs_ty.zigTypeTag(zcu) == .Vector) {14247 if (rhs_ty.zigTypeTag(zcu) == .vector) {
14248 var i: usize = 0;14248 var i: usize = 0;
14249 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {14249 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {
14250 const rhs_elem = try rhs_val.elemValue(pt, i);14250 const rhs_elem = try rhs_val.elemValue(pt, i);
...@@ -14263,7 +14263,7 @@ fn zirShr(...@@ -14263,7 +14263,7 @@ fn zirShr(
14263 });14263 });
14264 }14264 }
14265 }14265 }
14266 if (rhs_ty.zigTypeTag(zcu) == .Vector) {14266 if (rhs_ty.zigTypeTag(zcu) == .vector) {
14267 var i: usize = 0;14267 var i: usize = 0;
14268 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {14268 while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {
14269 const rhs_elem = try rhs_val.elemValue(pt, i);14269 const rhs_elem = try rhs_val.elemValue(pt, i);
...@@ -14297,7 +14297,7 @@ fn zirShr(...@@ -14297,7 +14297,7 @@ fn zirShr(
14297 }14297 }
14298 } else rhs_src;14298 } else rhs_src;
1429914299
14300 if (maybe_rhs_val == null and scalar_ty.zigTypeTag(zcu) == .ComptimeInt) {14300 if (maybe_rhs_val == null and scalar_ty.zigTypeTag(zcu) == .comptime_int) {
14301 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});14301 return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});
14302 }14302 }
1430314303
...@@ -14308,7 +14308,7 @@ fn zirShr(...@@ -14308,7 +14308,7 @@ fn zirShr(
14308 if (!std.math.isPowerOfTwo(bit_count)) {14308 if (!std.math.isPowerOfTwo(bit_count)) {
14309 const bit_count_val = try pt.intValue(rhs_ty.scalarType(zcu), bit_count);14309 const bit_count_val = try pt.intValue(rhs_ty.scalarType(zcu), bit_count);
1431014310
14311 const ok = if (rhs_ty.zigTypeTag(zcu) == .Vector) ok: {14311 const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: {
14312 const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());14312 const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());
14313 const lt = try block.addCmpVector(rhs, bit_count_inst, .lt);14313 const lt = try block.addCmpVector(rhs, bit_count_inst, .lt);
14314 break :ok try block.addInst(.{14314 break :ok try block.addInst(.{
...@@ -14328,7 +14328,7 @@ fn zirShr(...@@ -14328,7 +14328,7 @@ fn zirShr(
14328 if (air_tag == .shr_exact) {14328 if (air_tag == .shr_exact) {
14329 const back = try block.addBinOp(.shl, result, rhs);14329 const back = try block.addBinOp(.shl, result, rhs);
1433014330
14331 const ok = if (rhs_ty.zigTypeTag(zcu) == .Vector) ok: {14331 const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: {
14332 const eql = try block.addCmpVector(lhs, back, .eq);14332 const eql = try block.addCmpVector(lhs, back, .eq);
14333 break :ok try block.addInst(.{14333 break :ok try block.addInst(.{
14334 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,14334 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,
...@@ -14374,7 +14374,7 @@ fn zirBitwise(...@@ -14374,7 +14374,7 @@ fn zirBitwise(
14374 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);14374 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
14375 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src);14375 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src);
1437614376
14377 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;14377 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1437814378
14379 if (!is_int) {14379 if (!is_int) {
14380 return sema.fail(block, src, "invalid operands to binary bitwise expression: '{s}' and '{s}'", .{ @tagName(lhs_ty.zigTypeTag(zcu)), @tagName(rhs_ty.zigTypeTag(zcu)) });14380 return sema.fail(block, src, "invalid operands to binary bitwise expression: '{s}' and '{s}'", .{ @tagName(lhs_ty.zigTypeTag(zcu)), @tagName(rhs_ty.zigTypeTag(zcu)) });
...@@ -14418,7 +14418,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14418,7 +14418,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
14418 const operand_type = sema.typeOf(operand);14418 const operand_type = sema.typeOf(operand);
14419 const scalar_type = operand_type.scalarType(zcu);14419 const scalar_type = operand_type.scalarType(zcu);
1442014420
14421 if (scalar_type.zigTypeTag(zcu) != .Int) {14421 if (scalar_type.zigTypeTag(zcu) != .int) {
14422 return sema.fail(block, src, "unable to perform binary not operation on type '{}'", .{14422 return sema.fail(block, src, "unable to perform binary not operation on type '{}'", .{
14423 operand_type.fmt(pt),14423 operand_type.fmt(pt),
14424 });14424 });
...@@ -14427,7 +14427,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -14427,7 +14427,7 @@ fn zirBitNot(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
14427 if (try sema.resolveValue(operand)) |val| {14427 if (try sema.resolveValue(operand)) |val| {
14428 if (val.isUndef(zcu)) {14428 if (val.isUndef(zcu)) {
14429 return pt.undefRef(operand_type);14429 return pt.undefRef(operand_type);
14430 } else if (operand_type.zigTypeTag(zcu) == .Vector) {14430 } else if (operand_type.zigTypeTag(zcu) == .vector) {
14431 const vec_len = try sema.usizeCast(block, operand_src, operand_type.vectorLen(zcu));14431 const vec_len = try sema.usizeCast(block, operand_src, operand_type.vectorLen(zcu));
14432 const elems = try sema.arena.alloc(InternPool.Index, vec_len);14432 const elems = try sema.arena.alloc(InternPool.Index, vec_len);
14433 for (elems, 0..) |*elem, i| {14433 for (elems, 0..) |*elem, i| {
...@@ -14647,19 +14647,19 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14647,19 +14647,19 @@ fn zirArrayCat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14647 .child = resolved_elem_ty.toIntern(),14647 .child = resolved_elem_ty.toIntern(),
14648 });14648 });
14649 const ptr_addrspace = p: {14649 const ptr_addrspace = p: {
14650 if (lhs_ty.zigTypeTag(zcu) == .Pointer) break :p lhs_ty.ptrAddressSpace(zcu);14650 if (lhs_ty.zigTypeTag(zcu) == .pointer) break :p lhs_ty.ptrAddressSpace(zcu);
14651 if (rhs_ty.zigTypeTag(zcu) == .Pointer) break :p rhs_ty.ptrAddressSpace(zcu);14651 if (rhs_ty.zigTypeTag(zcu) == .pointer) break :p rhs_ty.ptrAddressSpace(zcu);
14652 break :p null;14652 break :p null;
14653 };14653 };
1465414654
14655 const runtime_src = if (switch (lhs_ty.zigTypeTag(zcu)) {14655 const runtime_src = if (switch (lhs_ty.zigTypeTag(zcu)) {
14656 .Array, .Struct => try sema.resolveValue(lhs),14656 .array, .@"struct" => try sema.resolveValue(lhs),
14657 .Pointer => try sema.resolveDefinedValue(block, lhs_src, lhs),14657 .pointer => try sema.resolveDefinedValue(block, lhs_src, lhs),
14658 else => unreachable,14658 else => unreachable,
14659 }) |lhs_val| rs: {14659 }) |lhs_val| rs: {
14660 if (switch (rhs_ty.zigTypeTag(zcu)) {14660 if (switch (rhs_ty.zigTypeTag(zcu)) {
14661 .Array, .Struct => try sema.resolveValue(rhs),14661 .array, .@"struct" => try sema.resolveValue(rhs),
14662 .Pointer => try sema.resolveDefinedValue(block, rhs_src, rhs),14662 .pointer => try sema.resolveDefinedValue(block, rhs_src, rhs),
14663 else => unreachable,14663 else => unreachable,
14664 }) |rhs_val| {14664 }) |rhs_val| {
14665 const lhs_sub_val = if (lhs_ty.isSinglePointer(zcu))14665 const lhs_sub_val = if (lhs_ty.isSinglePointer(zcu))
...@@ -14789,8 +14789,8 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins...@@ -14789,8 +14789,8 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
14789 const zcu = pt.zcu;14789 const zcu = pt.zcu;
14790 const operand_ty = sema.typeOf(operand);14790 const operand_ty = sema.typeOf(operand);
14791 switch (operand_ty.zigTypeTag(zcu)) {14791 switch (operand_ty.zigTypeTag(zcu)) {
14792 .Array => return operand_ty.arrayInfo(zcu),14792 .array => return operand_ty.arrayInfo(zcu),
14793 .Pointer => {14793 .pointer => {
14794 const ptr_info = operand_ty.ptrInfo(zcu);14794 const ptr_info = operand_ty.ptrInfo(zcu);
14795 switch (ptr_info.flags.size) {14795 switch (ptr_info.flags.size) {
14796 .Slice => {14796 .Slice => {
...@@ -14807,14 +14807,14 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins...@@ -14807,14 +14807,14 @@ fn getArrayCatInfo(sema: *Sema, block: *Block, src: LazySrcLoc, operand: Air.Ins
14807 };14807 };
14808 },14808 },
14809 .One => {14809 .One => {
14810 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Array) {14810 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
14811 return Type.fromInterned(ptr_info.child).arrayInfo(zcu);14811 return Type.fromInterned(ptr_info.child).arrayInfo(zcu);
14812 }14812 }
14813 },14813 },
14814 .C, .Many => {},14814 .C, .Many => {},
14815 }14815 }
14816 },14816 },
14817 .Struct => {14817 .@"struct" => {
14818 if (operand_ty.isTuple(zcu) and peer_ty.isIndexable(zcu)) {14818 if (operand_ty.isTuple(zcu) and peer_ty.isIndexable(zcu)) {
14819 assert(!peer_ty.isTuple(zcu));14819 assert(!peer_ty.isTuple(zcu));
14820 return .{14820 return .{
...@@ -14934,12 +14934,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14934,12 +14934,12 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14934 const lhs_len = uncoerced_lhs_ty.structFieldCount(zcu);14934 const lhs_len = uncoerced_lhs_ty.structFieldCount(zcu);
14935 const lhs_dest_ty = switch (res_ty.zigTypeTag(zcu)) {14935 const lhs_dest_ty = switch (res_ty.zigTypeTag(zcu)) {
14936 else => break :no_coerce,14936 else => break :no_coerce,
14937 .Array => try pt.arrayType(.{14937 .array => try pt.arrayType(.{
14938 .child = res_ty.childType(zcu).toIntern(),14938 .child = res_ty.childType(zcu).toIntern(),
14939 .len = lhs_len,14939 .len = lhs_len,
14940 .sentinel = if (res_ty.sentinel(zcu)) |s| s.toIntern() else .none,14940 .sentinel = if (res_ty.sentinel(zcu)) |s| s.toIntern() else .none,
14941 }),14941 }),
14942 .Vector => try pt.vectorType(.{14942 .vector => try pt.vectorType(.{
14943 .child = res_ty.childType(zcu).toIntern(),14943 .child = res_ty.childType(zcu).toIntern(),
14944 .len = lhs_len,14944 .len = lhs_len,
14945 }),14945 }),
...@@ -14971,7 +14971,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14971,7 +14971,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14971 const msg = try sema.errMsg(lhs_src, "expected indexable; found '{}'", .{lhs_ty.fmt(pt)});14971 const msg = try sema.errMsg(lhs_src, "expected indexable; found '{}'", .{lhs_ty.fmt(pt)});
14972 errdefer msg.destroy(sema.gpa);14972 errdefer msg.destroy(sema.gpa);
14973 switch (lhs_ty.zigTypeTag(zcu)) {14973 switch (lhs_ty.zigTypeTag(zcu)) {
14974 .Int, .Float, .ComptimeFloat, .ComptimeInt, .Vector => {14974 .int, .float, .comptime_float, .comptime_int, .vector => {
14975 try sema.errNote(operator_src, msg, "this operator multiplies arrays; use std.math.pow for exponentiation", .{});14975 try sema.errNote(operator_src, msg, "this operator multiplies arrays; use std.math.pow for exponentiation", .{});
14976 },14976 },
14977 else => {},14977 else => {},
...@@ -14996,7 +14996,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -14996,7 +14996,7 @@ fn zirArrayMul(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
14996 .child = lhs_info.elem_type.toIntern(),14996 .child = lhs_info.elem_type.toIntern(),
14997 });14997 });
1499814998
14999 const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .Pointer) lhs_ty.ptrAddressSpace(zcu) else null;14999 const ptr_addrspace = if (lhs_ty.zigTypeTag(zcu) == .pointer) lhs_ty.ptrAddressSpace(zcu) else null;
15000 const lhs_len = try sema.usizeCast(block, lhs_src, lhs_info.len);15000 const lhs_len = try sema.usizeCast(block, lhs_src, lhs_info.len);
1500115001
15002 if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| ct: {15002 if (try sema.resolveDefinedValue(block, lhs_src, lhs)) |lhs_val| ct: {
...@@ -15096,7 +15096,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -15096,7 +15096,7 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
15096 const rhs_scalar_ty = rhs_ty.scalarType(zcu);15096 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
1509715097
15098 if (rhs_scalar_ty.isUnsignedInt(zcu) or switch (rhs_scalar_ty.zigTypeTag(zcu)) {15098 if (rhs_scalar_ty.isUnsignedInt(zcu) or switch (rhs_scalar_ty.zigTypeTag(zcu)) {
15099 .Int, .ComptimeInt, .Float, .ComptimeFloat => false,15099 .int, .comptime_int, .float, .comptime_float => false,
15100 else => true,15100 else => true,
15101 }) {15101 }) {
15102 return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(pt)});15102 return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(pt)});
...@@ -15129,7 +15129,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -15129,7 +15129,7 @@ fn zirNegateWrap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
15129 const rhs_scalar_ty = rhs_ty.scalarType(zcu);15129 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
1513015130
15131 switch (rhs_scalar_ty.zigTypeTag(zcu)) {15131 switch (rhs_scalar_ty.zigTypeTag(zcu)) {
15132 .Int, .ComptimeInt, .Float, .ComptimeFloat => {},15132 .int, .comptime_int, .float, .comptime_float => {},
15133 else => return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(pt)}),15133 else => return sema.fail(block, src, "negation of type '{}'", .{rhs_ty.fmt(pt)}),
15134 }15134 }
1513515135
...@@ -15187,15 +15187,15 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -15187,15 +15187,15 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
15187 const rhs_scalar_ty = rhs_ty.scalarType(zcu);15187 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
15188 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);15188 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1518915189
15190 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;15190 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1519115191
15192 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div);15192 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div);
1519315193
15194 const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs);15194 const maybe_lhs_val = try sema.resolveValueIntable(casted_lhs);
15195 const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs);15195 const maybe_rhs_val = try sema.resolveValueIntable(casted_rhs);
1519615196
15197 if ((lhs_ty.zigTypeTag(zcu) == .ComptimeFloat and rhs_ty.zigTypeTag(zcu) == .ComptimeInt) or15197 if ((lhs_ty.zigTypeTag(zcu) == .comptime_float and rhs_ty.zigTypeTag(zcu) == .comptime_int) or
15198 (lhs_ty.zigTypeTag(zcu) == .ComptimeInt and rhs_ty.zigTypeTag(zcu) == .ComptimeFloat))15198 (lhs_ty.zigTypeTag(zcu) == .comptime_int and rhs_ty.zigTypeTag(zcu) == .comptime_float))
15199 {15199 {
15200 // If it makes a difference whether we coerce to ints or floats before doing the division, error.15200 // If it makes a difference whether we coerce to ints or floats before doing the division, error.
15201 // If lhs % rhs is 0, it doesn't matter.15201 // If lhs % rhs is 0, it doesn't matter.
...@@ -15240,13 +15240,13 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -15240,13 +15240,13 @@ fn zirDiv(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
15240 // * other float type: result is undefined15240 // * other float type: result is undefined
15241 // If the lhs is undefined, result is undefined.15241 // If the lhs is undefined, result is undefined.
15242 switch (scalar_tag) {15242 switch (scalar_tag) {
15243 .Int, .ComptimeInt, .ComptimeFloat => {15243 .int, .comptime_int, .comptime_float => {
15244 if (maybe_lhs_val) |lhs_val| {15244 if (maybe_lhs_val) |lhs_val| {
15245 if (!lhs_val.isUndef(zcu)) {15245 if (!lhs_val.isUndef(zcu)) {
15246 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {15246 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {
15247 const scalar_zero = switch (scalar_tag) {15247 const scalar_zero = switch (scalar_tag) {
15248 .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),15248 .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),
15249 .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0),15249 .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0),
15250 else => unreachable,15250 else => unreachable,
15251 };15251 };
15252 const zero_val = try sema.splat(resolved_type, scalar_zero);15252 const zero_val = try sema.splat(resolved_type, scalar_zero);
...@@ -15352,7 +15352,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15352,7 +15352,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15352 const lhs_scalar_ty = lhs_ty.scalarType(zcu);15352 const lhs_scalar_ty = lhs_ty.scalarType(zcu);
15353 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);15353 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1535415354
15355 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;15355 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1535615356
15357 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact);15357 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_exact);
1535815358
...@@ -15382,8 +15382,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15382,8 +15382,8 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15382 } else {15382 } else {
15383 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {15383 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {
15384 const scalar_zero = switch (scalar_tag) {15384 const scalar_zero = switch (scalar_tag) {
15385 .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),15385 .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),
15386 .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0),15386 .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0),
15387 else => unreachable,15387 else => unreachable,
15388 };15388 };
15389 const zero_val = try sema.splat(resolved_type, scalar_zero);15389 const zero_val = try sema.splat(resolved_type, scalar_zero);
...@@ -15439,7 +15439,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15439,7 +15439,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15439 const ok = if (!is_int) ok: {15439 const ok = if (!is_int) ok: {
15440 const floored = try block.addUnOp(.floor, result);15440 const floored = try block.addUnOp(.floor, result);
1544115441
15442 if (resolved_type.zigTypeTag(zcu) == .Vector) {15442 if (resolved_type.zigTypeTag(zcu) == .vector) {
15443 const eql = try block.addCmpVector(result, floored, .eq);15443 const eql = try block.addCmpVector(result, floored, .eq);
15444 break :ok try block.addInst(.{15444 break :ok try block.addInst(.{
15445 .tag = switch (block.float_mode) {15445 .tag = switch (block.float_mode) {
...@@ -15462,11 +15462,11 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15462,11 +15462,11 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15462 const remainder = try block.addBinOp(.rem, casted_lhs, casted_rhs);15462 const remainder = try block.addBinOp(.rem, casted_lhs, casted_rhs);
1546315463
15464 const scalar_zero = switch (scalar_tag) {15464 const scalar_zero = switch (scalar_tag) {
15465 .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),15465 .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),
15466 .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0),15466 .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0),
15467 else => unreachable,15467 else => unreachable,
15468 };15468 };
15469 if (resolved_type.zigTypeTag(zcu) == .Vector) {15469 if (resolved_type.zigTypeTag(zcu) == .vector) {
15470 const zero_val = try sema.splat(resolved_type, scalar_zero);15470 const zero_val = try sema.splat(resolved_type, scalar_zero);
15471 const zero = Air.internedToRef(zero_val.toIntern());15471 const zero = Air.internedToRef(zero_val.toIntern());
15472 const eql = try block.addCmpVector(remainder, zero, .eq);15472 const eql = try block.addCmpVector(remainder, zero, .eq);
...@@ -15519,7 +15519,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15519,7 +15519,7 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15519 const rhs_scalar_ty = rhs_ty.scalarType(zcu);15519 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
15520 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);15520 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1552115521
15522 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;15522 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1552315523
15524 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor);15524 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_floor);
1552515525
...@@ -15550,8 +15550,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15550,8 +15550,8 @@ fn zirDivFloor(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15550 if (!lhs_val.isUndef(zcu)) {15550 if (!lhs_val.isUndef(zcu)) {
15551 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {15551 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {
15552 const scalar_zero = switch (scalar_tag) {15552 const scalar_zero = switch (scalar_tag) {
15553 .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),15553 .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),
15554 .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0),15554 .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0),
15555 else => unreachable,15555 else => unreachable,
15556 };15556 };
15557 const zero_val = try sema.splat(resolved_type, scalar_zero);15557 const zero_val = try sema.splat(resolved_type, scalar_zero);
...@@ -15630,7 +15630,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15630,7 +15630,7 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15630 const rhs_scalar_ty = rhs_ty.scalarType(zcu);15630 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
15631 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);15631 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1563215632
15633 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;15633 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1563415634
15635 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc);15635 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .div_trunc);
1563615636
...@@ -15661,8 +15661,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15661,8 +15661,8 @@ fn zirDivTrunc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15661 if (!lhs_val.isUndef(zcu)) {15661 if (!lhs_val.isUndef(zcu)) {
15662 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {15662 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {
15663 const scalar_zero = switch (scalar_tag) {15663 const scalar_zero = switch (scalar_tag) {
15664 .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),15664 .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),
15665 .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0),15665 .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0),
15666 else => unreachable,15666 else => unreachable,
15667 };15667 };
15668 const zero_val = try sema.splat(resolved_type, scalar_zero);15668 const zero_val = try sema.splat(resolved_type, scalar_zero);
...@@ -15756,7 +15756,7 @@ fn addDivIntOverflowSafety(...@@ -15756,7 +15756,7 @@ fn addDivIntOverflowSafety(
15756 }15756 }
1575715757
15758 var ok: Air.Inst.Ref = .none;15758 var ok: Air.Inst.Ref = .none;
15759 if (resolved_type.zigTypeTag(zcu) == .Vector) {15759 if (resolved_type.zigTypeTag(zcu) == .vector) {
15760 if (maybe_lhs_val == null) {15760 if (maybe_lhs_val == null) {
15761 const min_int_ref = Air.internedToRef(min_int.toIntern());15761 const min_int_ref = Air.internedToRef(min_int.toIntern());
15762 ok = try block.addCmpVector(casted_lhs, min_int_ref, .neq);15762 ok = try block.addCmpVector(casted_lhs, min_int_ref, .neq);
...@@ -15819,7 +15819,7 @@ fn addDivByZeroSafety(...@@ -15819,7 +15819,7 @@ fn addDivByZeroSafety(
15819 try pt.intValue(resolved_type.scalarType(zcu), 0)15819 try pt.intValue(resolved_type.scalarType(zcu), 0)
15820 else15820 else
15821 try pt.floatValue(resolved_type.scalarType(zcu), 0.0);15821 try pt.floatValue(resolved_type.scalarType(zcu), 0.0);
15822 const ok = if (resolved_type.zigTypeTag(zcu) == .Vector) ok: {15822 const ok = if (resolved_type.zigTypeTag(zcu) == .vector) ok: {
15823 const zero_val = try sema.splat(resolved_type, scalar_zero);15823 const zero_val = try sema.splat(resolved_type, scalar_zero);
15824 const zero = Air.internedToRef(zero_val.toIntern());15824 const zero = Air.internedToRef(zero_val.toIntern());
15825 const ok = try block.addCmpVector(casted_rhs, zero, .neq);15825 const ok = try block.addCmpVector(casted_rhs, zero, .neq);
...@@ -15867,7 +15867,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -15867,7 +15867,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
15867 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },15867 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },
15868 });15868 });
1586915869
15870 const is_vector = resolved_type.zigTypeTag(zcu) == .Vector;15870 const is_vector = resolved_type.zigTypeTag(zcu) == .vector;
1587115871
15872 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);15872 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
15873 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src);15873 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src);
...@@ -15876,7 +15876,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -15876,7 +15876,7 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
15876 const rhs_scalar_ty = rhs_ty.scalarType(zcu);15876 const rhs_scalar_ty = rhs_ty.scalarType(zcu);
15877 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);15877 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1587815878
15879 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;15879 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1588015880
15881 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem);15881 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod_rem);
1588215882
...@@ -15904,8 +15904,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -15904,8 +15904,8 @@ fn zirModRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
15904 }15904 }
15905 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {15905 if (try lhs_val.compareAllWithZeroSema(.eq, pt)) {
15906 const scalar_zero = switch (scalar_tag) {15906 const scalar_zero = switch (scalar_tag) {
15907 .ComptimeFloat, .Float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),15907 .comptime_float, .float => try pt.floatValue(resolved_type.scalarType(zcu), 0.0),
15908 .ComptimeInt, .Int => try pt.intValue(resolved_type.scalarType(zcu), 0),15908 .comptime_int, .int => try pt.intValue(resolved_type.scalarType(zcu), 0),
15909 else => unreachable,15909 else => unreachable,
15910 };15910 };
15911 const zero_val = if (is_vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{15911 const zero_val = if (is_vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{
...@@ -15987,7 +15987,7 @@ fn intRem(...@@ -15987,7 +15987,7 @@ fn intRem(
15987) CompileError!Value {15987) CompileError!Value {
15988 const pt = sema.pt;15988 const pt = sema.pt;
15989 const zcu = pt.zcu;15989 const zcu = pt.zcu;
15990 if (ty.zigTypeTag(zcu) == .Vector) {15990 if (ty.zigTypeTag(zcu) == .vector) {
15991 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu));15991 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu));
15992 const scalar_ty = ty.scalarType(zcu);15992 const scalar_ty = ty.scalarType(zcu);
15993 for (result_data, 0..) |*scalar, i| {15993 for (result_data, 0..) |*scalar, i| {
...@@ -16058,7 +16058,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -16058,7 +16058,7 @@ fn zirMod(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1605816058
16059 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);16059 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1606016060
16061 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;16061 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1606216062
16063 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod);16063 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .mod);
1606416064
...@@ -16154,7 +16154,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins...@@ -16154,7 +16154,7 @@ fn zirRem(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Ins
1615416154
16155 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);16155 const scalar_tag = resolved_type.scalarType(zcu).zigTypeTag(zcu);
1615616156
16157 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;16157 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1615816158
16159 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem);16159 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, .rem);
1616016160
...@@ -16265,7 +16265,7 @@ fn zirOverflowArithmetic(...@@ -16265,7 +16265,7 @@ fn zirOverflowArithmetic(
16265 const lhs = try sema.coerce(block, dest_ty, uncasted_lhs, lhs_src);16265 const lhs = try sema.coerce(block, dest_ty, uncasted_lhs, lhs_src);
16266 const rhs = try sema.coerce(block, rhs_dest_ty, uncasted_rhs, rhs_src);16266 const rhs = try sema.coerce(block, rhs_dest_ty, uncasted_rhs, rhs_src);
1626716267
16268 if (dest_ty.scalarType(zcu).zigTypeTag(zcu) != .Int) {16268 if (dest_ty.scalarType(zcu).zigTypeTag(zcu) != .int) {
16269 return sema.fail(block, src, "expected vector of integers or integer tag type, found '{}'", .{dest_ty.fmt(pt)});16269 return sema.fail(block, src, "expected vector of integers or integer tag type, found '{}'", .{dest_ty.fmt(pt)});
16270 }16270 }
1627116271
...@@ -16438,7 +16438,7 @@ fn zirOverflowArithmetic(...@@ -16438,7 +16438,7 @@ fn zirOverflowArithmetic(
16438fn splat(sema: *Sema, ty: Type, val: Value) !Value {16438fn splat(sema: *Sema, ty: Type, val: Value) !Value {
16439 const pt = sema.pt;16439 const pt = sema.pt;
16440 const zcu = pt.zcu;16440 const zcu = pt.zcu;
16441 if (ty.zigTypeTag(zcu) != .Vector) return val;16441 if (ty.zigTypeTag(zcu) != .vector) return val;
16442 const repeated = try pt.intern(.{ .aggregate = .{16442 const repeated = try pt.intern(.{ .aggregate = .{
16443 .ty = ty.toIntern(),16443 .ty = ty.toIntern(),
16444 .storage = .{ .repeated_elem = val.toIntern() },16444 .storage = .{ .repeated_elem = val.toIntern() },
...@@ -16450,7 +16450,7 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type {...@@ -16450,7 +16450,7 @@ fn overflowArithmeticTupleType(sema: *Sema, ty: Type) !Type {
16450 const pt = sema.pt;16450 const pt = sema.pt;
16451 const zcu = pt.zcu;16451 const zcu = pt.zcu;
16452 const ip = &zcu.intern_pool;16452 const ip = &zcu.intern_pool;
16453 const ov_ty = if (ty.zigTypeTag(zcu) == .Vector) try pt.vectorType(.{16453 const ov_ty = if (ty.zigTypeTag(zcu) == .vector) try pt.vectorType(.{
16454 .len = ty.vectorLen(zcu),16454 .len = ty.vectorLen(zcu),
16455 .child = .u1_type,16455 .child = .u1_type,
16456 }) else Type.u1;16456 }) else Type.u1;
...@@ -16485,8 +16485,8 @@ fn analyzeArithmetic(...@@ -16485,8 +16485,8 @@ fn analyzeArithmetic(
16485 const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(zcu);16485 const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(zcu);
16486 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);16486 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
1648716487
16488 if (lhs_zig_ty_tag == .Pointer) {16488 if (lhs_zig_ty_tag == .pointer) {
16489 if (rhs_zig_ty_tag == .Pointer) {16489 if (rhs_zig_ty_tag == .pointer) {
16490 if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) {16490 if (lhs_ty.ptrSize(zcu) != .Slice and rhs_ty.ptrSize(zcu) != .Slice) {
16491 if (zir_tag != .sub) {16491 if (zir_tag != .sub) {
16492 return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction");16492 return sema.failWithInvalidPtrArithmetic(block, src, "pointer-pointer", "subtraction");
...@@ -16569,7 +16569,7 @@ fn analyzeArithmetic(...@@ -16569,7 +16569,7 @@ fn analyzeArithmetic(
16569 const scalar_type = resolved_type.scalarType(zcu);16569 const scalar_type = resolved_type.scalarType(zcu);
16570 const scalar_tag = scalar_type.zigTypeTag(zcu);16570 const scalar_tag = scalar_type.zigTypeTag(zcu);
1657116571
16572 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;16572 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
1657316573
16574 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag);16574 try sema.checkArithmeticOp(block, src, scalar_tag, lhs_zig_ty_tag, rhs_zig_ty_tag, zir_tag);
1657516575
...@@ -16667,7 +16667,7 @@ fn analyzeArithmetic(...@@ -16667,7 +16667,7 @@ fn analyzeArithmetic(
16667 return pt.undefRef(resolved_type);16667 return pt.undefRef(resolved_type);
16668 }16668 }
1666916669
16670 const val = if (scalar_tag == .ComptimeInt)16670 const val = if (scalar_tag == .comptime_int)
16671 try sema.intAdd(lhs_val, rhs_val, resolved_type, undefined)16671 try sema.intAdd(lhs_val, rhs_val, resolved_type, undefined)
16672 else16672 else
16673 try lhs_val.intAddSat(rhs_val, resolved_type, sema.arena, pt);16673 try lhs_val.intAddSat(rhs_val, resolved_type, sema.arena, pt);
...@@ -16765,7 +16765,7 @@ fn analyzeArithmetic(...@@ -16765,7 +16765,7 @@ fn analyzeArithmetic(
16765 return pt.undefRef(resolved_type);16765 return pt.undefRef(resolved_type);
16766 }16766 }
16767 if (maybe_rhs_val) |rhs_val| {16767 if (maybe_rhs_val) |rhs_val| {
16768 const val = if (scalar_tag == .ComptimeInt)16768 const val = if (scalar_tag == .comptime_int)
16769 try sema.intSub(lhs_val, rhs_val, resolved_type, undefined)16769 try sema.intSub(lhs_val, rhs_val, resolved_type, undefined)
16770 else16770 else
16771 try lhs_val.intSubSat(rhs_val, resolved_type, sema.arena, pt);16771 try lhs_val.intSubSat(rhs_val, resolved_type, sema.arena, pt);
...@@ -16789,13 +16789,13 @@ fn analyzeArithmetic(...@@ -16789,13 +16789,13 @@ fn analyzeArithmetic(
16789 // the result is nan.16789 // the result is nan.
16790 // If either of the operands are nan, the result is nan.16790 // If either of the operands are nan, the result is nan.
16791 const scalar_zero = switch (scalar_tag) {16791 const scalar_zero = switch (scalar_tag) {
16792 .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 0.0),16792 .comptime_float, .float => try pt.floatValue(scalar_type, 0.0),
16793 .ComptimeInt, .Int => try pt.intValue(scalar_type, 0),16793 .comptime_int, .int => try pt.intValue(scalar_type, 0),
16794 else => unreachable,16794 else => unreachable,
16795 };16795 };
16796 const scalar_one = switch (scalar_tag) {16796 const scalar_one = switch (scalar_tag) {
16797 .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 1.0),16797 .comptime_float, .float => try pt.floatValue(scalar_type, 1.0),
16798 .ComptimeInt, .Int => try pt.intValue(scalar_type, 1),16798 .comptime_int, .int => try pt.intValue(scalar_type, 1),
16799 else => unreachable,16799 else => unreachable,
16800 };16800 };
16801 if (maybe_lhs_val) |lhs_val| {16801 if (maybe_lhs_val) |lhs_val| {
...@@ -16875,13 +16875,13 @@ fn analyzeArithmetic(...@@ -16875,13 +16875,13 @@ fn analyzeArithmetic(
16875 // If either of the operands are one, result is the other operand.16875 // If either of the operands are one, result is the other operand.
16876 // If either of the operands are undefined, result is undefined.16876 // If either of the operands are undefined, result is undefined.
16877 const scalar_zero = switch (scalar_tag) {16877 const scalar_zero = switch (scalar_tag) {
16878 .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 0.0),16878 .comptime_float, .float => try pt.floatValue(scalar_type, 0.0),
16879 .ComptimeInt, .Int => try pt.intValue(scalar_type, 0),16879 .comptime_int, .int => try pt.intValue(scalar_type, 0),
16880 else => unreachable,16880 else => unreachable,
16881 };16881 };
16882 const scalar_one = switch (scalar_tag) {16882 const scalar_one = switch (scalar_tag) {
16883 .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 1.0),16883 .comptime_float, .float => try pt.floatValue(scalar_type, 1.0),
16884 .ComptimeInt, .Int => try pt.intValue(scalar_type, 1),16884 .comptime_int, .int => try pt.intValue(scalar_type, 1),
16885 else => unreachable,16885 else => unreachable,
16886 };16886 };
16887 if (maybe_lhs_val) |lhs_val| {16887 if (maybe_lhs_val) |lhs_val| {
...@@ -16920,13 +16920,13 @@ fn analyzeArithmetic(...@@ -16920,13 +16920,13 @@ fn analyzeArithmetic(
16920 // If either of the operands are one, result is the other operand.16920 // If either of the operands are one, result is the other operand.
16921 // If either of the operands are undefined, result is undefined.16921 // If either of the operands are undefined, result is undefined.
16922 const scalar_zero = switch (scalar_tag) {16922 const scalar_zero = switch (scalar_tag) {
16923 .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 0.0),16923 .comptime_float, .float => try pt.floatValue(scalar_type, 0.0),
16924 .ComptimeInt, .Int => try pt.intValue(scalar_type, 0),16924 .comptime_int, .int => try pt.intValue(scalar_type, 0),
16925 else => unreachable,16925 else => unreachable,
16926 };16926 };
16927 const scalar_one = switch (scalar_tag) {16927 const scalar_one = switch (scalar_tag) {
16928 .ComptimeFloat, .Float => try pt.floatValue(scalar_type, 1.0),16928 .comptime_float, .float => try pt.floatValue(scalar_type, 1.0),
16929 .ComptimeInt, .Int => try pt.intValue(scalar_type, 1),16929 .comptime_int, .int => try pt.intValue(scalar_type, 1),
16930 else => unreachable,16930 else => unreachable,
16931 };16931 };
16932 if (maybe_lhs_val) |lhs_val| {16932 if (maybe_lhs_val) |lhs_val| {
...@@ -16956,7 +16956,7 @@ fn analyzeArithmetic(...@@ -16956,7 +16956,7 @@ fn analyzeArithmetic(
16956 return pt.undefRef(resolved_type);16956 return pt.undefRef(resolved_type);
16957 }16957 }
1695816958
16959 const val = if (scalar_tag == .ComptimeInt)16959 const val = if (scalar_tag == .comptime_int)
16960 try lhs_val.intMul(rhs_val, resolved_type, undefined, sema.arena, pt)16960 try lhs_val.intMul(rhs_val, resolved_type, undefined, sema.arena, pt)
16961 else16961 else
16962 try lhs_val.intMulSat(rhs_val, resolved_type, sema.arena, pt);16962 try lhs_val.intMulSat(rhs_val, resolved_type, sema.arena, pt);
...@@ -16971,7 +16971,7 @@ fn analyzeArithmetic(...@@ -16971,7 +16971,7 @@ fn analyzeArithmetic(
1697116971
16972 try sema.requireRuntimeBlock(block, src, runtime_src);16972 try sema.requireRuntimeBlock(block, src, runtime_src);
1697316973
16974 if (block.wantSafety() and want_safety and scalar_tag == .Int) {16974 if (block.wantSafety() and want_safety and scalar_tag == .int) {
16975 if (zcu.backendSupportsFeature(.safety_checked_instructions)) {16975 if (zcu.backendSupportsFeature(.safety_checked_instructions)) {
16976 if (air_tag != air_tag_safe) {16976 if (air_tag != air_tag_safe) {
16977 _ = try sema.preparePanicId(block, src, .integer_overflow);16977 _ = try sema.preparePanicId(block, src, .integer_overflow);
...@@ -16997,7 +16997,7 @@ fn analyzeArithmetic(...@@ -16997,7 +16997,7 @@ fn analyzeArithmetic(
16997 } },16997 } },
16998 });16998 });
16999 const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty);16999 const ov_bit = try sema.tupleFieldValByIndex(block, src, op_ov, 1, op_ov_tuple_ty);
17000 const any_ov_bit = if (resolved_type.zigTypeTag(zcu) == .Vector)17000 const any_ov_bit = if (resolved_type.zigTypeTag(zcu) == .vector)
17001 try block.addInst(.{17001 try block.addInst(.{
17002 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,17002 .tag = if (block.float_mode == .optimized) .reduce_optimized else .reduce,
17003 .data = .{ .reduce = .{17003 .data = .{ .reduce = .{
...@@ -17170,7 +17170,7 @@ fn zirAsm(...@@ -17170,7 +17170,7 @@ fn zirAsm(
1717017170
17171 var extra_i = extra.end;17171 var extra_i = extra.end;
17172 var output_type_bits = extra.data.output_type_bits;17172 var output_type_bits = extra.data.output_type_bits;
17173 var needed_capacity: usize = @typeInfo(Air.Asm).Struct.fields.len + outputs_len + inputs_len;17173 var needed_capacity: usize = @typeInfo(Air.Asm).@"struct".fields.len + outputs_len + inputs_len;
1717417174
17175 const ConstraintName = struct { c: []const u8, n: []const u8 };17175 const ConstraintName = struct { c: []const u8, n: []const u8 };
17176 const out_args = try sema.arena.alloc(Air.Inst.Ref, outputs_len);17176 const out_args = try sema.arena.alloc(Air.Inst.Ref, outputs_len);
...@@ -17217,8 +17217,8 @@ fn zirAsm(...@@ -17217,8 +17217,8 @@ fn zirAsm(
17217 const uncasted_arg = try sema.resolveInst(input.data.operand);17217 const uncasted_arg = try sema.resolveInst(input.data.operand);
17218 const uncasted_arg_ty = sema.typeOf(uncasted_arg);17218 const uncasted_arg_ty = sema.typeOf(uncasted_arg);
17219 switch (uncasted_arg_ty.zigTypeTag(zcu)) {17219 switch (uncasted_arg_ty.zigTypeTag(zcu)) {
17220 .ComptimeInt => arg.* = try sema.coerce(block, Type.usize, uncasted_arg, src),17220 .comptime_int => arg.* = try sema.coerce(block, Type.usize, uncasted_arg, src),
17221 .ComptimeFloat => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src),17221 .comptime_float => arg.* = try sema.coerce(block, Type.f64, uncasted_arg, src),
17222 else => {17222 else => {
17223 arg.* = uncasted_arg;17223 arg.* = uncasted_arg;
17224 },17224 },
...@@ -17312,32 +17312,32 @@ fn zirCmpEq(...@@ -17312,32 +17312,32 @@ fn zirCmpEq(
17312 const rhs_ty = sema.typeOf(rhs);17312 const rhs_ty = sema.typeOf(rhs);
17313 const lhs_ty_tag = lhs_ty.zigTypeTag(zcu);17313 const lhs_ty_tag = lhs_ty.zigTypeTag(zcu);
17314 const rhs_ty_tag = rhs_ty.zigTypeTag(zcu);17314 const rhs_ty_tag = rhs_ty.zigTypeTag(zcu);
17315 if (lhs_ty_tag == .Null and rhs_ty_tag == .Null) {17315 if (lhs_ty_tag == .null and rhs_ty_tag == .null) {
17316 // null == null, null != null17316 // null == null, null != null
17317 return if (op == .eq) .bool_true else .bool_false;17317 return if (op == .eq) .bool_true else .bool_false;
17318 }17318 }
1731917319
17320 // comparing null with optionals17320 // comparing null with optionals
17321 if (lhs_ty_tag == .Null and (rhs_ty_tag == .Optional or rhs_ty.isCPtr(zcu))) {17321 if (lhs_ty_tag == .null and (rhs_ty_tag == .optional or rhs_ty.isCPtr(zcu))) {
17322 return sema.analyzeIsNull(block, src, rhs, op == .neq);17322 return sema.analyzeIsNull(block, src, rhs, op == .neq);
17323 }17323 }
17324 if (rhs_ty_tag == .Null and (lhs_ty_tag == .Optional or lhs_ty.isCPtr(zcu))) {17324 if (rhs_ty_tag == .null and (lhs_ty_tag == .optional or lhs_ty.isCPtr(zcu))) {
17325 return sema.analyzeIsNull(block, src, lhs, op == .neq);17325 return sema.analyzeIsNull(block, src, lhs, op == .neq);
17326 }17326 }
1732717327
17328 if (lhs_ty_tag == .Null or rhs_ty_tag == .Null) {17328 if (lhs_ty_tag == .null or rhs_ty_tag == .null) {
17329 const non_null_type = if (lhs_ty_tag == .Null) rhs_ty else lhs_ty;17329 const non_null_type = if (lhs_ty_tag == .null) rhs_ty else lhs_ty;
17330 return sema.fail(block, src, "comparison of '{}' with null", .{non_null_type.fmt(pt)});17330 return sema.fail(block, src, "comparison of '{}' with null", .{non_null_type.fmt(pt)});
17331 }17331 }
1733217332
17333 if (lhs_ty_tag == .Union and (rhs_ty_tag == .EnumLiteral or rhs_ty_tag == .Enum)) {17333 if (lhs_ty_tag == .@"union" and (rhs_ty_tag == .enum_literal or rhs_ty_tag == .@"enum")) {
17334 return sema.analyzeCmpUnionTag(block, src, lhs, lhs_src, rhs, rhs_src, op);17334 return sema.analyzeCmpUnionTag(block, src, lhs, lhs_src, rhs, rhs_src, op);
17335 }17335 }
17336 if (rhs_ty_tag == .Union and (lhs_ty_tag == .EnumLiteral or lhs_ty_tag == .Enum)) {17336 if (rhs_ty_tag == .@"union" and (lhs_ty_tag == .enum_literal or lhs_ty_tag == .@"enum")) {
17337 return sema.analyzeCmpUnionTag(block, src, rhs, rhs_src, lhs, lhs_src, op);17337 return sema.analyzeCmpUnionTag(block, src, rhs, rhs_src, lhs, lhs_src, op);
17338 }17338 }
1733917339
17340 if (lhs_ty_tag == .ErrorSet and rhs_ty_tag == .ErrorSet) {17340 if (lhs_ty_tag == .error_set and rhs_ty_tag == .error_set) {
17341 const runtime_src: LazySrcLoc = src: {17341 const runtime_src: LazySrcLoc = src: {
17342 if (try sema.resolveValue(lhs)) |lval| {17342 if (try sema.resolveValue(lhs)) |lval| {
17343 if (try sema.resolveValue(rhs)) |rval| {17343 if (try sema.resolveValue(rhs)) |rval| {
...@@ -17360,7 +17360,7 @@ fn zirCmpEq(...@@ -17360,7 +17360,7 @@ fn zirCmpEq(
17360 try sema.requireRuntimeBlock(block, src, runtime_src);17360 try sema.requireRuntimeBlock(block, src, runtime_src);
17361 return block.addBinOp(air_tag, lhs, rhs);17361 return block.addBinOp(air_tag, lhs, rhs);
17362 }17362 }
17363 if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) {17363 if (lhs_ty_tag == .type and rhs_ty_tag == .type) {
17364 const lhs_as_type = try sema.analyzeAsType(block, lhs_src, lhs);17364 const lhs_as_type = try sema.analyzeAsType(block, lhs_src, lhs);
17365 const rhs_as_type = try sema.analyzeAsType(block, rhs_src, rhs);17365 const rhs_as_type = try sema.analyzeAsType(block, rhs_src, rhs);
17366 return if (lhs_as_type.eql(rhs_as_type, zcu) == (op == .eq)) .bool_true else .bool_false;17366 return if (lhs_as_type.eql(rhs_as_type, zcu) == (op == .eq)) .bool_true else .bool_false;
...@@ -17399,7 +17399,7 @@ fn analyzeCmpUnionTag(...@@ -17399,7 +17399,7 @@ fn analyzeCmpUnionTag(
17399 if (try sema.resolveValue(coerced_tag)) |enum_val| {17399 if (try sema.resolveValue(coerced_tag)) |enum_val| {
17400 if (enum_val.isUndef(zcu)) return pt.undefRef(Type.bool);17400 if (enum_val.isUndef(zcu)) return pt.undefRef(Type.bool);
17401 const field_ty = union_ty.unionFieldType(enum_val, zcu).?;17401 const field_ty = union_ty.unionFieldType(enum_val, zcu).?;
17402 if (field_ty.zigTypeTag(zcu) == .NoReturn) {17402 if (field_ty.zigTypeTag(zcu) == .noreturn) {
17403 return .bool_false;17403 return .bool_false;
17404 }17404 }
17405 }17405 }
...@@ -17442,11 +17442,11 @@ fn analyzeCmp(...@@ -17442,11 +17442,11 @@ fn analyzeCmp(
17442 const zcu = pt.zcu;17442 const zcu = pt.zcu;
17443 const lhs_ty = sema.typeOf(lhs);17443 const lhs_ty = sema.typeOf(lhs);
17444 const rhs_ty = sema.typeOf(rhs);17444 const rhs_ty = sema.typeOf(rhs);
17445 if (lhs_ty.zigTypeTag(zcu) != .Optional and rhs_ty.zigTypeTag(zcu) != .Optional) {17445 if (lhs_ty.zigTypeTag(zcu) != .optional and rhs_ty.zigTypeTag(zcu) != .optional) {
17446 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);17446 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
17447 }17447 }
1744817448
17449 if (lhs_ty.zigTypeTag(zcu) == .Vector and rhs_ty.zigTypeTag(zcu) == .Vector) {17449 if (lhs_ty.zigTypeTag(zcu) == .vector and rhs_ty.zigTypeTag(zcu) == .vector) {
17450 return sema.cmpVector(block, src, lhs, rhs, op, lhs_src, rhs_src);17450 return sema.cmpVector(block, src, lhs, rhs, op, lhs_src, rhs_src);
17451 }17451 }
17452 if (lhs_ty.isNumeric(zcu) and rhs_ty.isNumeric(zcu)) {17452 if (lhs_ty.isNumeric(zcu) and rhs_ty.isNumeric(zcu)) {
...@@ -17455,11 +17455,11 @@ fn analyzeCmp(...@@ -17455,11 +17455,11 @@ fn analyzeCmp(
17455 // numeric types.17455 // numeric types.
17456 return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src);17456 return sema.cmpNumeric(block, src, lhs, rhs, op, lhs_src, rhs_src);
17457 }17457 }
17458 if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .ErrorUnion and rhs_ty.zigTypeTag(zcu) == .ErrorSet) {17458 if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .error_union and rhs_ty.zigTypeTag(zcu) == .error_set) {
17459 const casted_lhs = try sema.analyzeErrUnionCode(block, lhs_src, lhs);17459 const casted_lhs = try sema.analyzeErrUnionCode(block, lhs_src, lhs);
17460 return sema.cmpSelf(block, src, casted_lhs, rhs, op, lhs_src, rhs_src);17460 return sema.cmpSelf(block, src, casted_lhs, rhs, op, lhs_src, rhs_src);
17461 }17461 }
17462 if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .ErrorSet and rhs_ty.zigTypeTag(zcu) == .ErrorUnion) {17462 if (is_equality_cmp and lhs_ty.zigTypeTag(zcu) == .error_set and rhs_ty.zigTypeTag(zcu) == .error_union) {
17463 const casted_rhs = try sema.analyzeErrUnionCode(block, rhs_src, rhs);17463 const casted_rhs = try sema.analyzeErrUnionCode(block, rhs_src, rhs);
17464 return sema.cmpSelf(block, src, lhs, casted_rhs, op, lhs_src, rhs_src);17464 return sema.cmpSelf(block, src, lhs, casted_rhs, op, lhs_src, rhs_src);
17465 }17465 }
...@@ -17505,7 +17505,7 @@ fn cmpSelf(...@@ -17505,7 +17505,7 @@ fn cmpSelf(
17505 if (try sema.resolveValue(casted_rhs)) |rhs_val| {17505 if (try sema.resolveValue(casted_rhs)) |rhs_val| {
17506 if (rhs_val.isUndef(zcu)) return pt.undefRef(Type.bool);17506 if (rhs_val.isUndef(zcu)) return pt.undefRef(Type.bool);
1750717507
17508 if (resolved_type.zigTypeTag(zcu) == .Vector) {17508 if (resolved_type.zigTypeTag(zcu) == .vector) {
17509 const cmp_val = try sema.compareVector(lhs_val, op, rhs_val, resolved_type);17509 const cmp_val = try sema.compareVector(lhs_val, op, rhs_val, resolved_type);
17510 return Air.internedToRef(cmp_val.toIntern());17510 return Air.internedToRef(cmp_val.toIntern());
17511 }17511 }
...@@ -17515,7 +17515,7 @@ fn cmpSelf(...@@ -17515,7 +17515,7 @@ fn cmpSelf(
17515 else17515 else
17516 .bool_false;17516 .bool_false;
17517 } else {17517 } else {
17518 if (resolved_type.zigTypeTag(zcu) == .Bool) {17518 if (resolved_type.zigTypeTag(zcu) == .bool) {
17519 // We can lower bool eq/neq more efficiently.17519 // We can lower bool eq/neq more efficiently.
17520 return sema.runtimeBoolCmp(block, src, op, casted_rhs, lhs_val.toBool(), rhs_src);17520 return sema.runtimeBoolCmp(block, src, op, casted_rhs, lhs_val.toBool(), rhs_src);
17521 }17521 }
...@@ -17524,7 +17524,7 @@ fn cmpSelf(...@@ -17524,7 +17524,7 @@ fn cmpSelf(
17524 } else {17524 } else {
17525 // For bools, we still check the other operand, because we can lower17525 // For bools, we still check the other operand, because we can lower
17526 // bool eq/neq more efficiently.17526 // bool eq/neq more efficiently.
17527 if (resolved_type.zigTypeTag(zcu) == .Bool) {17527 if (resolved_type.zigTypeTag(zcu) == .bool) {
17528 if (try sema.resolveValue(casted_rhs)) |rhs_val| {17528 if (try sema.resolveValue(casted_rhs)) |rhs_val| {
17529 if (rhs_val.isUndef(zcu)) return pt.undefRef(Type.bool);17529 if (rhs_val.isUndef(zcu)) return pt.undefRef(Type.bool);
17530 return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src);17530 return sema.runtimeBoolCmp(block, src, op, casted_lhs, rhs_val.toBool(), lhs_src);
...@@ -17534,7 +17534,7 @@ fn cmpSelf(...@@ -17534,7 +17534,7 @@ fn cmpSelf(
17534 }17534 }
17535 };17535 };
17536 try sema.requireRuntimeBlock(block, src, runtime_src);17536 try sema.requireRuntimeBlock(block, src, runtime_src);
17537 if (resolved_type.zigTypeTag(zcu) == .Vector) {17537 if (resolved_type.zigTypeTag(zcu) == .vector) {
17538 return block.addCmpVector(casted_lhs, casted_rhs, op);17538 return block.addCmpVector(casted_lhs, casted_rhs, op);
17539 }17539 }
17540 const tag = Air.Inst.Tag.fromCmpOp(op, block.float_mode == .optimized);17540 const tag = Air.Inst.Tag.fromCmpOp(op, block.float_mode == .optimized);
...@@ -17568,34 +17568,34 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -17568,34 +17568,34 @@ fn zirSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
17568 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);17568 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
17569 const ty = try sema.resolveType(block, operand_src, inst_data.operand);17569 const ty = try sema.resolveType(block, operand_src, inst_data.operand);
17570 switch (ty.zigTypeTag(pt.zcu)) {17570 switch (ty.zigTypeTag(pt.zcu)) {
17571 .Fn,17571 .@"fn",
17572 .NoReturn,17572 .noreturn,
17573 .Undefined,17573 .undefined,
17574 .Null,17574 .null,
17575 .Opaque,17575 .@"opaque",
17576 => return sema.fail(block, operand_src, "no size available for type '{}'", .{ty.fmt(pt)}),17576 => return sema.fail(block, operand_src, "no size available for type '{}'", .{ty.fmt(pt)}),
1757717577
17578 .Type,17578 .type,
17579 .EnumLiteral,17579 .enum_literal,
17580 .ComptimeFloat,17580 .comptime_float,
17581 .ComptimeInt,17581 .comptime_int,
17582 .Void,17582 .void,
17583 => return pt.intRef(Type.comptime_int, 0),17583 => return pt.intRef(Type.comptime_int, 0),
1758417584
17585 .Bool,17585 .bool,
17586 .Int,17586 .int,
17587 .Float,17587 .float,
17588 .Pointer,17588 .pointer,
17589 .Array,17589 .array,
17590 .Struct,17590 .@"struct",
17591 .Optional,17591 .optional,
17592 .ErrorUnion,17592 .error_union,
17593 .ErrorSet,17593 .error_set,
17594 .Enum,17594 .@"enum",
17595 .Union,17595 .@"union",
17596 .Vector,17596 .vector,
17597 .Frame,17597 .frame,
17598 .AnyFrame,17598 .@"anyframe",
17599 => {},17599 => {},
17600 }17600 }
17601 const val = try ty.abiSizeLazy(pt);17601 const val = try ty.abiSizeLazy(pt);
...@@ -17609,34 +17609,34 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -17609,34 +17609,34 @@ fn zirBitSizeOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
17609 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);17609 const operand_src = block.builtinCallArgSrc(inst_data.src_node, 0);
17610 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);17610 const operand_ty = try sema.resolveType(block, operand_src, inst_data.operand);
17611 switch (operand_ty.zigTypeTag(zcu)) {17611 switch (operand_ty.zigTypeTag(zcu)) {
17612 .Fn,17612 .@"fn",
17613 .NoReturn,17613 .noreturn,
17614 .Undefined,17614 .undefined,
17615 .Null,17615 .null,
17616 .Opaque,17616 .@"opaque",
17617 => return sema.fail(block, operand_src, "no size available for type '{}'", .{operand_ty.fmt(pt)}),17617 => return sema.fail(block, operand_src, "no size available for type '{}'", .{operand_ty.fmt(pt)}),
1761817618
17619 .Type,17619 .type,
17620 .EnumLiteral,17620 .enum_literal,
17621 .ComptimeFloat,17621 .comptime_float,
17622 .ComptimeInt,17622 .comptime_int,
17623 .Void,17623 .void,
17624 => return pt.intRef(Type.comptime_int, 0),17624 => return pt.intRef(Type.comptime_int, 0),
1762517625
17626 .Bool,17626 .bool,
17627 .Int,17627 .int,
17628 .Float,17628 .float,
17629 .Pointer,17629 .pointer,
17630 .Array,17630 .array,
17631 .Struct,17631 .@"struct",
17632 .Optional,17632 .optional,
17633 .ErrorUnion,17633 .error_union,
17634 .ErrorSet,17634 .error_set,
17635 .Enum,17635 .@"enum",
17636 .Union,17636 .@"union",
17637 .Vector,17637 .vector,
17638 .Frame,17638 .frame,
17639 .AnyFrame,17639 .@"anyframe",
17640 => {},17640 => {},
17641 }17641 }
17642 const bit_size = try operand_ty.bitSizeSema(pt);17642 const bit_size = try operand_ty.bitSizeSema(pt);
...@@ -17893,21 +17893,21 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -17893,21 +17893,21 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
17893 }17893 }
1789417894
17895 switch (ty.zigTypeTag(zcu)) {17895 switch (ty.zigTypeTag(zcu)) {
17896 .Type,17896 .type,
17897 .Void,17897 .void,
17898 .Bool,17898 .bool,
17899 .NoReturn,17899 .noreturn,
17900 .ComptimeFloat,17900 .comptime_float,
17901 .ComptimeInt,17901 .comptime_int,
17902 .Undefined,17902 .undefined,
17903 .Null,17903 .null,
17904 .EnumLiteral,17904 .enum_literal,
17905 => |type_info_tag| return Air.internedToRef((try pt.intern(.{ .un = .{17905 => |type_info_tag| return Air.internedToRef((try pt.intern(.{ .un = .{
17906 .ty = type_info_ty.toIntern(),17906 .ty = type_info_ty.toIntern(),
17907 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(type_info_tag))).toIntern(),17907 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(type_info_tag))).toIntern(),
17908 .val = .void_value,17908 .val = .void_value,
17909 } }))),17909 } }))),
17910 .Fn => {17910 .@"fn" => {
17911 const fn_info_nav = try sema.namespaceLookup(17911 const fn_info_nav = try sema.namespaceLookup(
17912 block,17912 block,
17913 src,17913 src,
...@@ -18010,14 +18010,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18010,14 +18010,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18010 };18010 };
18011 return Air.internedToRef((try pt.intern(.{ .un = .{18011 return Air.internedToRef((try pt.intern(.{ .un = .{
18012 .ty = type_info_ty.toIntern(),18012 .ty = type_info_ty.toIntern(),
18013 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Fn))).toIntern(),18013 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"fn"))).toIntern(),
18014 .val = try pt.intern(.{ .aggregate = .{18014 .val = try pt.intern(.{ .aggregate = .{
18015 .ty = fn_info_ty.toIntern(),18015 .ty = fn_info_ty.toIntern(),
18016 .storage = .{ .elems = &field_values },18016 .storage = .{ .elems = &field_values },
18017 } }),18017 } }),
18018 } })));18018 } })));
18019 },18019 },
18020 .Int => {18020 .int => {
18021 const int_info_nav = try sema.namespaceLookup(18021 const int_info_nav = try sema.namespaceLookup(
18022 block,18022 block,
18023 src,18023 src,
...@@ -18037,14 +18037,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18037,14 +18037,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18037 };18037 };
18038 return Air.internedToRef((try pt.intern(.{ .un = .{18038 return Air.internedToRef((try pt.intern(.{ .un = .{
18039 .ty = type_info_ty.toIntern(),18039 .ty = type_info_ty.toIntern(),
18040 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Int))).toIntern(),18040 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.int))).toIntern(),
18041 .val = try pt.intern(.{ .aggregate = .{18041 .val = try pt.intern(.{ .aggregate = .{
18042 .ty = int_info_ty.toIntern(),18042 .ty = int_info_ty.toIntern(),
18043 .storage = .{ .elems = &field_values },18043 .storage = .{ .elems = &field_values },
18044 } }),18044 } }),
18045 } })));18045 } })));
18046 },18046 },
18047 .Float => {18047 .float => {
18048 const float_info_nav = try sema.namespaceLookup(18048 const float_info_nav = try sema.namespaceLookup(
18049 block,18049 block,
18050 src,18050 src,
...@@ -18060,14 +18060,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18060,14 +18060,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18060 };18060 };
18061 return Air.internedToRef((try pt.intern(.{ .un = .{18061 return Air.internedToRef((try pt.intern(.{ .un = .{
18062 .ty = type_info_ty.toIntern(),18062 .ty = type_info_ty.toIntern(),
18063 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Float))).toIntern(),18063 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.float))).toIntern(),
18064 .val = try pt.intern(.{ .aggregate = .{18064 .val = try pt.intern(.{ .aggregate = .{
18065 .ty = float_info_ty.toIntern(),18065 .ty = float_info_ty.toIntern(),
18066 .storage = .{ .elems = &field_vals },18066 .storage = .{ .elems = &field_vals },
18067 } }),18067 } }),
18068 } })));18068 } })));
18069 },18069 },
18070 .Pointer => {18070 .pointer => {
18071 const info = ty.ptrInfo(zcu);18071 const info = ty.ptrInfo(zcu);
18072 const alignment = if (info.flags.alignment.toByteUnits()) |alignment|18072 const alignment = if (info.flags.alignment.toByteUnits()) |alignment|
18073 try pt.intValue(Type.comptime_int, alignment)18073 try pt.intValue(Type.comptime_int, alignment)
...@@ -18119,14 +18119,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18119,14 +18119,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18119 };18119 };
18120 return Air.internedToRef((try pt.intern(.{ .un = .{18120 return Air.internedToRef((try pt.intern(.{ .un = .{
18121 .ty = type_info_ty.toIntern(),18121 .ty = type_info_ty.toIntern(),
18122 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Pointer))).toIntern(),18122 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.pointer))).toIntern(),
18123 .val = try pt.intern(.{ .aggregate = .{18123 .val = try pt.intern(.{ .aggregate = .{
18124 .ty = pointer_ty.toIntern(),18124 .ty = pointer_ty.toIntern(),
18125 .storage = .{ .elems = &field_values },18125 .storage = .{ .elems = &field_values },
18126 } }),18126 } }),
18127 } })));18127 } })));
18128 },18128 },
18129 .Array => {18129 .array => {
18130 const array_field_ty = t: {18130 const array_field_ty = t: {
18131 const nav = try sema.namespaceLookup(18131 const nav = try sema.namespaceLookup(
18132 block,18132 block,
...@@ -18149,14 +18149,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18149,14 +18149,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18149 };18149 };
18150 return Air.internedToRef((try pt.intern(.{ .un = .{18150 return Air.internedToRef((try pt.intern(.{ .un = .{
18151 .ty = type_info_ty.toIntern(),18151 .ty = type_info_ty.toIntern(),
18152 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Array))).toIntern(),18152 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.array))).toIntern(),
18153 .val = try pt.intern(.{ .aggregate = .{18153 .val = try pt.intern(.{ .aggregate = .{
18154 .ty = array_field_ty.toIntern(),18154 .ty = array_field_ty.toIntern(),
18155 .storage = .{ .elems = &field_values },18155 .storage = .{ .elems = &field_values },
18156 } }),18156 } }),
18157 } })));18157 } })));
18158 },18158 },
18159 .Vector => {18159 .vector => {
18160 const vector_field_ty = t: {18160 const vector_field_ty = t: {
18161 const nav = try sema.namespaceLookup(18161 const nav = try sema.namespaceLookup(
18162 block,18162 block,
...@@ -18177,14 +18177,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18177,14 +18177,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18177 };18177 };
18178 return Air.internedToRef((try pt.intern(.{ .un = .{18178 return Air.internedToRef((try pt.intern(.{ .un = .{
18179 .ty = type_info_ty.toIntern(),18179 .ty = type_info_ty.toIntern(),
18180 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Vector))).toIntern(),18180 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.vector))).toIntern(),
18181 .val = try pt.intern(.{ .aggregate = .{18181 .val = try pt.intern(.{ .aggregate = .{
18182 .ty = vector_field_ty.toIntern(),18182 .ty = vector_field_ty.toIntern(),
18183 .storage = .{ .elems = &field_values },18183 .storage = .{ .elems = &field_values },
18184 } }),18184 } }),
18185 } })));18185 } })));
18186 },18186 },
18187 .Optional => {18187 .optional => {
18188 const optional_field_ty = t: {18188 const optional_field_ty = t: {
18189 const nav = try sema.namespaceLookup(18189 const nav = try sema.namespaceLookup(
18190 block,18190 block,
...@@ -18202,14 +18202,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18202,14 +18202,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18202 };18202 };
18203 return Air.internedToRef((try pt.intern(.{ .un = .{18203 return Air.internedToRef((try pt.intern(.{ .un = .{
18204 .ty = type_info_ty.toIntern(),18204 .ty = type_info_ty.toIntern(),
18205 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Optional))).toIntern(),18205 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.optional))).toIntern(),
18206 .val = try pt.intern(.{ .aggregate = .{18206 .val = try pt.intern(.{ .aggregate = .{
18207 .ty = optional_field_ty.toIntern(),18207 .ty = optional_field_ty.toIntern(),
18208 .storage = .{ .elems = &field_values },18208 .storage = .{ .elems = &field_values },
18209 } }),18209 } }),
18210 } })));18210 } })));
18211 },18211 },
18212 .ErrorSet => {18212 .error_set => {
18213 // Get the Error type18213 // Get the Error type
18214 const error_field_ty = t: {18214 const error_field_ty = t: {
18215 const nav = try sema.namespaceLookup(18215 const nav = try sema.namespaceLookup(
...@@ -18308,14 +18308,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18308,14 +18308,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18308 .val = errors_payload_val,18308 .val = errors_payload_val,
18309 } });18309 } });
1831018310
18311 // Construct Type{ .ErrorSet = errors_val }18311 // Construct Type{ .error_set = errors_val }
18312 return Air.internedToRef((try pt.intern(.{ .un = .{18312 return Air.internedToRef((try pt.intern(.{ .un = .{
18313 .ty = type_info_ty.toIntern(),18313 .ty = type_info_ty.toIntern(),
18314 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorSet))).toIntern(),18314 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.error_set))).toIntern(),
18315 .val = errors_val,18315 .val = errors_val,
18316 } })));18316 } })));
18317 },18317 },
18318 .ErrorUnion => {18318 .error_union => {
18319 const error_union_field_ty = t: {18319 const error_union_field_ty = t: {
18320 const nav = try sema.namespaceLookup(18320 const nav = try sema.namespaceLookup(
18321 block,18321 block,
...@@ -18335,14 +18335,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18335,14 +18335,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18335 };18335 };
18336 return Air.internedToRef((try pt.intern(.{ .un = .{18336 return Air.internedToRef((try pt.intern(.{ .un = .{
18337 .ty = type_info_ty.toIntern(),18337 .ty = type_info_ty.toIntern(),
18338 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.ErrorUnion))).toIntern(),18338 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.error_union))).toIntern(),
18339 .val = try pt.intern(.{ .aggregate = .{18339 .val = try pt.intern(.{ .aggregate = .{
18340 .ty = error_union_field_ty.toIntern(),18340 .ty = error_union_field_ty.toIntern(),
18341 .storage = .{ .elems = &field_values },18341 .storage = .{ .elems = &field_values },
18342 } }),18342 } }),
18343 } })));18343 } })));
18344 },18344 },
18345 .Enum => {18345 .@"enum" => {
18346 const is_exhaustive = Value.makeBool(ip.loadEnumType(ty.toIntern()).tag_mode != .nonexhaustive);18346 const is_exhaustive = Value.makeBool(ip.loadEnumType(ty.toIntern()).tag_mode != .nonexhaustive);
1834718347
18348 const enum_field_ty = t: {18348 const enum_field_ty = t: {
...@@ -18464,14 +18464,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18464,14 +18464,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18464 };18464 };
18465 return Air.internedToRef((try pt.intern(.{ .un = .{18465 return Air.internedToRef((try pt.intern(.{ .un = .{
18466 .ty = type_info_ty.toIntern(),18466 .ty = type_info_ty.toIntern(),
18467 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Enum))).toIntern(),18467 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"enum"))).toIntern(),
18468 .val = try pt.intern(.{ .aggregate = .{18468 .val = try pt.intern(.{ .aggregate = .{
18469 .ty = type_enum_ty.toIntern(),18469 .ty = type_enum_ty.toIntern(),
18470 .storage = .{ .elems = &field_values },18470 .storage = .{ .elems = &field_values },
18471 } }),18471 } }),
18472 } })));18472 } })));
18473 },18473 },
18474 .Union => {18474 .@"union" => {
18475 const type_union_ty = t: {18475 const type_union_ty = t: {
18476 const nav = try sema.namespaceLookup(18476 const nav = try sema.namespaceLookup(
18477 block,18477 block,
...@@ -18611,14 +18611,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18611,14 +18611,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18611 };18611 };
18612 return Air.internedToRef((try pt.intern(.{ .un = .{18612 return Air.internedToRef((try pt.intern(.{ .un = .{
18613 .ty = type_info_ty.toIntern(),18613 .ty = type_info_ty.toIntern(),
18614 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Union))).toIntern(),18614 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"union"))).toIntern(),
18615 .val = try pt.intern(.{ .aggregate = .{18615 .val = try pt.intern(.{ .aggregate = .{
18616 .ty = type_union_ty.toIntern(),18616 .ty = type_union_ty.toIntern(),
18617 .storage = .{ .elems = &field_values },18617 .storage = .{ .elems = &field_values },
18618 } }),18618 } }),
18619 } })));18619 } })));
18620 },18620 },
18621 .Struct => {18621 .@"struct" => {
18622 const type_struct_ty = t: {18622 const type_struct_ty = t: {
18623 const nav = try sema.namespaceLookup(18623 const nav = try sema.namespaceLookup(
18624 block,18624 block,
...@@ -18843,14 +18843,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18843,14 +18843,14 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18843 };18843 };
18844 return Air.internedToRef((try pt.intern(.{ .un = .{18844 return Air.internedToRef((try pt.intern(.{ .un = .{
18845 .ty = type_info_ty.toIntern(),18845 .ty = type_info_ty.toIntern(),
18846 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Struct))).toIntern(),18846 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"struct"))).toIntern(),
18847 .val = try pt.intern(.{ .aggregate = .{18847 .val = try pt.intern(.{ .aggregate = .{
18848 .ty = type_struct_ty.toIntern(),18848 .ty = type_struct_ty.toIntern(),
18849 .storage = .{ .elems = &field_values },18849 .storage = .{ .elems = &field_values },
18850 } }),18850 } }),
18851 } })));18851 } })));
18852 },18852 },
18853 .Opaque => {18853 .@"opaque" => {
18854 const type_opaque_ty = t: {18854 const type_opaque_ty = t: {
18855 const nav = try sema.namespaceLookup(18855 const nav = try sema.namespaceLookup(
18856 block,18856 block,
...@@ -18871,15 +18871,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -18871,15 +18871,15 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
18871 };18871 };
18872 return Air.internedToRef((try pt.intern(.{ .un = .{18872 return Air.internedToRef((try pt.intern(.{ .un = .{
18873 .ty = type_info_ty.toIntern(),18873 .ty = type_info_ty.toIntern(),
18874 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.Opaque))).toIntern(),18874 .tag = (try pt.enumValueFieldIndex(type_info_tag_ty, @intFromEnum(std.builtin.TypeId.@"opaque"))).toIntern(),
18875 .val = try pt.intern(.{ .aggregate = .{18875 .val = try pt.intern(.{ .aggregate = .{
18876 .ty = type_opaque_ty.toIntern(),18876 .ty = type_opaque_ty.toIntern(),
18877 .storage = .{ .elems = &field_values },18877 .storage = .{ .elems = &field_values },
18878 } }),18878 } }),
18879 } })));18879 } })));
18880 },18880 },
18881 .Frame => return sema.failWithUseOfAsync(block, src),18881 .frame => return sema.failWithUseOfAsync(block, src),
18882 .AnyFrame => return sema.failWithUseOfAsync(block, src),18882 .@"anyframe" => return sema.failWithUseOfAsync(block, src),
18883 }18883 }
18884}18884}
1888518885
...@@ -19064,8 +19064,8 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi...@@ -19064,8 +19064,8 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi
19064 const pt = sema.pt;19064 const pt = sema.pt;
19065 const zcu = pt.zcu;19065 const zcu = pt.zcu;
19066 switch (operand.zigTypeTag(zcu)) {19066 switch (operand.zigTypeTag(zcu)) {
19067 .ComptimeInt => return Type.comptime_int,19067 .comptime_int => return Type.comptime_int,
19068 .Int => {19068 .int => {
19069 const bits = operand.bitSize(zcu);19069 const bits = operand.bitSize(zcu);
19070 const count = if (bits == 0)19070 const count = if (bits == 0)
19071 019071 0
...@@ -19079,7 +19079,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi...@@ -19079,7 +19079,7 @@ fn log2IntType(sema: *Sema, block: *Block, operand: Type, src: LazySrcLoc) Compi
19079 };19079 };
19080 return pt.intType(.unsigned, count);19080 return pt.intType(.unsigned, count);
19081 },19081 },
19082 .Vector => {19082 .vector => {
19083 const elem_ty = operand.elemType2(zcu);19083 const elem_ty = operand.elemType2(zcu);
19084 const log2_elem_ty = try sema.log2IntType(block, elem_ty, src);19084 const log2_elem_ty = try sema.log2IntType(block, elem_ty, src);
19085 return pt.vectorType(.{19085 return pt.vectorType(.{
...@@ -19277,9 +19277,9 @@ fn finishCondBr(...@@ -19277,9 +19277,9 @@ fn finishCondBr(
19277) !Air.Inst.Ref {19277) !Air.Inst.Ref {
19278 const gpa = sema.gpa;19278 const gpa = sema.gpa;
1927919279
19280 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +19280 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
19281 then_block.instructions.items.len + else_block.instructions.items.len +19281 then_block.instructions.items.len + else_block.instructions.items.len +
19282 @typeInfo(Air.Block).Struct.fields.len + child_block.instructions.items.len + 1);19282 @typeInfo(Air.Block).@"struct".fields.len + child_block.instructions.items.len + 1);
1928319283
19284 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{19284 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
19285 .then_body_len = @intCast(then_block.instructions.items.len),19285 .then_body_len = @intCast(then_block.instructions.items.len),
...@@ -19307,8 +19307,8 @@ fn checkNullableType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !voi...@@ -19307,8 +19307,8 @@ fn checkNullableType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !voi
19307 const pt = sema.pt;19307 const pt = sema.pt;
19308 const zcu = pt.zcu;19308 const zcu = pt.zcu;
19309 switch (ty.zigTypeTag(zcu)) {19309 switch (ty.zigTypeTag(zcu)) {
19310 .Optional, .Null, .Undefined => return,19310 .optional, .null, .undefined => return,
19311 .Pointer => if (ty.isPtrLikeOptional(zcu)) return,19311 .pointer => if (ty.isPtrLikeOptional(zcu)) return,
19312 else => {},19312 else => {},
19313 }19313 }
19314 return sema.failWithExpectedOptionalType(block, src, ty);19314 return sema.failWithExpectedOptionalType(block, src, ty);
...@@ -19354,7 +19354,7 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void {...@@ -19354,7 +19354,7 @@ fn checkErrorType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void {
19354 const pt = sema.pt;19354 const pt = sema.pt;
19355 const zcu = pt.zcu;19355 const zcu = pt.zcu;
19356 switch (ty.zigTypeTag(zcu)) {19356 switch (ty.zigTypeTag(zcu)) {
19357 .ErrorSet, .ErrorUnion, .Undefined => return,19357 .error_set, .error_union, .undefined => return,
19358 else => return sema.fail(block, src, "expected error union type, found '{}'", .{19358 else => return sema.fail(block, src, "expected error union type, found '{}'", .{
19359 ty.fmt(pt),19359 ty.fmt(pt),
19360 }),19360 }),
...@@ -19451,7 +19451,7 @@ fn zirCondbr(...@@ -19451,7 +19451,7 @@ fn zirCondbr(
19451 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;19451 const err_inst_data = sema.code.instructions.items(.data)[@intFromEnum(index)].un_node;
19452 const err_operand = try sema.resolveInst(err_inst_data.operand);19452 const err_operand = try sema.resolveInst(err_inst_data.operand);
19453 const operand_ty = sema.typeOf(err_operand);19453 const operand_ty = sema.typeOf(err_operand);
19454 assert(operand_ty.zigTypeTag(zcu) == .ErrorUnion);19454 assert(operand_ty.zigTypeTag(zcu) == .error_union);
19455 const result_ty = operand_ty.errorUnionSet(zcu);19455 const result_ty = operand_ty.errorUnionSet(zcu);
19456 break :blk try sub_block.addTyOp(.unwrap_errunion_err, result_ty, err_operand);19456 break :blk try sub_block.addTyOp(.unwrap_errunion_err, result_ty, err_operand);
19457 };19457 };
...@@ -19463,7 +19463,7 @@ fn zirCondbr(...@@ -19463,7 +19463,7 @@ fn zirCondbr(
19463 break :h .unlikely;19463 break :h .unlikely;
19464 } else try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);19464 } else try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);
1946519465
19466 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +19466 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
19467 true_instructions.len + sub_block.instructions.items.len);19467 true_instructions.len + sub_block.instructions.items.len);
19468 _ = try parent_block.addInst(.{19468 _ = try parent_block.addInst(.{
19469 .tag = .cond_br,19469 .tag = .cond_br,
...@@ -19490,7 +19490,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -19490,7 +19490,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
19490 const err_union_ty = sema.typeOf(err_union);19490 const err_union_ty = sema.typeOf(err_union);
19491 const pt = sema.pt;19491 const pt = sema.pt;
19492 const zcu = pt.zcu;19492 const zcu = pt.zcu;
19493 if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) {19493 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
19494 return sema.fail(parent_block, operand_src, "expected error union type, found '{}'", .{19494 return sema.fail(parent_block, operand_src, "expected error union type, found '{}'", .{
19495 err_union_ty.fmt(pt),19495 err_union_ty.fmt(pt),
19496 });19496 });
...@@ -19524,7 +19524,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -19524,7 +19524,7 @@ fn zirTry(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileError!
19524 // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`.19524 // The only interesting hint here is `.cold`, which can come from e.g. `errdefer @panic`.
19525 const is_cold = sema.branch_hint == .cold;19525 const is_cold = sema.branch_hint == .cold;
1952619526
19527 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).Struct.fields.len +19527 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.Try).@"struct".fields.len +
19528 sub_block.instructions.items.len);19528 sub_block.instructions.items.len);
19529 const try_inst = try parent_block.addInst(.{19529 const try_inst = try parent_block.addInst(.{
19530 .tag = if (is_cold) .try_cold else .@"try",19530 .tag = if (is_cold) .try_cold else .@"try",
...@@ -19550,7 +19550,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -19550,7 +19550,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
19550 const err_union_ty = sema.typeOf(err_union);19550 const err_union_ty = sema.typeOf(err_union);
19551 const pt = sema.pt;19551 const pt = sema.pt;
19552 const zcu = pt.zcu;19552 const zcu = pt.zcu;
19553 if (err_union_ty.zigTypeTag(zcu) != .ErrorUnion) {19553 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
19554 return sema.fail(parent_block, operand_src, "expected error union type, found '{}'", .{19554 return sema.fail(parent_block, operand_src, "expected error union type, found '{}'", .{
19555 err_union_ty.fmt(pt),19555 err_union_ty.fmt(pt),
19556 });19556 });
...@@ -19596,7 +19596,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr...@@ -19596,7 +19596,7 @@ fn zirTryPtr(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErr
19596 },19596 },
19597 });19597 });
19598 const res_ty_ref = Air.internedToRef(res_ty.toIntern());19598 const res_ty_ref = Air.internedToRef(res_ty.toIntern());
19599 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).Struct.fields.len +19599 try sema.air_extra.ensureUnusedCapacity(sema.gpa, @typeInfo(Air.TryPtr).@"struct".fields.len +
19600 sub_block.instructions.items.len);19600 sub_block.instructions.items.len);
19601 const try_inst = try parent_block.addInst(.{19601 const try_inst = try parent_block.addInst(.{
19602 .tag = if (is_cold) .try_ptr_cold else .try_ptr,19602 .tag = if (is_cold) .try_ptr_cold else .try_ptr,
...@@ -19747,7 +19747,7 @@ fn zirRetImplicit(...@@ -19747,7 +19747,7 @@ fn zirRetImplicit(
19747 const operand = try sema.resolveInst(inst_data.operand);19747 const operand = try sema.resolveInst(inst_data.operand);
19748 const ret_ty_src = block.src(.{ .node_offset_fn_type_ret_ty = 0 });19748 const ret_ty_src = block.src(.{ .node_offset_fn_type_ret_ty = 0 });
19749 const base_tag = sema.fn_ret_ty.baseZigTypeTag(zcu);19749 const base_tag = sema.fn_ret_ty.baseZigTypeTag(zcu);
19750 if (base_tag == .NoReturn) {19750 if (base_tag == .noreturn) {
19751 const msg = msg: {19751 const msg = msg: {
19752 const msg = try sema.errMsg(ret_ty_src, "function declared '{}' implicitly returns", .{19752 const msg = try sema.errMsg(ret_ty_src, "function declared '{}' implicitly returns", .{
19753 sema.fn_ret_ty.fmt(pt),19753 sema.fn_ret_ty.fmt(pt),
...@@ -19757,7 +19757,7 @@ fn zirRetImplicit(...@@ -19757,7 +19757,7 @@ fn zirRetImplicit(
19757 break :msg msg;19757 break :msg msg;
19758 };19758 };
19759 return sema.failWithOwnedErrorMsg(block, msg);19759 return sema.failWithOwnedErrorMsg(block, msg);
19760 } else if (base_tag != .Void) {19760 } else if (base_tag != .void) {
19761 const msg = msg: {19761 const msg = msg: {
19762 const msg = try sema.errMsg(ret_ty_src, "function with non-void return type '{}' implicitly returns", .{19762 const msg = try sema.errMsg(ret_ty_src, "function with non-void return type '{}' implicitly returns", .{
19763 sema.fn_ret_ty.fmt(pt),19763 sema.fn_ret_ty.fmt(pt),
...@@ -19844,9 +19844,9 @@ fn retWithErrTracing(...@@ -19844,9 +19844,9 @@ fn retWithErrTracing(
19844 try sema.callBuiltin(&else_block, src, return_err_fn, .never_inline, &args, .@"error return");19844 try sema.callBuiltin(&else_block, src, return_err_fn, .never_inline, &args, .@"error return");
19845 _ = try else_block.addUnOp(ret_tag, operand);19845 _ = try else_block.addUnOp(ret_tag, operand);
1984619846
19847 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +19847 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).@"struct".fields.len +
19848 then_block.instructions.items.len + else_block.instructions.items.len +19848 then_block.instructions.items.len + else_block.instructions.items.len +
19849 @typeInfo(Air.Block).Struct.fields.len + 1);19849 @typeInfo(Air.Block).@"struct".fields.len + 1);
1985019850
19851 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{19851 const cond_br_payload = sema.addExtraAssumeCapacity(Air.CondBr{
19852 .then_body_len = @intCast(then_block.instructions.items.len),19852 .then_body_len = @intCast(then_block.instructions.items.len),
...@@ -19958,7 +19958,7 @@ fn addToInferredErrorSet(sema: *Sema, uncasted_operand: Air.Inst.Ref) !void {...@@ -19958,7 +19958,7 @@ fn addToInferredErrorSet(sema: *Sema, uncasted_operand: Air.Inst.Ref) !void {
19958 const pt = sema.pt;19958 const pt = sema.pt;
19959 const zcu = pt.zcu;19959 const zcu = pt.zcu;
19960 const ip = &zcu.intern_pool;19960 const ip = &zcu.intern_pool;
19961 assert(sema.fn_ret_ty.zigTypeTag(zcu) == .ErrorUnion);19961 assert(sema.fn_ret_ty.zigTypeTag(zcu) == .error_union);
19962 const err_set_ty = sema.fn_ret_ty.errorUnionSet(zcu).toIntern();19962 const err_set_ty = sema.fn_ret_ty.errorUnionSet(zcu).toIntern();
19963 switch (err_set_ty) {19963 switch (err_set_ty) {
19964 .adhoc_inferred_error_set_type => {19964 .adhoc_inferred_error_set_type => {
...@@ -19980,8 +19980,8 @@ fn addToInferredErrorSetPtr(sema: *Sema, ies: *InferredErrorSet, op_ty: Type) !v...@@ -19980,8 +19980,8 @@ fn addToInferredErrorSetPtr(sema: *Sema, ies: *InferredErrorSet, op_ty: Type) !v
19980 const zcu = pt.zcu;19980 const zcu = pt.zcu;
19981 const ip = &zcu.intern_pool;19981 const ip = &zcu.intern_pool;
19982 switch (op_ty.zigTypeTag(zcu)) {19982 switch (op_ty.zigTypeTag(zcu)) {
19983 .ErrorSet => try ies.addErrorSet(op_ty, ip, arena),19983 .error_set => try ies.addErrorSet(op_ty, ip, arena),
19984 .ErrorUnion => try ies.addErrorSet(op_ty.errorUnionSet(zcu), ip, arena),19984 .error_union => try ies.addErrorSet(op_ty.errorUnionSet(zcu), ip, arena),
19985 else => {},19985 else => {},
19986 }19986 }
19987}19987}
...@@ -19998,7 +19998,7 @@ fn analyzeRet(...@@ -19998,7 +19998,7 @@ fn analyzeRet(
19998 // that the coercion below works correctly.19998 // that the coercion below works correctly.
19999 const pt = sema.pt;19999 const pt = sema.pt;
20000 const zcu = pt.zcu;20000 const zcu = pt.zcu;
20001 if (sema.fn_ret_ty_ies != null and sema.fn_ret_ty.zigTypeTag(zcu) == .ErrorUnion) {20001 if (sema.fn_ret_ty_ies != null and sema.fn_ret_ty.zigTypeTag(zcu) == .error_union) {
20002 try sema.addToInferredErrorSet(uncasted_operand);20002 try sema.addToInferredErrorSet(uncasted_operand);
20003 }20003 }
20004 const operand = sema.coerceExtra(block, sema.fn_ret_ty, uncasted_operand, operand_src, .{ .is_ret = true }) catch |err| switch (err) {20004 const operand = sema.coerceExtra(block, sema.fn_ret_ty, uncasted_operand, operand_src, .{ .is_ret = true }) catch |err| switch (err) {
...@@ -20087,7 +20087,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -20087,7 +20087,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
20087 break :blk ty;20087 break :blk ty;
20088 };20088 };
2008920089
20090 if (elem_ty.zigTypeTag(zcu) == .NoReturn)20090 if (elem_ty.zigTypeTag(zcu) == .noreturn)
20091 return sema.fail(block, elem_ty_src, "pointer to noreturn not allowed", .{});20091 return sema.fail(block, elem_ty_src, "pointer to noreturn not allowed", .{});
2009220092
20093 const target = zcu.getTarget();20093 const target = zcu.getTarget();
...@@ -20128,7 +20128,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -20128,7 +20128,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
20128 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);20128 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
20129 extra_i += 1;20129 extra_i += 1;
20130 break :blk try sema.resolveAddressSpace(block, addrspace_src, ref, .pointer);20130 break :blk try sema.resolveAddressSpace(block, addrspace_src, ref, .pointer);
20131 } else if (elem_ty.zigTypeTag(zcu) == .Fn and target.cpu.arch == .avr) .flash else .generic;20131 } else if (elem_ty.zigTypeTag(zcu) == .@"fn" and target.cpu.arch == .avr) .flash else .generic;
2013220132
20133 const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: {20133 const bit_offset: u16 = if (inst_data.flags.has_bit_range) blk: {
20134 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);20134 const ref: Zir.Inst.Ref = @enumFromInt(sema.code.extra[extra_i]);
...@@ -20162,11 +20162,11 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -20162,11 +20162,11 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
20162 }20162 }
20163 }20163 }
2016420164
20165 if (elem_ty.zigTypeTag(zcu) == .Fn) {20165 if (elem_ty.zigTypeTag(zcu) == .@"fn") {
20166 if (inst_data.size != .One) {20166 if (inst_data.size != .One) {
20167 return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{});20167 return sema.fail(block, elem_ty_src, "function pointers must be single pointers", .{});
20168 }20168 }
20169 } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .Opaque) {20169 } else if (inst_data.size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
20170 return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{});20170 return sema.fail(block, elem_ty_src, "unknown-length pointer to opaque not allowed", .{});
20171 } else if (inst_data.size == .C) {20171 } else if (inst_data.size == .C) {
20172 if (!try sema.validateExternType(elem_ty, .other)) {20172 if (!try sema.validateExternType(elem_ty, .other)) {
...@@ -20181,7 +20181,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -20181,7 +20181,7 @@ fn zirPtrType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
20181 };20181 };
20182 return sema.failWithOwnedErrorMsg(block, msg);20182 return sema.failWithOwnedErrorMsg(block, msg);
20183 }20183 }
20184 if (elem_ty.zigTypeTag(zcu) == .Opaque) {20184 if (elem_ty.zigTypeTag(zcu) == .@"opaque") {
20185 return sema.fail(block, elem_ty_src, "C pointers cannot point to opaque types", .{});20185 return sema.fail(block, elem_ty_src, "C pointers cannot point to opaque types", .{});
20186 }20186 }
20187 }20187 }
...@@ -20226,10 +20226,10 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE...@@ -20226,10 +20226,10 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
20226 const zcu = pt.zcu;20226 const zcu = pt.zcu;
2022720227
20228 switch (obj_ty.zigTypeTag(zcu)) {20228 switch (obj_ty.zigTypeTag(zcu)) {
20229 .Struct => return sema.structInitEmpty(block, obj_ty, src, src),20229 .@"struct" => return sema.structInitEmpty(block, obj_ty, src, src),
20230 .Array, .Vector => return sema.arrayInitEmpty(block, src, obj_ty),20230 .array, .vector => return sema.arrayInitEmpty(block, src, obj_ty),
20231 .Void => return Air.internedToRef(Value.void.toIntern()),20231 .void => return Air.internedToRef(Value.void.toIntern()),
20232 .Union => return sema.fail(block, src, "union initializer must initialize one field", .{}),20232 .@"union" => return sema.fail(block, src, "union initializer must initialize one field", .{}),
20233 else => return sema.failWithArrayInitNotSupported(block, src, obj_ty),20233 else => return sema.failWithArrayInitNotSupported(block, src, obj_ty),
20234 }20234 }
20235}20235}
...@@ -20249,7 +20249,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is...@@ -20249,7 +20249,7 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is
20249 };20249 };
20250 const init_ty = if (is_byref) ty: {20250 const init_ty = if (is_byref) ty: {
20251 const ptr_ty = ty_operand.optEuBaseType(zcu);20251 const ptr_ty = ty_operand.optEuBaseType(zcu);
20252 assert(ptr_ty.zigTypeTag(zcu) == .Pointer); // validated by a previous instruction20252 assert(ptr_ty.zigTypeTag(zcu) == .pointer); // validated by a previous instruction
20253 if (!ptr_ty.isSlice(zcu)) {20253 if (!ptr_ty.isSlice(zcu)) {
20254 break :ty ptr_ty.childType(zcu);20254 break :ty ptr_ty.childType(zcu);
20255 }20255 }
...@@ -20263,9 +20263,9 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is...@@ -20263,9 +20263,9 @@ fn zirStructInitEmptyResult(sema: *Sema, block: *Block, inst: Zir.Inst.Index, is
20263 const obj_ty = init_ty.optEuBaseType(zcu);20263 const obj_ty = init_ty.optEuBaseType(zcu);
2026420264
20265 const empty_ref = switch (obj_ty.zigTypeTag(zcu)) {20265 const empty_ref = switch (obj_ty.zigTypeTag(zcu)) {
20266 .Struct => try sema.structInitEmpty(block, obj_ty, src, src),20266 .@"struct" => try sema.structInitEmpty(block, obj_ty, src, src),
20267 .Array, .Vector => try sema.arrayInitEmpty(block, src, obj_ty),20267 .array, .vector => try sema.arrayInitEmpty(block, src, obj_ty),
20268 .Union => return sema.fail(block, src, "union initializer must initialize one field", .{}),20268 .@"union" => return sema.fail(block, src, "union initializer must initialize one field", .{}),
20269 else => return sema.failWithArrayInitNotSupported(block, src, obj_ty),20269 else => return sema.failWithArrayInitNotSupported(block, src, obj_ty),
20270 };20270 };
20271 const init_ref = try sema.coerce(block, init_ty, empty_ref, src);20271 const init_ref = try sema.coerce(block, init_ty, empty_ref, src);
...@@ -20304,7 +20304,7 @@ fn arrayInitEmpty(sema: *Sema, block: *Block, src: LazySrcLoc, obj_ty: Type) Com...@@ -20304,7 +20304,7 @@ fn arrayInitEmpty(sema: *Sema, block: *Block, src: LazySrcLoc, obj_ty: Type) Com
20304 const zcu = pt.zcu;20304 const zcu = pt.zcu;
20305 const arr_len = obj_ty.arrayLen(zcu);20305 const arr_len = obj_ty.arrayLen(zcu);
20306 if (arr_len != 0) {20306 if (arr_len != 0) {
20307 if (obj_ty.zigTypeTag(zcu) == .Array) {20307 if (obj_ty.zigTypeTag(zcu) == .array) {
20308 return sema.fail(block, src, "expected {d} array elements; found 0", .{arr_len});20308 return sema.fail(block, src, "expected {d} array elements; found 0", .{arr_len});
20309 } else {20309 } else {
20310 return sema.fail(block, src, "expected {d} vector elements; found 0", .{arr_len});20310 return sema.fail(block, src, "expected {d} vector elements; found 0", .{arr_len});
...@@ -20324,7 +20324,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -20324,7 +20324,7 @@ fn zirUnionInit(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
20324 const init_src = block.builtinCallArgSrc(inst_data.src_node, 2);20324 const init_src = block.builtinCallArgSrc(inst_data.src_node, 2);
20325 const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data;20325 const extra = sema.code.extraData(Zir.Inst.UnionInit, inst_data.payload_index).data;
20326 const union_ty = try sema.resolveType(block, ty_src, extra.union_type);20326 const union_ty = try sema.resolveType(block, ty_src, extra.union_type);
20327 if (union_ty.zigTypeTag(pt.zcu) != .Union) {20327 if (union_ty.zigTypeTag(pt.zcu) != .@"union") {
20328 return sema.fail(block, ty_src, "expected union type, found '{}'", .{union_ty.fmt(pt)});20328 return sema.fail(block, ty_src, "expected union type, found '{}'", .{union_ty.fmt(pt)});
20329 }20329 }
20330 const field_name = try sema.resolveConstStringIntern(block, field_src, extra.field_name, .{20330 const field_name = try sema.resolveConstStringIntern(block, field_src, extra.field_name, .{
...@@ -20394,7 +20394,7 @@ fn zirStructInit(...@@ -20394,7 +20394,7 @@ fn zirStructInit(
20394 const resolved_ty = result_ty.optEuBaseType(zcu);20394 const resolved_ty = result_ty.optEuBaseType(zcu);
20395 try resolved_ty.resolveLayout(pt);20395 try resolved_ty.resolveLayout(pt);
2039620396
20397 if (resolved_ty.zigTypeTag(zcu) == .Struct) {20397 if (resolved_ty.zigTypeTag(zcu) == .@"struct") {
20398 // This logic must be synchronized with that in `zirStructInitEmpty`.20398 // This logic must be synchronized with that in `zirStructInitEmpty`.
2039920399
20400 // Maps field index to field_type index of where it was already initialized.20400 // Maps field index to field_type index of where it was already initialized.
...@@ -20450,7 +20450,7 @@ fn zirStructInit(...@@ -20450,7 +20450,7 @@ fn zirStructInit(
20450 }20450 }
2045120451
20452 return sema.finishStructInit(block, src, src, field_inits, resolved_ty, result_ty, is_ref);20452 return sema.finishStructInit(block, src, src, field_inits, resolved_ty, result_ty, is_ref);
20453 } else if (resolved_ty.zigTypeTag(zcu) == .Union) {20453 } else if (resolved_ty.zigTypeTag(zcu) == .@"union") {
20454 if (extra.data.fields_len != 1) {20454 if (extra.data.fields_len != 1) {
20455 return sema.fail(block, src, "union initialization expects exactly one field", .{});20455 return sema.fail(block, src, "union initialization expects exactly one field", .{});
20456 }20456 }
...@@ -20471,7 +20471,7 @@ fn zirStructInit(...@@ -20471,7 +20471,7 @@ fn zirStructInit(
20471 const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index);20471 const tag_val = try pt.enumValueFieldIndex(tag_ty, field_index);
20472 const field_ty = Type.fromInterned(zcu.typeToUnion(resolved_ty).?.field_types.get(ip)[field_index]);20472 const field_ty = Type.fromInterned(zcu.typeToUnion(resolved_ty).?.field_types.get(ip)[field_index]);
2047320473
20474 if (field_ty.zigTypeTag(zcu) == .NoReturn) {20474 if (field_ty.zigTypeTag(zcu) == .noreturn) {
20475 return sema.failWithOwnedErrorMsg(block, msg: {20475 return sema.failWithOwnedErrorMsg(block, msg: {
20476 const msg = try sema.errMsg(src, "cannot initialize 'noreturn' field of union", .{});20476 const msg = try sema.errMsg(src, "cannot initialize 'noreturn' field of union", .{});
20477 errdefer msg.destroy(sema.gpa);20477 errdefer msg.destroy(sema.gpa);
...@@ -20756,7 +20756,7 @@ fn structInitAnon(...@@ -20756,7 +20756,7 @@ fn structInitAnon(
2075620756
20757 const init = try sema.resolveInst(item.data.init);20757 const init = try sema.resolveInst(item.data.init);
20758 field_ty.* = sema.typeOf(init).toIntern();20758 field_ty.* = sema.typeOf(init).toIntern();
20759 if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .Opaque) {20759 if (Type.fromInterned(field_ty.*).zigTypeTag(zcu) == .@"opaque") {
20760 const msg = msg: {20760 const msg = msg: {
20761 const field_src = block.src(.{ .init_elem = .{20761 const field_src = block.src(.{ .init_elem = .{
20762 .init_node_offset = src.offset.node_offset.x,20762 .init_node_offset = src.offset.node_offset.x,
...@@ -20867,7 +20867,7 @@ fn zirArrayInit(...@@ -20867,7 +20867,7 @@ fn zirArrayInit(
20867 else => |e| return e,20867 else => |e| return e,
20868 };20868 };
20869 const array_ty = result_ty.optEuBaseType(zcu);20869 const array_ty = result_ty.optEuBaseType(zcu);
20870 const is_tuple = array_ty.zigTypeTag(zcu) == .Struct;20870 const is_tuple = array_ty.zigTypeTag(zcu) == .@"struct";
20871 const sentinel_val = array_ty.sentinel(zcu);20871 const sentinel_val = array_ty.sentinel(zcu);
2087220872
20873 var root_msg: ?*Zcu.ErrorMsg = null;20873 var root_msg: ?*Zcu.ErrorMsg = null;
...@@ -21029,7 +21029,7 @@ fn arrayInitAnon(...@@ -21029,7 +21029,7 @@ fn arrayInitAnon(
21029 const operand_src = src; // TODO better source location21029 const operand_src = src; // TODO better source location
21030 const elem = try sema.resolveInst(operand);21030 const elem = try sema.resolveInst(operand);
21031 types[i] = sema.typeOf(elem).toIntern();21031 types[i] = sema.typeOf(elem).toIntern();
21032 if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .Opaque) {21032 if (Type.fromInterned(types[i]).zigTypeTag(zcu) == .@"opaque") {
21033 const msg = msg: {21033 const msg = msg: {
21034 const msg = try sema.errMsg(operand_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});21034 const msg = try sema.errMsg(operand_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});
21035 errdefer msg.destroy(gpa);21035 errdefer msg.destroy(gpa);
...@@ -21148,7 +21148,7 @@ fn fieldType(...@@ -21148,7 +21148,7 @@ fn fieldType(
21148 while (true) {21148 while (true) {
21149 try cur_ty.resolveFields(pt);21149 try cur_ty.resolveFields(pt);
21150 switch (cur_ty.zigTypeTag(zcu)) {21150 switch (cur_ty.zigTypeTag(zcu)) {
21151 .Struct => switch (ip.indexToKey(cur_ty.toIntern())) {21151 .@"struct" => switch (ip.indexToKey(cur_ty.toIntern())) {
21152 .anon_struct_type => |anon_struct| {21152 .anon_struct_type => |anon_struct| {
21153 const field_index = if (anon_struct.names.len == 0)21153 const field_index = if (anon_struct.names.len == 0)
21154 try sema.tupleFieldIndex(block, cur_ty, field_name, field_src)21154 try sema.tupleFieldIndex(block, cur_ty, field_name, field_src)
...@@ -21165,20 +21165,20 @@ fn fieldType(...@@ -21165,20 +21165,20 @@ fn fieldType(
21165 },21165 },
21166 else => unreachable,21166 else => unreachable,
21167 },21167 },
21168 .Union => {21168 .@"union" => {
21169 const union_obj = zcu.typeToUnion(cur_ty).?;21169 const union_obj = zcu.typeToUnion(cur_ty).?;
21170 const field_index = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse21170 const field_index = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse
21171 return sema.failWithBadUnionFieldAccess(block, cur_ty, union_obj, field_src, field_name);21171 return sema.failWithBadUnionFieldAccess(block, cur_ty, union_obj, field_src, field_name);
21172 const field_ty = union_obj.field_types.get(ip)[field_index];21172 const field_ty = union_obj.field_types.get(ip)[field_index];
21173 return Air.internedToRef(field_ty);21173 return Air.internedToRef(field_ty);
21174 },21174 },
21175 .Optional => {21175 .optional => {
21176 // Struct/array init through optional requires the child type to not be a pointer.21176 // Struct/array init through optional requires the child type to not be a pointer.
21177 // If the child of .optional is a pointer it'll error on the next loop.21177 // If the child of .optional is a pointer it'll error on the next loop.
21178 cur_ty = Type.fromInterned(ip.indexToKey(cur_ty.toIntern()).opt_type);21178 cur_ty = Type.fromInterned(ip.indexToKey(cur_ty.toIntern()).opt_type);
21179 continue;21179 continue;
21180 },21180 },
21181 .ErrorUnion => {21181 .error_union => {
21182 cur_ty = cur_ty.errorUnionPayload(zcu);21182 cur_ty = cur_ty.errorUnionPayload(zcu);
21183 continue;21183 continue;
21184 },21184 },
...@@ -21243,7 +21243,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -21243,7 +21243,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
21243 const src = block.nodeOffset(inst_data.src_node);21243 const src = block.nodeOffset(inst_data.src_node);
21244 const operand = try sema.resolveInst(inst_data.operand);21244 const operand = try sema.resolveInst(inst_data.operand);
21245 const operand_ty = sema.typeOf(operand);21245 const operand_ty = sema.typeOf(operand);
21246 const is_vector = operand_ty.zigTypeTag(zcu) == .Vector;21246 const is_vector = operand_ty.zigTypeTag(zcu) == .vector;
21247 const operand_scalar_ty = operand_ty.scalarType(zcu);21247 const operand_scalar_ty = operand_ty.scalarType(zcu);
21248 if (operand_scalar_ty.toIntern() != .bool_type) {21248 if (operand_scalar_ty.toIntern() != .bool_type) {
21249 return sema.fail(block, src, "expected 'bool', found '{}'", .{operand_scalar_ty.zigTypeTag(zcu)});21249 return sema.fail(block, src, "expected 'bool', found '{}'", .{operand_scalar_ty.zigTypeTag(zcu)});
...@@ -21317,8 +21317,8 @@ fn zirAbs(...@@ -21317,8 +21317,8 @@ fn zirAbs(
21317 const scalar_ty = operand_ty.scalarType(zcu);21317 const scalar_ty = operand_ty.scalarType(zcu);
2131821318
21319 const result_ty = switch (scalar_ty.zigTypeTag(zcu)) {21319 const result_ty = switch (scalar_ty.zigTypeTag(zcu)) {
21320 .ComptimeFloat, .Float, .ComptimeInt => operand_ty,21320 .comptime_float, .float, .comptime_int => operand_ty,
21321 .Int => if (scalar_ty.isSignedInt(zcu)) try operand_ty.toUnsigned(pt) else return operand,21321 .int => if (scalar_ty.isSignedInt(zcu)) try operand_ty.toUnsigned(pt) else return operand,
21322 else => return sema.fail(21322 else => return sema.fail(
21323 block,21323 block,
21324 operand_src,21324 operand_src,
...@@ -21342,7 +21342,7 @@ fn maybeConstantUnaryMath(...@@ -21342,7 +21342,7 @@ fn maybeConstantUnaryMath(
21342 const pt = sema.pt;21342 const pt = sema.pt;
21343 const zcu = pt.zcu;21343 const zcu = pt.zcu;
21344 switch (result_ty.zigTypeTag(zcu)) {21344 switch (result_ty.zigTypeTag(zcu)) {
21345 .Vector => if (try sema.resolveValue(operand)) |val| {21345 .vector => if (try sema.resolveValue(operand)) |val| {
21346 const scalar_ty = result_ty.scalarType(zcu);21346 const scalar_ty = result_ty.scalarType(zcu);
21347 const vec_len = result_ty.vectorLen(zcu);21347 const vec_len = result_ty.vectorLen(zcu);
21348 if (val.isUndef(zcu))21348 if (val.isUndef(zcu))
...@@ -21387,7 +21387,7 @@ fn zirUnaryMath(...@@ -21387,7 +21387,7 @@ fn zirUnaryMath(
21387 const scalar_ty = operand_ty.scalarType(zcu);21387 const scalar_ty = operand_ty.scalarType(zcu);
2138821388
21389 switch (scalar_ty.zigTypeTag(zcu)) {21389 switch (scalar_ty.zigTypeTag(zcu)) {
21390 .ComptimeFloat, .Float => {},21390 .comptime_float, .float => {},
21391 else => return sema.fail(21391 else => return sema.fail(
21392 block,21392 block,
21393 operand_src,21393 operand_src,
...@@ -21414,13 +21414,13 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -21414,13 +21414,13 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
2141421414
21415 try operand_ty.resolveLayout(pt);21415 try operand_ty.resolveLayout(pt);
21416 const enum_ty = switch (operand_ty.zigTypeTag(zcu)) {21416 const enum_ty = switch (operand_ty.zigTypeTag(zcu)) {
21417 .EnumLiteral => {21417 .enum_literal => {
21418 const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, operand, undefined);21418 const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, operand, undefined);
21419 const tag_name = ip.indexToKey(val.toIntern()).enum_literal;21419 const tag_name = ip.indexToKey(val.toIntern()).enum_literal;
21420 return sema.addNullTerminatedStrLit(tag_name);21420 return sema.addNullTerminatedStrLit(tag_name);
21421 },21421 },
21422 .Enum => operand_ty,21422 .@"enum" => operand_ty,
21423 .Union => operand_ty.unionTagType(zcu) orelse21423 .@"union" => operand_ty.unionTagType(zcu) orelse
21424 return sema.fail(block, src, "union '{}' is untagged", .{operand_ty.fmt(pt)}),21424 return sema.fail(block, src, "union '{}' is untagged", .{operand_ty.fmt(pt)}),
21425 else => return sema.fail(block, operand_src, "expected enum or union; found '{}'", .{21425 else => return sema.fail(block, operand_src, "expected enum or union; found '{}'", .{
21426 operand_ty.fmt(pt),21426 operand_ty.fmt(pt),
...@@ -21500,17 +21500,17 @@ fn zirReify(...@@ -21500,17 +21500,17 @@ fn zirReify(
21500 }21500 }
21501 const tag_index = type_info_ty.unionTagFieldIndex(Value.fromInterned(union_val.tag), zcu).?;21501 const tag_index = type_info_ty.unionTagFieldIndex(Value.fromInterned(union_val.tag), zcu).?;
21502 switch (@as(std.builtin.TypeId, @enumFromInt(tag_index))) {21502 switch (@as(std.builtin.TypeId, @enumFromInt(tag_index))) {
21503 .Type => return .type_type,21503 .type => return .type_type,
21504 .Void => return .void_type,21504 .void => return .void_type,
21505 .Bool => return .bool_type,21505 .bool => return .bool_type,
21506 .NoReturn => return .noreturn_type,21506 .noreturn => return .noreturn_type,
21507 .ComptimeFloat => return .comptime_float_type,21507 .comptime_float => return .comptime_float_type,
21508 .ComptimeInt => return .comptime_int_type,21508 .comptime_int => return .comptime_int_type,
21509 .Undefined => return .undefined_type,21509 .undefined => return .undefined_type,
21510 .Null => return .null_type,21510 .null => return .null_type,
21511 .AnyFrame => return sema.failWithUseOfAsync(block, src),21511 .@"anyframe" => return sema.failWithUseOfAsync(block, src),
21512 .EnumLiteral => return .enum_literal_type,21512 .enum_literal => return .enum_literal_type,
21513 .Int => {21513 .int => {
21514 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21514 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21515 const signedness_val = try Value.fromInterned(union_val.val).fieldValue(21515 const signedness_val = try Value.fromInterned(union_val.val).fieldValue(
21516 pt,21516 pt,
...@@ -21526,7 +21526,7 @@ fn zirReify(...@@ -21526,7 +21526,7 @@ fn zirReify(
21526 const ty = try pt.intType(signedness, bits);21526 const ty = try pt.intType(signedness, bits);
21527 return Air.internedToRef(ty.toIntern());21527 return Air.internedToRef(ty.toIntern());
21528 },21528 },
21529 .Vector => {21529 .vector => {
21530 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21530 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21531 const len_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21531 const len_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21532 ip,21532 ip,
...@@ -21548,7 +21548,7 @@ fn zirReify(...@@ -21548,7 +21548,7 @@ fn zirReify(
21548 });21548 });
21549 return Air.internedToRef(ty.toIntern());21549 return Air.internedToRef(ty.toIntern());
21550 },21550 },
21551 .Float => {21551 .float => {
21552 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21552 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21553 const bits_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21553 const bits_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21554 ip,21554 ip,
...@@ -21566,7 +21566,7 @@ fn zirReify(...@@ -21566,7 +21566,7 @@ fn zirReify(
21566 };21566 };
21567 return Air.internedToRef(ty.toIntern());21567 return Air.internedToRef(ty.toIntern());
21568 },21568 },
21569 .Pointer => {21569 .pointer => {
21570 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21570 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21571 const size_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21571 const size_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21572 ip,21572 ip,
...@@ -21631,13 +21631,13 @@ fn zirReify(...@@ -21631,13 +21631,13 @@ fn zirReify(
21631 break :s .none;21631 break :s .none;
21632 };21632 };
2163321633
21634 if (elem_ty.zigTypeTag(zcu) == .NoReturn) {21634 if (elem_ty.zigTypeTag(zcu) == .noreturn) {
21635 return sema.fail(block, src, "pointer to noreturn not allowed", .{});21635 return sema.fail(block, src, "pointer to noreturn not allowed", .{});
21636 } else if (elem_ty.zigTypeTag(zcu) == .Fn) {21636 } else if (elem_ty.zigTypeTag(zcu) == .@"fn") {
21637 if (ptr_size != .One) {21637 if (ptr_size != .One) {
21638 return sema.fail(block, src, "function pointers must be single pointers", .{});21638 return sema.fail(block, src, "function pointers must be single pointers", .{});
21639 }21639 }
21640 } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .Opaque) {21640 } else if (ptr_size == .Many and elem_ty.zigTypeTag(zcu) == .@"opaque") {
21641 return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{});21641 return sema.fail(block, src, "unknown-length pointer to opaque not allowed", .{});
21642 } else if (ptr_size == .C) {21642 } else if (ptr_size == .C) {
21643 if (!try sema.validateExternType(elem_ty, .other)) {21643 if (!try sema.validateExternType(elem_ty, .other)) {
...@@ -21652,7 +21652,7 @@ fn zirReify(...@@ -21652,7 +21652,7 @@ fn zirReify(
21652 };21652 };
21653 return sema.failWithOwnedErrorMsg(block, msg);21653 return sema.failWithOwnedErrorMsg(block, msg);
21654 }21654 }
21655 if (elem_ty.zigTypeTag(zcu) == .Opaque) {21655 if (elem_ty.zigTypeTag(zcu) == .@"opaque") {
21656 return sema.fail(block, src, "C pointers cannot point to opaque types", .{});21656 return sema.fail(block, src, "C pointers cannot point to opaque types", .{});
21657 }21657 }
21658 }21658 }
...@@ -21671,7 +21671,7 @@ fn zirReify(...@@ -21671,7 +21671,7 @@ fn zirReify(
21671 });21671 });
21672 return Air.internedToRef(ty.toIntern());21672 return Air.internedToRef(ty.toIntern());
21673 },21673 },
21674 .Array => {21674 .array => {
21675 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21675 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21676 const len_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21676 const len_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21677 ip,21677 ip,
...@@ -21700,7 +21700,7 @@ fn zirReify(...@@ -21700,7 +21700,7 @@ fn zirReify(
21700 });21700 });
21701 return Air.internedToRef(ty.toIntern());21701 return Air.internedToRef(ty.toIntern());
21702 },21702 },
21703 .Optional => {21703 .optional => {
21704 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21704 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21705 const child_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21705 const child_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21706 ip,21706 ip,
...@@ -21712,7 +21712,7 @@ fn zirReify(...@@ -21712,7 +21712,7 @@ fn zirReify(
21712 const ty = try pt.optionalType(child_ty.toIntern());21712 const ty = try pt.optionalType(child_ty.toIntern());
21713 return Air.internedToRef(ty.toIntern());21713 return Air.internedToRef(ty.toIntern());
21714 },21714 },
21715 .ErrorUnion => {21715 .error_union => {
21716 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21716 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21717 const error_set_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21717 const error_set_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21718 ip,21718 ip,
...@@ -21726,14 +21726,14 @@ fn zirReify(...@@ -21726,14 +21726,14 @@ fn zirReify(
21726 const error_set_ty = error_set_val.toType();21726 const error_set_ty = error_set_val.toType();
21727 const payload_ty = payload_val.toType();21727 const payload_ty = payload_val.toType();
2172821728
21729 if (error_set_ty.zigTypeTag(zcu) != .ErrorSet) {21729 if (error_set_ty.zigTypeTag(zcu) != .error_set) {
21730 return sema.fail(block, src, "Type.ErrorUnion.error_set must be an error set type", .{});21730 return sema.fail(block, src, "Type.ErrorUnion.error_set must be an error set type", .{});
21731 }21731 }
2173221732
21733 const ty = try pt.errorUnionType(error_set_ty, payload_ty);21733 const ty = try pt.errorUnionType(error_set_ty, payload_ty);
21734 return Air.internedToRef(ty.toIntern());21734 return Air.internedToRef(ty.toIntern());
21735 },21735 },
21736 .ErrorSet => {21736 .error_set => {
21737 const payload_val = Value.fromInterned(union_val.val).optionalValue(zcu) orelse21737 const payload_val = Value.fromInterned(union_val.val).optionalValue(zcu) orelse
21738 return Air.internedToRef(Type.anyerror.toIntern());21738 return Air.internedToRef(Type.anyerror.toIntern());
2173921739
...@@ -21767,7 +21767,7 @@ fn zirReify(...@@ -21767,7 +21767,7 @@ fn zirReify(
21767 const ty = try pt.errorSetFromUnsortedNames(names.keys());21767 const ty = try pt.errorSetFromUnsortedNames(names.keys());
21768 return Air.internedToRef(ty.toIntern());21768 return Air.internedToRef(ty.toIntern());
21769 },21769 },
21770 .Struct => {21770 .@"struct" => {
21771 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21771 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21772 const layout_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21772 const layout_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21773 ip,21773 ip,
...@@ -21807,7 +21807,7 @@ fn zirReify(...@@ -21807,7 +21807,7 @@ fn zirReify(
2180721807
21808 return try sema.reifyStruct(block, inst, src, layout, backing_integer_val, fields_arr, name_strategy, is_tuple_val.toBool());21808 return try sema.reifyStruct(block, inst, src, layout, backing_integer_val, fields_arr, name_strategy, is_tuple_val.toBool());
21809 },21809 },
21810 .Enum => {21810 .@"enum" => {
21811 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21811 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21812 const tag_type_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21812 const tag_type_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21813 ip,21813 ip,
...@@ -21836,7 +21836,7 @@ fn zirReify(...@@ -21836,7 +21836,7 @@ fn zirReify(
2183621836
21837 return sema.reifyEnum(block, inst, src, tag_type_val.toType(), is_exhaustive_val.toBool(), fields_arr, name_strategy);21837 return sema.reifyEnum(block, inst, src, tag_type_val.toType(), is_exhaustive_val.toBool(), fields_arr, name_strategy);
21838 },21838 },
21839 .Opaque => {21839 .@"opaque" => {
21840 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21840 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21841 const decls_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21841 const decls_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21842 ip,21842 ip,
...@@ -21879,7 +21879,7 @@ fn zirReify(...@@ -21879,7 +21879,7 @@ fn zirReify(
21879 try sema.addTypeReferenceEntry(src, wip_ty.index);21879 try sema.addTypeReferenceEntry(src, wip_ty.index);
21880 return Air.internedToRef(wip_ty.finish(ip, .none, new_namespace_index));21880 return Air.internedToRef(wip_ty.finish(ip, .none, new_namespace_index));
21881 },21881 },
21882 .Union => {21882 .@"union" => {
21883 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21883 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21884 const layout_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21884 const layout_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21885 ip,21885 ip,
...@@ -21909,7 +21909,7 @@ fn zirReify(...@@ -21909,7 +21909,7 @@ fn zirReify(
2190921909
21910 return sema.reifyUnion(block, inst, src, layout, tag_type_val, fields_arr, name_strategy);21910 return sema.reifyUnion(block, inst, src, layout, tag_type_val, fields_arr, name_strategy);
21911 },21911 },
21912 .Fn => {21912 .@"fn" => {
21913 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));21913 const struct_type = ip.loadStructType(ip.typeOf(union_val.val));
21914 const calling_convention_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(21914 const calling_convention_val = try Value.fromInterned(union_val.val).fieldValue(pt, struct_type.nameIndex(
21915 ip,21915 ip,
...@@ -21996,7 +21996,7 @@ fn zirReify(...@@ -21996,7 +21996,7 @@ fn zirReify(
21996 });21996 });
21997 return Air.internedToRef(ty.toIntern());21997 return Air.internedToRef(ty.toIntern());
21998 },21998 },
21999 .Frame => return sema.failWithUseOfAsync(block, src),21999 .frame => return sema.failWithUseOfAsync(block, src),
22000 }22000 }
22001}22001}
2200222002
...@@ -22067,7 +22067,7 @@ fn reifyEnum(...@@ -22067,7 +22067,7 @@ fn reifyEnum(
22067 var done = false;22067 var done = false;
22068 errdefer if (!done) wip_ty.cancel(ip, pt.tid);22068 errdefer if (!done) wip_ty.cancel(ip, pt.tid);
2206922069
22070 if (tag_ty.zigTypeTag(zcu) != .Int) {22070 if (tag_ty.zigTypeTag(zcu) != .int) {
22071 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});22071 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});
22072 }22072 }
2207322073
...@@ -22344,7 +22344,7 @@ fn reifyUnion(...@@ -22344,7 +22344,7 @@ fn reifyUnion(
2234422344
22345 for (field_types) |field_ty_ip| {22345 for (field_types) |field_ty_ip| {
22346 const field_ty = Type.fromInterned(field_ty_ip);22346 const field_ty = Type.fromInterned(field_ty_ip);
22347 if (field_ty.zigTypeTag(zcu) == .Opaque) {22347 if (field_ty.zigTypeTag(zcu) == .@"opaque") {
22348 return sema.failWithOwnedErrorMsg(block, msg: {22348 return sema.failWithOwnedErrorMsg(block, msg: {
22349 const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{});22349 const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{});
22350 errdefer msg.destroy(gpa);22350 errdefer msg.destroy(gpa);
...@@ -22602,7 +22602,7 @@ fn reifyStruct(...@@ -22602,7 +22602,7 @@ fn reifyStruct(
22602 struct_type.field_inits.get(ip)[field_idx] = field_default;22602 struct_type.field_inits.get(ip)[field_idx] = field_default;
22603 }22603 }
2260422604
22605 if (field_ty.zigTypeTag(zcu) == .Opaque) {22605 if (field_ty.zigTypeTag(zcu) == .@"opaque") {
22606 return sema.failWithOwnedErrorMsg(block, msg: {22606 return sema.failWithOwnedErrorMsg(block, msg: {
22607 const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});22607 const msg = try sema.errMsg(src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});
22608 errdefer msg.destroy(gpa);22608 errdefer msg.destroy(gpa);
...@@ -22611,7 +22611,7 @@ fn reifyStruct(...@@ -22611,7 +22611,7 @@ fn reifyStruct(
22611 break :msg msg;22611 break :msg msg;
22612 });22612 });
22613 }22613 }
22614 if (field_ty.zigTypeTag(zcu) == .NoReturn) {22614 if (field_ty.zigTypeTag(zcu) == .noreturn) {
22615 return sema.failWithOwnedErrorMsg(block, msg: {22615 return sema.failWithOwnedErrorMsg(block, msg: {
22616 const msg = try sema.errMsg(src, "struct fields cannot be 'noreturn'", .{});22616 const msg = try sema.errMsg(src, "struct fields cannot be 'noreturn'", .{});
22617 errdefer msg.destroy(gpa);22617 errdefer msg.destroy(gpa);
...@@ -22794,7 +22794,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -22794,7 +22794,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22794 const operand_ty = sema.typeOf(operand);22794 const operand_ty = sema.typeOf(operand);
2279522795
22796 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);22796 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
22797 const is_vector = dest_ty.zigTypeTag(zcu) == .Vector;22797 const is_vector = dest_ty.zigTypeTag(zcu) == .vector;
2279822798
22799 const dest_scalar_ty = dest_ty.scalarType(zcu);22799 const dest_scalar_ty = dest_ty.scalarType(zcu);
22800 const operand_scalar_ty = operand_ty.scalarType(zcu);22800 const operand_scalar_ty = operand_ty.scalarType(zcu);
...@@ -22805,7 +22805,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -22805,7 +22805,7 @@ fn zirIntFromFloat(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22805 if (try sema.resolveValue(operand)) |operand_val| {22805 if (try sema.resolveValue(operand)) |operand_val| {
22806 const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate);22806 const result_val = try sema.intFromFloat(block, operand_src, operand_val, operand_ty, dest_ty, .truncate);
22807 return Air.internedToRef(result_val.toIntern());22807 return Air.internedToRef(result_val.toIntern());
22808 } else if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeInt) {22808 } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) {
22809 return sema.failWithNeededComptime(block, operand_src, .{22809 return sema.failWithNeededComptime(block, operand_src, .{
22810 .needed_comptime_reason = "value being casted to 'comptime_int' must be comptime-known",22810 .needed_comptime_reason = "value being casted to 'comptime_int' must be comptime-known",
22811 });22811 });
...@@ -22877,7 +22877,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -22877,7 +22877,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22877 const operand_ty = sema.typeOf(operand);22877 const operand_ty = sema.typeOf(operand);
2287822878
22879 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);22879 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, operand_ty, src, operand_src);
22880 const is_vector = dest_ty.zigTypeTag(zcu) == .Vector;22880 const is_vector = dest_ty.zigTypeTag(zcu) == .vector;
2288122881
22882 const dest_scalar_ty = dest_ty.scalarType(zcu);22882 const dest_scalar_ty = dest_ty.scalarType(zcu);
22883 const operand_scalar_ty = operand_ty.scalarType(zcu);22883 const operand_scalar_ty = operand_ty.scalarType(zcu);
...@@ -22888,7 +22888,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro...@@ -22888,7 +22888,7 @@ fn zirFloatFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro
22888 if (try sema.resolveValue(operand)) |operand_val| {22888 if (try sema.resolveValue(operand)) |operand_val| {
22889 const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, pt, .sema);22889 const result_val = try operand_val.floatFromIntAdvanced(sema.arena, operand_ty, dest_ty, pt, .sema);
22890 return Air.internedToRef(result_val.toIntern());22890 return Air.internedToRef(result_val.toIntern());
22891 } else if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeFloat) {22891 } else if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_float) {
22892 return sema.failWithNeededComptime(block, operand_src, .{22892 return sema.failWithNeededComptime(block, operand_src, .{
22893 .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known",22893 .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known",
22894 });22894 });
...@@ -22923,7 +22923,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -22923,7 +22923,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
22923 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt");22923 const dest_ty = try sema.resolveDestType(block, src, extra.lhs, .remove_eu, "@ptrFromInt");
22924 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, uncoerced_operand_ty, src, operand_src);22924 try sema.checkVectorizableBinaryOperands(block, operand_src, dest_ty, uncoerced_operand_ty, src, operand_src);
2292522925
22926 const is_vector = dest_ty.zigTypeTag(zcu) == .Vector;22926 const is_vector = dest_ty.zigTypeTag(zcu) == .vector;
22927 const operand_ty = if (is_vector) operand_ty: {22927 const operand_ty = if (is_vector) operand_ty: {
22928 const len = dest_ty.vectorLen(zcu);22928 const len = dest_ty.vectorLen(zcu);
22929 break :operand_ty try pt.vectorType(.{ .child = .usize_type, .len = len });22929 break :operand_ty try pt.vectorType(.{ .child = .usize_type, .len = len });
...@@ -22975,7 +22975,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -22975,7 +22975,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
22975 }22975 }
22976 try sema.requireRuntimeBlock(block, src, operand_src);22976 try sema.requireRuntimeBlock(block, src, operand_src);
22977 if (!is_vector) {22977 if (!is_vector) {
22978 if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .Fn)) {22978 if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .@"fn")) {
22979 if (!ptr_ty.isAllowzeroPtr(zcu)) {22979 if (!ptr_ty.isAllowzeroPtr(zcu)) {
22980 const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize);22980 const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize);
22981 try sema.addSafetyCheck(block, src, is_non_zero, .cast_to_null);22981 try sema.addSafetyCheck(block, src, is_non_zero, .cast_to_null);
...@@ -22992,7 +22992,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -22992,7 +22992,7 @@ fn zirPtrFromInt(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
22992 }22992 }
2299322993
22994 const len = dest_ty.vectorLen(zcu);22994 const len = dest_ty.vectorLen(zcu);
22995 if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .Fn)) {22995 if (block.wantSafety() and (try elem_ty.hasRuntimeBitsSema(pt) or elem_ty.zigTypeTag(zcu) == .@"fn")) {
22996 for (0..len) |i| {22996 for (0..len) |i| {
22997 const idx_ref = try pt.intRef(Type.usize, i);22997 const idx_ref = try pt.intRef(Type.usize, i);
22998 const elem_coerced = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref);22998 const elem_coerced = try block.addBinOp(.array_elem_val, operand_coerced, idx_ref);
...@@ -23042,11 +23042,11 @@ fn ptrFromIntVal(...@@ -23042,11 +23042,11 @@ fn ptrFromIntVal(
23042 return sema.fail(block, operand_src, "pointer type '{}' requires aligned address", .{ptr_ty.fmt(pt)});23042 return sema.fail(block, operand_src, "pointer type '{}' requires aligned address", .{ptr_ty.fmt(pt)});
2304323043
23044 return switch (ptr_ty.zigTypeTag(zcu)) {23044 return switch (ptr_ty.zigTypeTag(zcu)) {
23045 .Optional => Value.fromInterned(try pt.intern(.{ .opt = .{23045 .optional => Value.fromInterned(try pt.intern(.{ .opt = .{
23046 .ty = ptr_ty.toIntern(),23046 .ty = ptr_ty.toIntern(),
23047 .val = if (addr == 0) .none else (try pt.ptrIntValue(ptr_ty.childType(zcu), addr)).toIntern(),23047 .val = if (addr == 0) .none else (try pt.ptrIntValue(ptr_ty.childType(zcu), addr)).toIntern(),
23048 } })),23048 } })),
23049 .Pointer => try pt.ptrIntValue(ptr_ty, addr),23049 .pointer => try pt.ptrIntValue(ptr_ty, addr),
23050 else => unreachable,23050 else => unreachable,
23051 };23051 };
23052}23052}
...@@ -23064,16 +23064,16 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -23064,16 +23064,16 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
23064 const dest_tag = base_dest_ty.zigTypeTag(zcu);23064 const dest_tag = base_dest_ty.zigTypeTag(zcu);
23065 const operand_tag = base_operand_ty.zigTypeTag(zcu);23065 const operand_tag = base_operand_ty.zigTypeTag(zcu);
2306623066
23067 if (dest_tag != .ErrorSet and dest_tag != .ErrorUnion) {23067 if (dest_tag != .error_set and dest_tag != .error_union) {
23068 return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(dest_tag)});23068 return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(dest_tag)});
23069 }23069 }
23070 if (operand_tag != .ErrorSet and operand_tag != .ErrorUnion) {23070 if (operand_tag != .error_set and operand_tag != .error_union) {
23071 return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(operand_tag)});23071 return sema.fail(block, src, "expected error set or error union type, found '{s}'", .{@tagName(operand_tag)});
23072 }23072 }
23073 if (dest_tag == .ErrorSet and operand_tag == .ErrorUnion) {23073 if (dest_tag == .error_set and operand_tag == .error_union) {
23074 return sema.fail(block, src, "cannot cast an error union type to error set", .{});23074 return sema.fail(block, src, "cannot cast an error union type to error set", .{});
23075 }23075 }
23076 if (dest_tag == .ErrorUnion and operand_tag == .ErrorUnion and23076 if (dest_tag == .error_union and operand_tag == .error_union and
23077 base_dest_ty.errorUnionPayload(zcu).toIntern() != base_operand_ty.errorUnionPayload(zcu).toIntern())23077 base_dest_ty.errorUnionPayload(zcu).toIntern() != base_operand_ty.errorUnionPayload(zcu).toIntern())
23078 {23078 {
23079 return sema.failWithOwnedErrorMsg(block, msg: {23079 return sema.failWithOwnedErrorMsg(block, msg: {
...@@ -23088,8 +23088,8 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -23088,8 +23088,8 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
23088 break :msg msg;23088 break :msg msg;
23089 });23089 });
23090 }23090 }
23091 const dest_ty = if (dest_tag == .ErrorUnion) base_dest_ty.errorUnionSet(zcu) else base_dest_ty;23091 const dest_ty = if (dest_tag == .error_union) base_dest_ty.errorUnionSet(zcu) else base_dest_ty;
23092 const operand_ty = if (operand_tag == .ErrorUnion) base_operand_ty.errorUnionSet(zcu) else base_operand_ty;23092 const operand_ty = if (operand_tag == .error_union) base_operand_ty.errorUnionSet(zcu) else base_operand_ty;
2309323093
23094 // operand must be defined since it can be an invalid error value23094 // operand must be defined since it can be an invalid error value
23095 const maybe_operand_val = try sema.resolveDefinedValue(block, operand_src, operand);23095 const maybe_operand_val = try sema.resolveDefinedValue(block, operand_src, operand);
...@@ -23121,7 +23121,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -23121,7 +23121,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
2312123121
23122 break :disjoint true;23122 break :disjoint true;
23123 };23123 };
23124 if (disjoint and dest_tag != .ErrorUnion) {23124 if (disjoint and dest_tag != .error_union) {
23125 return sema.fail(block, src, "error sets '{}' and '{}' have no common errors", .{23125 return sema.fail(block, src, "error sets '{}' and '{}' have no common errors", .{
23126 operand_ty.fmt(pt), dest_ty.fmt(pt),23126 operand_ty.fmt(pt), dest_ty.fmt(pt),
23127 });23127 });
...@@ -23131,7 +23131,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -23131,7 +23131,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
23131 if (!dest_ty.isAnyError(zcu)) check: {23131 if (!dest_ty.isAnyError(zcu)) check: {
23132 const operand_val = zcu.intern_pool.indexToKey(val.toIntern());23132 const operand_val = zcu.intern_pool.indexToKey(val.toIntern());
23133 var error_name: InternPool.NullTerminatedString = undefined;23133 var error_name: InternPool.NullTerminatedString = undefined;
23134 if (operand_tag == .ErrorUnion) {23134 if (operand_tag == .error_union) {
23135 if (operand_val.error_union.val != .err_name) break :check;23135 if (operand_val.error_union.val != .err_name) break :check;
23136 error_name = operand_val.error_union.val.err_name;23136 error_name = operand_val.error_union.val.err_name;
23137 } else {23137 } else {
...@@ -23153,7 +23153,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -23153,7 +23153,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
23153 dest_ty.toIntern() != .adhoc_inferred_error_set_type and23153 dest_ty.toIntern() != .adhoc_inferred_error_set_type and
23154 zcu.backendSupportsFeature(.error_set_has_value))23154 zcu.backendSupportsFeature(.error_set_has_value))
23155 {23155 {
23156 if (dest_tag == .ErrorUnion) {23156 if (dest_tag == .error_union) {
23157 const err_code = try sema.analyzeErrUnionCode(block, operand_src, operand);23157 const err_code = try sema.analyzeErrUnionCode(block, operand_src, operand);
23158 const err_int = try block.addBitCast(err_int_ty, err_code);23158 const err_int = try block.addBitCast(err_int_ty, err_code);
23159 const zero_err = try pt.intRef(try pt.errorIntType(), 0);23159 const zero_err = try pt.intRef(try pt.errorIntType(), 0);
...@@ -23178,7 +23178,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData...@@ -23178,7 +23178,7 @@ fn zirErrorCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData
23178}23178}
2317923179
23180fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {23180fn zirPtrCastFull(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
23181 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;23181 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
23182 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));23182 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
23183 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;23183 const extra = sema.code.extraData(Zir.Inst.BinNode, extended.operand).data;
23184 const src = block.nodeOffset(extra.node);23184 const src = block.nodeOffset(extra.node);
...@@ -23239,10 +23239,10 @@ fn ptrCastFull(...@@ -23239,10 +23239,10 @@ fn ptrCastFull(
23239 try Type.fromInterned(dest_info.child).resolveLayout(pt);23239 try Type.fromInterned(dest_info.child).resolveLayout(pt);
2324023240
23241 const src_slice_like = src_info.flags.size == .Slice or23241 const src_slice_like = src_info.flags.size == .Slice or
23242 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .Array);23242 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array);
2324323243
23244 const dest_slice_like = dest_info.flags.size == .Slice or23244 const dest_slice_like = dest_info.flags.size == .Slice or
23245 (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .Array);23245 (dest_info.flags.size == .One and Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .array);
2324623246
23247 if (dest_info.flags.size == .Slice and !src_slice_like) {23247 if (dest_info.flags.size == .Slice and !src_slice_like) {
23248 return sema.fail(block, src, "illegal pointer cast to slice", .{});23248 return sema.fail(block, src, "illegal pointer cast to slice", .{});
...@@ -23277,7 +23277,7 @@ fn ptrCastFull(...@@ -23277,7 +23277,7 @@ fn ptrCastFull(
23277 errdefer msg.destroy(sema.gpa);23277 errdefer msg.destroy(sema.gpa);
23278 if (dest_info.flags.size == .Many and23278 if (dest_info.flags.size == .Many and
23279 (src_info.flags.size == .Slice or23279 (src_info.flags.size == .Slice or
23280 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .Array)))23280 (src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
23281 {23281 {
23282 try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});23282 try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
23283 } else {23283 } else {
...@@ -23473,7 +23473,7 @@ fn ptrCastFull(...@@ -23473,7 +23473,7 @@ fn ptrCastFull(
23473 }23473 }
2347423474
23475 const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: {23475 const ptr = if (src_info.flags.size == .Slice and dest_info.flags.size != .Slice) ptr: {
23476 if (operand_ty.zigTypeTag(zcu) == .Optional) {23476 if (operand_ty.zigTypeTag(zcu) == .optional) {
23477 break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty);23477 break :ptr try sema.analyzeOptionalSlicePtr(block, operand_src, operand, operand_ty);
23478 } else {23478 } else {
23479 break :ptr try sema.analyzeSlicePtr(block, operand_src, operand, operand_ty);23479 break :ptr try sema.analyzeSlicePtr(block, operand_src, operand, operand_ty);
...@@ -23485,7 +23485,7 @@ fn ptrCastFull(...@@ -23485,7 +23485,7 @@ fn ptrCastFull(
23485 var info = dest_info;23485 var info = dest_info;
23486 info.flags.size = .Many;23486 info.flags.size = .Many;
23487 const ty = try pt.ptrTypeSema(info);23487 const ty = try pt.ptrTypeSema(info);
23488 if (dest_ty.zigTypeTag(zcu) == .Optional) {23488 if (dest_ty.zigTypeTag(zcu) == .optional) {
23489 break :blk try pt.optionalType(ty.toIntern());23489 break :blk try pt.optionalType(ty.toIntern());
23490 } else {23490 } else {
23491 break :blk ty;23491 break :blk ty;
...@@ -23535,7 +23535,7 @@ fn ptrCastFull(...@@ -23535,7 +23535,7 @@ fn ptrCastFull(
23535 try sema.validateRuntimeValue(block, operand_src, ptr);23535 try sema.validateRuntimeValue(block, operand_src, ptr);
2353623536
23537 if (block.wantSafety() and operand_ty.ptrAllowsZero(zcu) and !dest_ty.ptrAllowsZero(zcu) and23537 if (block.wantSafety() and operand_ty.ptrAllowsZero(zcu) and !dest_ty.ptrAllowsZero(zcu) and
23538 (try Type.fromInterned(dest_info.child).hasRuntimeBitsSema(pt) or Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .Fn))23538 (try Type.fromInterned(dest_info.child).hasRuntimeBitsSema(pt) or Type.fromInterned(dest_info.child).zigTypeTag(zcu) == .@"fn"))
23539 {23539 {
23540 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);23540 const ptr_int = try block.addUnOp(.int_from_ptr, ptr);
23541 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);23541 const is_non_zero = try block.addBinOp(.cmp_neq, ptr_int, .zero_usize);
...@@ -23570,7 +23570,7 @@ fn ptrCastFull(...@@ -23570,7 +23570,7 @@ fn ptrCastFull(
23570 var intermediate_info = src_info;23570 var intermediate_info = src_info;
23571 intermediate_info.flags.address_space = dest_info.flags.address_space;23571 intermediate_info.flags.address_space = dest_info.flags.address_space;
23572 const intermediate_ptr_ty = try pt.ptrTypeSema(intermediate_info);23572 const intermediate_ptr_ty = try pt.ptrTypeSema(intermediate_info);
23573 const intermediate_ty = if (dest_ptr_ty.zigTypeTag(zcu) == .Optional) blk: {23573 const intermediate_ty = if (dest_ptr_ty.zigTypeTag(zcu) == .optional) blk: {
23574 break :blk try pt.optionalType(intermediate_ptr_ty.toIntern());23574 break :blk try pt.optionalType(intermediate_ptr_ty.toIntern());
23575 } else intermediate_ptr_ty;23575 } else intermediate_ptr_ty;
23576 const intermediate = try block.addInst(.{23576 const intermediate = try block.addInst(.{
...@@ -23613,7 +23613,7 @@ fn ptrCastFull(...@@ -23613,7 +23613,7 @@ fn ptrCastFull(
23613fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {23613fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref {
23614 const pt = sema.pt;23614 const pt = sema.pt;
23615 const zcu = pt.zcu;23615 const zcu = pt.zcu;
23616 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;23616 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
23617 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));23617 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
23618 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;23618 const extra = sema.code.extraData(Zir.Inst.UnNode, extended.operand).data;
23619 const src = block.nodeOffset(extra.node);23619 const src = block.nodeOffset(extra.node);
...@@ -23628,7 +23628,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst...@@ -23628,7 +23628,7 @@ fn zirPtrCastNoDest(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Inst
2362823628
23629 const dest_ty = blk: {23629 const dest_ty = blk: {
23630 const dest_ty = try pt.ptrTypeSema(ptr_info);23630 const dest_ty = try pt.ptrTypeSema(ptr_info);
23631 if (operand_ty.zigTypeTag(zcu) == .Optional) {23631 if (operand_ty.zigTypeTag(zcu) == .optional) {
23632 break :blk try pt.optionalType(dest_ty.toIntern());23632 break :blk try pt.optionalType(dest_ty.toIntern());
23633 }23633 }
23634 break :blk dest_ty;23634 break :blk dest_ty;
...@@ -23657,13 +23657,13 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -23657,13 +23657,13 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
23657 const operand_ty = sema.typeOf(operand);23657 const operand_ty = sema.typeOf(operand);
23658 const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);23658 const operand_scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src);
2365923659
23660 const operand_is_vector = operand_ty.zigTypeTag(zcu) == .Vector;23660 const operand_is_vector = operand_ty.zigTypeTag(zcu) == .vector;
23661 const dest_is_vector = dest_ty.zigTypeTag(zcu) == .Vector;23661 const dest_is_vector = dest_ty.zigTypeTag(zcu) == .vector;
23662 if (operand_is_vector != dest_is_vector) {23662 if (operand_is_vector != dest_is_vector) {
23663 return sema.fail(block, operand_src, "expected type '{}', found '{}'", .{ dest_ty.fmt(pt), operand_ty.fmt(pt) });23663 return sema.fail(block, operand_src, "expected type '{}', found '{}'", .{ dest_ty.fmt(pt), operand_ty.fmt(pt) });
23664 }23664 }
2366523665
23666 if (dest_scalar_ty.zigTypeTag(zcu) == .ComptimeInt) {23666 if (dest_scalar_ty.zigTypeTag(zcu) == .comptime_int) {
23667 return sema.coerce(block, dest_ty, operand, operand_src);23667 return sema.coerce(block, dest_ty, operand, operand_src);
23668 }23668 }
2366923669
...@@ -23673,7 +23673,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -23673,7 +23673,7 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
23673 return Air.internedToRef(val.toIntern());23673 return Air.internedToRef(val.toIntern());
23674 }23674 }
2367523675
23676 if (operand_scalar_ty.zigTypeTag(zcu) != .ComptimeInt) {23676 if (operand_scalar_ty.zigTypeTag(zcu) != .comptime_int) {
23677 const operand_info = operand_ty.intInfo(zcu);23677 const operand_info = operand_ty.intInfo(zcu);
23678 if (try sema.typeHasOnePossibleValue(operand_ty)) |val| {23678 if (try sema.typeHasOnePossibleValue(operand_ty)) |val| {
23679 return Air.internedToRef(val.toIntern());23679 return Air.internedToRef(val.toIntern());
...@@ -23751,7 +23751,7 @@ fn zirBitCount(...@@ -23751,7 +23751,7 @@ fn zirBitCount(
2375123751
23752 const result_scalar_ty = try pt.smallestUnsignedInt(bits);23752 const result_scalar_ty = try pt.smallestUnsignedInt(bits);
23753 switch (operand_ty.zigTypeTag(zcu)) {23753 switch (operand_ty.zigTypeTag(zcu)) {
23754 .Vector => {23754 .vector => {
23755 const vec_len = operand_ty.vectorLen(zcu);23755 const vec_len = operand_ty.vectorLen(zcu);
23756 const result_ty = try pt.vectorType(.{23756 const result_ty = try pt.vectorType(.{
23757 .len = vec_len,23757 .len = vec_len,
...@@ -23776,7 +23776,7 @@ fn zirBitCount(...@@ -23776,7 +23776,7 @@ fn zirBitCount(
23776 return block.addTyOp(air_tag, result_ty, operand);23776 return block.addTyOp(air_tag, result_ty, operand);
23777 }23777 }
23778 },23778 },
23779 .Int => {23779 .int => {
23780 if (try sema.resolveValueResolveLazy(operand)) |val| {23780 if (try sema.resolveValueResolveLazy(operand)) |val| {
23781 if (val.isUndef(zcu)) return pt.undefRef(result_scalar_ty);23781 if (val.isUndef(zcu)) return pt.undefRef(result_scalar_ty);
23782 return pt.intRef(result_scalar_ty, comptimeOp(val, operand_ty, zcu));23782 return pt.intRef(result_scalar_ty, comptimeOp(val, operand_ty, zcu));
...@@ -23813,7 +23813,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -23813,7 +23813,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
23813 }23813 }
2381423814
23815 switch (operand_ty.zigTypeTag(zcu)) {23815 switch (operand_ty.zigTypeTag(zcu)) {
23816 .Int => {23816 .int => {
23817 const runtime_src = if (try sema.resolveValue(operand)) |val| {23817 const runtime_src = if (try sema.resolveValue(operand)) |val| {
23818 if (val.isUndef(zcu)) return pt.undefRef(operand_ty);23818 if (val.isUndef(zcu)) return pt.undefRef(operand_ty);
23819 const result_val = try val.byteSwap(operand_ty, pt, sema.arena);23819 const result_val = try val.byteSwap(operand_ty, pt, sema.arena);
...@@ -23823,7 +23823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -23823,7 +23823,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
23823 try sema.requireRuntimeBlock(block, src, runtime_src);23823 try sema.requireRuntimeBlock(block, src, runtime_src);
23824 return block.addTyOp(.byte_swap, operand_ty, operand);23824 return block.addTyOp(.byte_swap, operand_ty, operand);
23825 },23825 },
23826 .Vector => {23826 .vector => {
23827 const runtime_src = if (try sema.resolveValue(operand)) |val| {23827 const runtime_src = if (try sema.resolveValue(operand)) |val| {
23828 if (val.isUndef(zcu))23828 if (val.isUndef(zcu))
23829 return pt.undefRef(operand_ty);23829 return pt.undefRef(operand_ty);
...@@ -23862,7 +23862,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -23862,7 +23862,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
23862 const pt = sema.pt;23862 const pt = sema.pt;
23863 const zcu = pt.zcu;23863 const zcu = pt.zcu;
23864 switch (operand_ty.zigTypeTag(zcu)) {23864 switch (operand_ty.zigTypeTag(zcu)) {
23865 .Int => {23865 .int => {
23866 const runtime_src = if (try sema.resolveValue(operand)) |val| {23866 const runtime_src = if (try sema.resolveValue(operand)) |val| {
23867 if (val.isUndef(zcu)) return pt.undefRef(operand_ty);23867 if (val.isUndef(zcu)) return pt.undefRef(operand_ty);
23868 const result_val = try val.bitReverse(operand_ty, pt, sema.arena);23868 const result_val = try val.bitReverse(operand_ty, pt, sema.arena);
...@@ -23872,7 +23872,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!...@@ -23872,7 +23872,7 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!
23872 try sema.requireRuntimeBlock(block, src, runtime_src);23872 try sema.requireRuntimeBlock(block, src, runtime_src);
23873 return block.addTyOp(.bit_reverse, operand_ty, operand);23873 return block.addTyOp(.bit_reverse, operand_ty, operand);
23874 },23874 },
23875 .Vector => {23875 .vector => {
23876 const runtime_src = if (try sema.resolveValue(operand)) |val| {23876 const runtime_src = if (try sema.resolveValue(operand)) |val| {
23877 if (val.isUndef(zcu))23877 if (val.isUndef(zcu))
23878 return pt.undefRef(operand_ty);23878 return pt.undefRef(operand_ty);
...@@ -23924,7 +23924,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6...@@ -23924,7 +23924,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6
23924 const ip = &zcu.intern_pool;23924 const ip = &zcu.intern_pool;
23925 try ty.resolveLayout(pt);23925 try ty.resolveLayout(pt);
23926 switch (ty.zigTypeTag(zcu)) {23926 switch (ty.zigTypeTag(zcu)) {
23927 .Struct => {},23927 .@"struct" => {},
23928 else => return sema.fail(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(pt)}),23928 else => return sema.fail(block, lhs_src, "expected struct type, found '{}'", .{ty.fmt(pt)}),
23929 }23929 }
2393023930
...@@ -23959,7 +23959,7 @@ fn checkNamespaceType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) Com...@@ -23959,7 +23959,7 @@ fn checkNamespaceType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) Com
23959 const pt = sema.pt;23959 const pt = sema.pt;
23960 const zcu = pt.zcu;23960 const zcu = pt.zcu;
23961 switch (ty.zigTypeTag(zcu)) {23961 switch (ty.zigTypeTag(zcu)) {
23962 .Struct, .Enum, .Union, .Opaque => return,23962 .@"struct", .@"enum", .@"union", .@"opaque" => return,
23963 else => return sema.fail(block, src, "expected struct, enum, union, or opaque; found '{}'", .{ty.fmt(pt)}),23963 else => return sema.fail(block, src, "expected struct, enum, union, or opaque; found '{}'", .{ty.fmt(pt)}),
23964 }23964 }
23965}23965}
...@@ -23969,8 +23969,8 @@ fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileEr...@@ -23969,8 +23969,8 @@ fn checkIntType(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileEr
23969 const pt = sema.pt;23969 const pt = sema.pt;
23970 const zcu = pt.zcu;23970 const zcu = pt.zcu;
23971 switch (try ty.zigTypeTagOrPoison(zcu)) {23971 switch (try ty.zigTypeTagOrPoison(zcu)) {
23972 .ComptimeInt => return true,23972 .comptime_int => return true,
23973 .Int => return false,23973 .int => return false,
23974 else => return sema.fail(block, src, "expected integer type, found '{}'", .{ty.fmt(pt)}),23974 else => return sema.fail(block, src, "expected integer type, found '{}'", .{ty.fmt(pt)}),
23975 }23975 }
23976}23976}
...@@ -23984,7 +23984,7 @@ fn checkInvalidPtrIntArithmetic(...@@ -23984,7 +23984,7 @@ fn checkInvalidPtrIntArithmetic(
23984 const pt = sema.pt;23984 const pt = sema.pt;
23985 const zcu = pt.zcu;23985 const zcu = pt.zcu;
23986 switch (try ty.zigTypeTagOrPoison(zcu)) {23986 switch (try ty.zigTypeTagOrPoison(zcu)) {
23987 .Pointer => switch (ty.ptrSize(zcu)) {23987 .pointer => switch (ty.ptrSize(zcu)) {
23988 .One, .Slice => return,23988 .One, .Slice => return,
23989 .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),23989 .Many, .C => return sema.failWithInvalidPtrArithmetic(block, src, "pointer-integer", "addition and subtraction"),
23990 },23990 },
...@@ -24001,8 +24001,8 @@ fn checkArithmeticOp(...@@ -24001,8 +24001,8 @@ fn checkArithmeticOp(
24001 rhs_zig_ty_tag: std.builtin.TypeId,24001 rhs_zig_ty_tag: std.builtin.TypeId,
24002 zir_tag: Zir.Inst.Tag,24002 zir_tag: Zir.Inst.Tag,
24003) CompileError!void {24003) CompileError!void {
24004 const is_int = scalar_tag == .Int or scalar_tag == .ComptimeInt;24004 const is_int = scalar_tag == .int or scalar_tag == .comptime_int;
24005 const is_float = scalar_tag == .Float or scalar_tag == .ComptimeFloat;24005 const is_float = scalar_tag == .float or scalar_tag == .comptime_float;
2400624006
24007 if (!is_int and !(is_float and floatOpAllowed(zir_tag))) {24007 if (!is_int and !(is_float and floatOpAllowed(zir_tag))) {
24008 return sema.fail(block, src, "invalid operands to binary expression: '{s}' and '{s}'", .{24008 return sema.fail(block, src, "invalid operands to binary expression: '{s}' and '{s}'", .{
...@@ -24020,8 +24020,8 @@ fn checkPtrOperand(...@@ -24020,8 +24020,8 @@ fn checkPtrOperand(
24020 const pt = sema.pt;24020 const pt = sema.pt;
24021 const zcu = pt.zcu;24021 const zcu = pt.zcu;
24022 switch (ty.zigTypeTag(zcu)) {24022 switch (ty.zigTypeTag(zcu)) {
24023 .Pointer => return,24023 .pointer => return,
24024 .Fn => {24024 .@"fn" => {
24025 const msg = msg: {24025 const msg = msg: {
24026 const msg = try sema.errMsg(24026 const msg = try sema.errMsg(
24027 ty_src,24027 ty_src,
...@@ -24036,7 +24036,7 @@ fn checkPtrOperand(...@@ -24036,7 +24036,7 @@ fn checkPtrOperand(
24036 };24036 };
24037 return sema.failWithOwnedErrorMsg(block, msg);24037 return sema.failWithOwnedErrorMsg(block, msg);
24038 },24038 },
24039 .Optional => if (ty.childType(zcu).zigTypeTag(zcu) == .Pointer) return,24039 .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return,
24040 else => {},24040 else => {},
24041 }24041 }
24042 return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty.fmt(pt)});24042 return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty.fmt(pt)});
...@@ -24052,8 +24052,8 @@ fn checkPtrType(...@@ -24052,8 +24052,8 @@ fn checkPtrType(
24052 const pt = sema.pt;24052 const pt = sema.pt;
24053 const zcu = pt.zcu;24053 const zcu = pt.zcu;
24054 switch (ty.zigTypeTag(zcu)) {24054 switch (ty.zigTypeTag(zcu)) {
24055 .Pointer => if (allow_slice or !ty.isSlice(zcu)) return,24055 .pointer => if (allow_slice or !ty.isSlice(zcu)) return,
24056 .Fn => {24056 .@"fn" => {
24057 const msg = msg: {24057 const msg = msg: {
24058 const msg = try sema.errMsg(24058 const msg = try sema.errMsg(
24059 ty_src,24059 ty_src,
...@@ -24068,7 +24068,7 @@ fn checkPtrType(...@@ -24068,7 +24068,7 @@ fn checkPtrType(
24068 };24068 };
24069 return sema.failWithOwnedErrorMsg(block, msg);24069 return sema.failWithOwnedErrorMsg(block, msg);
24070 },24070 },
24071 .Optional => if (ty.childType(zcu).zigTypeTag(zcu) == .Pointer) return,24071 .optional => if (ty.childType(zcu).zigTypeTag(zcu) == .pointer) return,
24072 else => {},24072 else => {},
24073 }24073 }
24074 return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty.fmt(pt)});24074 return sema.fail(block, ty_src, "expected pointer type, found '{}'", .{ty.fmt(pt)});
...@@ -24083,8 +24083,8 @@ fn checkVectorElemType(...@@ -24083,8 +24083,8 @@ fn checkVectorElemType(
24083 const pt = sema.pt;24083 const pt = sema.pt;
24084 const zcu = pt.zcu;24084 const zcu = pt.zcu;
24085 switch (ty.zigTypeTag(zcu)) {24085 switch (ty.zigTypeTag(zcu)) {
24086 .Int, .Float, .Bool => return,24086 .int, .float, .bool => return,
24087 .Optional, .Pointer => if (ty.isPtrAtRuntime(zcu)) return,24087 .optional, .pointer => if (ty.isPtrAtRuntime(zcu)) return,
24088 else => {},24088 else => {},
24089 }24089 }
24090 return sema.fail(block, ty_src, "expected integer, float, bool, or pointer for the vector element type; found '{}'", .{ty.fmt(pt)});24090 return sema.fail(block, ty_src, "expected integer, float, bool, or pointer for the vector element type; found '{}'", .{ty.fmt(pt)});
...@@ -24099,7 +24099,7 @@ fn checkFloatType(...@@ -24099,7 +24099,7 @@ fn checkFloatType(
24099 const pt = sema.pt;24099 const pt = sema.pt;
24100 const zcu = pt.zcu;24100 const zcu = pt.zcu;
24101 switch (ty.zigTypeTag(zcu)) {24101 switch (ty.zigTypeTag(zcu)) {
24102 .ComptimeInt, .ComptimeFloat, .Float => {},24102 .comptime_int, .comptime_float, .float => {},
24103 else => return sema.fail(block, ty_src, "expected float type, found '{}'", .{ty.fmt(pt)}),24103 else => return sema.fail(block, ty_src, "expected float type, found '{}'", .{ty.fmt(pt)}),
24104 }24104 }
24105}24105}
...@@ -24113,9 +24113,9 @@ fn checkNumericType(...@@ -24113,9 +24113,9 @@ fn checkNumericType(
24113 const pt = sema.pt;24113 const pt = sema.pt;
24114 const zcu = pt.zcu;24114 const zcu = pt.zcu;
24115 switch (ty.zigTypeTag(zcu)) {24115 switch (ty.zigTypeTag(zcu)) {
24116 .ComptimeFloat, .Float, .ComptimeInt, .Int => {},24116 .comptime_float, .float, .comptime_int, .int => {},
24117 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {24117 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
24118 .ComptimeFloat, .Float, .ComptimeInt, .Int => {},24118 .comptime_float, .float, .comptime_int, .int => {},
24119 else => |t| return sema.fail(block, ty_src, "expected number, found '{}'", .{t}),24119 else => |t| return sema.fail(block, ty_src, "expected number, found '{}'", .{t}),
24120 },24120 },
24121 else => return sema.fail(block, ty_src, "expected number, found '{}'", .{ty.fmt(pt)}),24121 else => return sema.fail(block, ty_src, "expected number, found '{}'", .{ty.fmt(pt)}),
...@@ -24167,7 +24167,7 @@ fn checkAtomicPtrOperand(...@@ -24167,7 +24167,7 @@ fn checkAtomicPtrOperand(
2416724167
24168 const ptr_ty = sema.typeOf(ptr);24168 const ptr_ty = sema.typeOf(ptr);
24169 const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(zcu)) {24169 const ptr_data = switch (try ptr_ty.zigTypeTagOrPoison(zcu)) {
24170 .Pointer => ptr_ty.ptrInfo(zcu),24170 .pointer => ptr_ty.ptrInfo(zcu),
24171 else => {24171 else => {
24172 const wanted_ptr_ty = try pt.ptrTypeSema(wanted_ptr_data);24172 const wanted_ptr_ty = try pt.ptrTypeSema(wanted_ptr_data);
24173 _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src);24173 _ = try sema.coerce(block, wanted_ptr_ty, ptr, ptr_src);
...@@ -24208,11 +24208,11 @@ fn checkIntOrVector(...@@ -24208,11 +24208,11 @@ fn checkIntOrVector(
24208 const zcu = pt.zcu;24208 const zcu = pt.zcu;
24209 const operand_ty = sema.typeOf(operand);24209 const operand_ty = sema.typeOf(operand);
24210 switch (try operand_ty.zigTypeTagOrPoison(zcu)) {24210 switch (try operand_ty.zigTypeTagOrPoison(zcu)) {
24211 .Int => return operand_ty,24211 .int => return operand_ty,
24212 .Vector => {24212 .vector => {
24213 const elem_ty = operand_ty.childType(zcu);24213 const elem_ty = operand_ty.childType(zcu);
24214 switch (try elem_ty.zigTypeTagOrPoison(zcu)) {24214 switch (try elem_ty.zigTypeTagOrPoison(zcu)) {
24215 .Int => return elem_ty,24215 .int => return elem_ty,
24216 else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{}'", .{24216 else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{}'", .{
24217 elem_ty.fmt(pt),24217 elem_ty.fmt(pt),
24218 }),24218 }),
...@@ -24233,11 +24233,11 @@ fn checkIntOrVectorAllowComptime(...@@ -24233,11 +24233,11 @@ fn checkIntOrVectorAllowComptime(
24233 const pt = sema.pt;24233 const pt = sema.pt;
24234 const zcu = pt.zcu;24234 const zcu = pt.zcu;
24235 switch (try operand_ty.zigTypeTagOrPoison(zcu)) {24235 switch (try operand_ty.zigTypeTagOrPoison(zcu)) {
24236 .Int, .ComptimeInt => return operand_ty,24236 .int, .comptime_int => return operand_ty,
24237 .Vector => {24237 .vector => {
24238 const elem_ty = operand_ty.childType(zcu);24238 const elem_ty = operand_ty.childType(zcu);
24239 switch (try elem_ty.zigTypeTagOrPoison(zcu)) {24239 switch (try elem_ty.zigTypeTagOrPoison(zcu)) {
24240 .Int, .ComptimeInt => return elem_ty,24240 .int, .comptime_int => return elem_ty,
24241 else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{}'", .{24241 else => return sema.fail(block, operand_src, "expected vector of integers; found vector of '{}'", .{
24242 elem_ty.fmt(pt),24242 elem_ty.fmt(pt),
24243 }),24243 }),
...@@ -24277,7 +24277,7 @@ fn checkSimdBinOp(...@@ -24277,7 +24277,7 @@ fn checkSimdBinOp(
24277 const rhs_ty = sema.typeOf(uncasted_rhs);24277 const rhs_ty = sema.typeOf(uncasted_rhs);
2427824278
24279 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);24279 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
24280 const vec_len: ?usize = if (lhs_ty.zigTypeTag(zcu) == .Vector) lhs_ty.vectorLen(zcu) else null;24280 const vec_len: ?usize = if (lhs_ty.zigTypeTag(zcu) == .vector) lhs_ty.vectorLen(zcu) else null;
24281 const result_ty = try sema.resolvePeerTypes(block, src, &.{ uncasted_lhs, uncasted_rhs }, .{24281 const result_ty = try sema.resolvePeerTypes(block, src, &.{ uncasted_lhs, uncasted_rhs }, .{
24282 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },24282 .override = &[_]?LazySrcLoc{ lhs_src, rhs_src },
24283 });24283 });
...@@ -24308,14 +24308,14 @@ fn checkVectorizableBinaryOperands(...@@ -24308,14 +24308,14 @@ fn checkVectorizableBinaryOperands(
24308 const zcu = pt.zcu;24308 const zcu = pt.zcu;
24309 const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(zcu);24309 const lhs_zig_ty_tag = try lhs_ty.zigTypeTagOrPoison(zcu);
24310 const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(zcu);24310 const rhs_zig_ty_tag = try rhs_ty.zigTypeTagOrPoison(zcu);
24311 if (lhs_zig_ty_tag != .Vector and rhs_zig_ty_tag != .Vector) return;24311 if (lhs_zig_ty_tag != .vector and rhs_zig_ty_tag != .vector) return;
2431224312
24313 const lhs_is_vector = switch (lhs_zig_ty_tag) {24313 const lhs_is_vector = switch (lhs_zig_ty_tag) {
24314 .Vector, .Array => true,24314 .vector, .array => true,
24315 else => false,24315 else => false,
24316 };24316 };
24317 const rhs_is_vector = switch (rhs_zig_ty_tag) {24317 const rhs_is_vector = switch (rhs_zig_ty_tag) {
24318 .Vector, .Array => true,24318 .vector, .array => true,
24319 else => false,24319 else => false,
24320 };24320 };
2432124321
...@@ -24477,7 +24477,7 @@ fn zirCmpxchg(...@@ -24477,7 +24477,7 @@ fn zirCmpxchg(
24477 // zig fmt: on24477 // zig fmt: on
24478 const expected_value = try sema.resolveInst(extra.expected_value);24478 const expected_value = try sema.resolveInst(extra.expected_value);
24479 const elem_ty = sema.typeOf(expected_value);24479 const elem_ty = sema.typeOf(expected_value);
24480 if (elem_ty.zigTypeTag(zcu) == .Float) {24480 if (elem_ty.zigTypeTag(zcu) == .float) {
24481 return sema.fail(24481 return sema.fail(
24482 block,24482 block,
24483 elem_ty_src,24483 elem_ty_src,
...@@ -24602,7 +24602,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -24602,7 +24602,7 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
24602 const pt = sema.pt;24602 const pt = sema.pt;
24603 const zcu = pt.zcu;24603 const zcu = pt.zcu;
2460424604
24605 if (operand_ty.zigTypeTag(zcu) != .Vector) {24605 if (operand_ty.zigTypeTag(zcu) != .vector) {
24606 return sema.fail(block, operand_src, "expected vector, found '{}'", .{operand_ty.fmt(pt)});24606 return sema.fail(block, operand_src, "expected vector, found '{}'", .{operand_ty.fmt(pt)});
24607 }24607 }
2460824608
...@@ -24611,13 +24611,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -24611,13 +24611,13 @@ fn zirReduce(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
24611 // Type-check depending on operation.24611 // Type-check depending on operation.
24612 switch (operation) {24612 switch (operation) {
24613 .And, .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) {24613 .And, .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) {
24614 .Int, .Bool => {},24614 .int, .bool => {},
24615 else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{}'", .{24615 else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or boolean operand; found '{}'", .{
24616 @tagName(operation), operand_ty.fmt(pt),24616 @tagName(operation), operand_ty.fmt(pt),
24617 }),24617 }),
24618 },24618 },
24619 .Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) {24619 .Min, .Max, .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) {
24620 .Int, .Float => {},24620 .int, .float => {},
24621 else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{}'", .{24621 else => return sema.fail(block, operand_src, "@reduce operation '{s}' requires integer or float operand; found '{}'", .{
24622 @tagName(operation), operand_ty.fmt(pt),24622 @tagName(operation), operand_ty.fmt(pt),
24623 }),24623 }),
...@@ -24677,7 +24677,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air...@@ -24677,7 +24677,7 @@ fn zirShuffle(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
24677 var mask_ty = sema.typeOf(mask);24677 var mask_ty = sema.typeOf(mask);
2467824678
24679 const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) {24679 const mask_len = switch (sema.typeOf(mask).zigTypeTag(zcu)) {
24680 .Array, .Vector => sema.typeOf(mask).arrayLen(zcu),24680 .array, .vector => sema.typeOf(mask).arrayLen(zcu),
24681 else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(pt)}),24681 else => return sema.fail(block, mask_src, "expected vector or array, found '{}'", .{sema.typeOf(mask).fmt(pt)}),
24682 };24682 };
24683 mask_ty = try pt.vectorType(.{24683 mask_ty = try pt.vectorType(.{
...@@ -24715,16 +24715,16 @@ fn analyzeShuffle(...@@ -24715,16 +24715,16 @@ fn analyzeShuffle(
24715 });24715 });
2471624716
24717 const maybe_a_len = switch (sema.typeOf(a).zigTypeTag(zcu)) {24717 const maybe_a_len = switch (sema.typeOf(a).zigTypeTag(zcu)) {
24718 .Array, .Vector => sema.typeOf(a).arrayLen(zcu),24718 .array, .vector => sema.typeOf(a).arrayLen(zcu),
24719 .Undefined => null,24719 .undefined => null,
24720 else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{24720 else => return sema.fail(block, a_src, "expected vector or array with element type '{}', found '{}'", .{
24721 elem_ty.fmt(pt),24721 elem_ty.fmt(pt),
24722 sema.typeOf(a).fmt(pt),24722 sema.typeOf(a).fmt(pt),
24723 }),24723 }),
24724 };24724 };
24725 const maybe_b_len = switch (sema.typeOf(b).zigTypeTag(zcu)) {24725 const maybe_b_len = switch (sema.typeOf(b).zigTypeTag(zcu)) {
24726 .Array, .Vector => sema.typeOf(b).arrayLen(zcu),24726 .array, .vector => sema.typeOf(b).arrayLen(zcu),
24727 .Undefined => null,24727 .undefined => null,
24728 else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{24728 else => return sema.fail(block, b_src, "expected vector or array with element type '{}', found '{}'", .{
24729 elem_ty.fmt(pt),24729 elem_ty.fmt(pt),
24730 sema.typeOf(b).fmt(pt),24730 sema.typeOf(b).fmt(pt),
...@@ -24869,7 +24869,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C...@@ -24869,7 +24869,7 @@ fn zirSelect(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) C
24869 const pred_ty = sema.typeOf(pred_uncoerced);24869 const pred_ty = sema.typeOf(pred_uncoerced);
2487024870
24871 const vec_len_u64 = switch (try pred_ty.zigTypeTagOrPoison(zcu)) {24871 const vec_len_u64 = switch (try pred_ty.zigTypeTagOrPoison(zcu)) {
24872 .Vector, .Array => pred_ty.arrayLen(zcu),24872 .vector, .array => pred_ty.arrayLen(zcu),
24873 else => return sema.fail(block, pred_src, "expected vector or array, found '{}'", .{pred_ty.fmt(pt)}),24873 else => return sema.fail(block, pred_src, "expected vector or array, found '{}'", .{pred_ty.fmt(pt)}),
24874 };24874 };
24875 const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64));24875 const vec_len: u32 = @intCast(try sema.usizeCast(block, pred_src, vec_len_u64));
...@@ -25011,13 +25011,13 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -25011,13 +25011,13 @@ fn zirAtomicRmw(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
25011 const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation);25011 const op = try sema.resolveAtomicRmwOp(block, op_src, extra.operation);
2501225012
25013 switch (elem_ty.zigTypeTag(zcu)) {25013 switch (elem_ty.zigTypeTag(zcu)) {
25014 .Enum => if (op != .Xchg) {25014 .@"enum" => if (op != .Xchg) {
25015 return sema.fail(block, op_src, "@atomicRmw with enum only allowed with .Xchg", .{});25015 return sema.fail(block, op_src, "@atomicRmw with enum only allowed with .Xchg", .{});
25016 },25016 },
25017 .Bool => if (op != .Xchg) {25017 .bool => if (op != .Xchg) {
25018 return sema.fail(block, op_src, "@atomicRmw with bool only allowed with .Xchg", .{});25018 return sema.fail(block, op_src, "@atomicRmw with bool only allowed with .Xchg", .{});
25019 },25019 },
25020 .Float => switch (op) {25020 .float => switch (op) {
25021 .Xchg, .Add, .Sub, .Max, .Min => {},25021 .Xchg, .Add, .Sub, .Max, .Min => {},
25022 else => return sema.fail(block, op_src, "@atomicRmw with float only allowed with .Xchg, .Add, .Sub, .Max, and .Min", .{}),25022 else => return sema.fail(block, op_src, "@atomicRmw with float only allowed with .Xchg, .Add, .Sub, .Max, and .Min", .{}),
25023 },25023 },
...@@ -25135,7 +25135,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air....@@ -25135,7 +25135,7 @@ fn zirMulAdd(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.
25135 const zcu = pt.zcu;25135 const zcu = pt.zcu;
2513625136
25137 switch (ty.scalarType(zcu).zigTypeTag(zcu)) {25137 switch (ty.scalarType(zcu).zigTypeTag(zcu)) {
25138 .ComptimeFloat, .Float => {},25138 .comptime_float, .float => {},
25139 else => return sema.fail(block, src, "expected vector of floats or float type, found '{}'", .{ty.fmt(pt)}),25139 else => return sema.fail(block, src, "expected vector of floats or float type, found '{}'", .{ty.fmt(pt)}),
25140 }25140 }
2514125141
...@@ -25281,7 +25281,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25281,7 +25281,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25281 const ip = &zcu.intern_pool;25281 const ip = &zcu.intern_pool;
2528225282
25283 const extra = sema.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data;25283 const extra = sema.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data;
25284 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;25284 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
25285 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));25285 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
25286 assert(!flags.ptr_cast);25286 assert(!flags.ptr_cast);
25287 const inst_src = block.nodeOffset(extra.src_node);25287 const inst_src = block.nodeOffset(extra.src_node);
...@@ -25296,7 +25296,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25296,7 +25296,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25296 }25296 }
25297 const parent_ty = Type.fromInterned(parent_ptr_info.child);25297 const parent_ty = Type.fromInterned(parent_ptr_info.child);
25298 switch (parent_ty.zigTypeTag(zcu)) {25298 switch (parent_ty.zigTypeTag(zcu)) {
25299 .Struct, .Union => {},25299 .@"struct", .@"union" => {},
25300 else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(pt)}),25300 else => return sema.fail(block, inst_src, "expected pointer to struct or union type, found '{}'", .{parent_ptr_ty.fmt(pt)}),
25301 }25301 }
25302 try parent_ty.resolveLayout(pt);25302 try parent_ty.resolveLayout(pt);
...@@ -25305,7 +25305,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25305,7 +25305,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25305 .needed_comptime_reason = "field name must be comptime-known",25305 .needed_comptime_reason = "field name must be comptime-known",
25306 });25306 });
25307 const field_index = switch (parent_ty.zigTypeTag(zcu)) {25307 const field_index = switch (parent_ty.zigTypeTag(zcu)) {
25308 .Struct => blk: {25308 .@"struct" => blk: {
25309 if (parent_ty.isTuple(zcu)) {25309 if (parent_ty.isTuple(zcu)) {
25310 if (field_name.eqlSlice("len", ip)) {25310 if (field_name.eqlSlice("len", ip)) {
25311 return sema.fail(block, inst_src, "cannot get @fieldParentPtr of 'len' field of tuple", .{});25311 return sema.fail(block, inst_src, "cannot get @fieldParentPtr of 'len' field of tuple", .{});
...@@ -25315,10 +25315,10 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25315,10 +25315,10 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25315 break :blk try sema.structFieldIndex(block, parent_ty, field_name, field_name_src);25315 break :blk try sema.structFieldIndex(block, parent_ty, field_name, field_name_src);
25316 }25316 }
25317 },25317 },
25318 .Union => try sema.unionFieldIndex(block, parent_ty, field_name, field_name_src),25318 .@"union" => try sema.unionFieldIndex(block, parent_ty, field_name, field_name_src),
25319 else => unreachable,25319 else => unreachable,
25320 };25320 };
25321 if (parent_ty.zigTypeTag(zcu) == .Struct and parent_ty.structFieldIsComptime(field_index, zcu)) {25321 if (parent_ty.zigTypeTag(zcu) == .@"struct" and parent_ty.structFieldIsComptime(field_index, zcu)) {
25322 return sema.fail(block, field_name_src, "cannot get @fieldParentPtr of a comptime field", .{});25322 return sema.fail(block, field_name_src, "cannot get @fieldParentPtr of a comptime field", .{});
25323 }25323 }
2532425324
...@@ -25400,7 +25400,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25400,7 +25400,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
2540025400
25401 const result = if (try sema.resolveDefinedValue(block, field_ptr_src, casted_field_ptr)) |field_ptr_val| result: {25401 const result = if (try sema.resolveDefinedValue(block, field_ptr_src, casted_field_ptr)) |field_ptr_val| result: {
25402 switch (parent_ty.zigTypeTag(zcu)) {25402 switch (parent_ty.zigTypeTag(zcu)) {
25403 .Struct => switch (parent_ty.containerLayout(zcu)) {25403 .@"struct" => switch (parent_ty.containerLayout(zcu)) {
25404 .auto => {},25404 .auto => {},
25405 .@"extern" => {25405 .@"extern" => {
25406 const byte_offset = parent_ty.structFieldOffset(field_index, zcu);25406 const byte_offset = parent_ty.structFieldOffset(field_index, zcu);
...@@ -25417,7 +25417,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins...@@ -25417,7 +25417,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.Ins
25417 break :result Air.internedToRef(parent_ptr_val.toIntern());25417 break :result Air.internedToRef(parent_ptr_val.toIntern());
25418 },25418 },
25419 },25419 },
25420 .Union => switch (parent_ty.containerLayout(zcu)) {25420 .@"union" => switch (parent_ty.containerLayout(zcu)) {
25421 .auto => {},25421 .auto => {},
25422 .@"extern", .@"packed" => {25422 .@"extern", .@"packed" => {
25423 // For an extern or packed union, just coerce the pointer.25423 // For an extern or packed union, just coerce the pointer.
...@@ -25914,7 +25914,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -25914,7 +25914,7 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
25914 // lowering. The AIR instruction requires pointers with element types of25914 // lowering. The AIR instruction requires pointers with element types of
25915 // equal ABI size.25915 // equal ABI size.
2591625916
25917 if (dest_ty.zigTypeTag(zcu) != .Pointer or src_ty.zigTypeTag(zcu) != .Pointer) {25917 if (dest_ty.zigTypeTag(zcu) != .pointer or src_ty.zigTypeTag(zcu) != .pointer) {
25918 return sema.fail(block, src, "TODO: lower @memcpy to a for loop because the source or destination iterable is a tuple", .{});25918 return sema.fail(block, src, "TODO: lower @memcpy to a for loop because the source or destination iterable is a tuple", .{});
25919 }25919 }
2592025920
...@@ -26034,7 +26034,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void...@@ -26034,7 +26034,7 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void
26034 switch (ptr_info.flags.size) {26034 switch (ptr_info.flags.size) {
26035 .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),26035 .Slice => break :dest_elem_ty Type.fromInterned(ptr_info.child),
26036 .One => {26036 .One => {
26037 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .Array) {26037 if (Type.fromInterned(ptr_info.child).zigTypeTag(zcu) == .array) {
26038 break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu);26038 break :dest_elem_ty Type.fromInterned(ptr_info.child).childType(zcu);
26039 }26039 }
26040 },26040 },
...@@ -26533,7 +26533,7 @@ fn zirCDefine(...@@ -26533,7 +26533,7 @@ fn zirCDefine(
26533 .needed_comptime_reason = "name of macro being undefined must be comptime-known",26533 .needed_comptime_reason = "name of macro being undefined must be comptime-known",
26534 });26534 });
26535 const rhs = try sema.resolveInst(extra.rhs);26535 const rhs = try sema.resolveInst(extra.rhs);
26536 if (sema.typeOf(rhs).zigTypeTag(zcu) != .Void) {26536 if (sema.typeOf(rhs).zigTypeTag(zcu) != .void) {
26537 const value = try sema.resolveConstString(block, val_src, extra.rhs, .{26537 const value = try sema.resolveConstString(block, val_src, extra.rhs, .{
26538 .needed_comptime_reason = "value of macro being undefined must be comptime-known",26538 .needed_comptime_reason = "value of macro being undefined must be comptime-known",
26539 });26539 });
...@@ -26951,7 +26951,7 @@ fn validateVarType(...@@ -26951,7 +26951,7 @@ fn validateVarType(
26951 return sema.failWithOwnedErrorMsg(block, msg);26951 return sema.failWithOwnedErrorMsg(block, msg);
26952 }26952 }
26953 } else {26953 } else {
26954 if (var_ty.zigTypeTag(zcu) == .Opaque) {26954 if (var_ty.zigTypeTag(zcu) == .@"opaque") {
26955 return sema.fail(26955 return sema.fail(
26956 block,26956 block,
26957 src,26957 src,
...@@ -26968,7 +26968,7 @@ fn validateVarType(...@@ -26968,7 +26968,7 @@ fn validateVarType(
26968 errdefer msg.destroy(sema.gpa);26968 errdefer msg.destroy(sema.gpa);
2696926969
26970 try sema.explainWhyTypeIsComptime(msg, src, var_ty);26970 try sema.explainWhyTypeIsComptime(msg, src, var_ty);
26971 if (var_ty.zigTypeTag(zcu) == .ComptimeInt or var_ty.zigTypeTag(zcu) == .ComptimeFloat) {26971 if (var_ty.zigTypeTag(zcu) == .comptime_int or var_ty.zigTypeTag(zcu) == .comptime_float) {
26972 try sema.errNote(src, msg, "to modify this variable at runtime, it must be given an explicit fixed-size number type", .{});26972 try sema.errNote(src, msg, "to modify this variable at runtime, it must be given an explicit fixed-size number type", .{});
26973 }26973 }
2697426974
...@@ -27003,42 +27003,42 @@ fn explainWhyTypeIsComptimeInner(...@@ -27003,42 +27003,42 @@ fn explainWhyTypeIsComptimeInner(
27003 const zcu = pt.zcu;27003 const zcu = pt.zcu;
27004 const ip = &zcu.intern_pool;27004 const ip = &zcu.intern_pool;
27005 switch (ty.zigTypeTag(zcu)) {27005 switch (ty.zigTypeTag(zcu)) {
27006 .Bool,27006 .bool,
27007 .Int,27007 .int,
27008 .Float,27008 .float,
27009 .ErrorSet,27009 .error_set,
27010 .Enum,27010 .@"enum",
27011 .Frame,27011 .frame,
27012 .AnyFrame,27012 .@"anyframe",
27013 .Void,27013 .void,
27014 => return,27014 => return,
2701527015
27016 .Fn => {27016 .@"fn" => {
27017 try sema.errNote(src_loc, msg, "use '*const {}' for a function pointer type", .{ty.fmt(pt)});27017 try sema.errNote(src_loc, msg, "use '*const {}' for a function pointer type", .{ty.fmt(pt)});
27018 },27018 },
2701927019
27020 .Type => {27020 .type => {
27021 try sema.errNote(src_loc, msg, "types are not available at runtime", .{});27021 try sema.errNote(src_loc, msg, "types are not available at runtime", .{});
27022 },27022 },
2702327023
27024 .ComptimeFloat,27024 .comptime_float,
27025 .ComptimeInt,27025 .comptime_int,
27026 .EnumLiteral,27026 .enum_literal,
27027 .NoReturn,27027 .noreturn,
27028 .Undefined,27028 .undefined,
27029 .Null,27029 .null,
27030 => return,27030 => return,
2703127031
27032 .Opaque => {27032 .@"opaque" => {
27033 try sema.errNote(src_loc, msg, "opaque type '{}' has undefined size", .{ty.fmt(pt)});27033 try sema.errNote(src_loc, msg, "opaque type '{}' has undefined size", .{ty.fmt(pt)});
27034 },27034 },
2703527035
27036 .Array, .Vector => {27036 .array, .vector => {
27037 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.childType(zcu), type_set);27037 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.childType(zcu), type_set);
27038 },27038 },
27039 .Pointer => {27039 .pointer => {
27040 const elem_ty = ty.elemType2(zcu);27040 const elem_ty = ty.elemType2(zcu);
27041 if (elem_ty.zigTypeTag(zcu) == .Fn) {27041 if (elem_ty.zigTypeTag(zcu) == .@"fn") {
27042 const fn_info = zcu.typeToFunc(elem_ty).?;27042 const fn_info = zcu.typeToFunc(elem_ty).?;
27043 if (fn_info.is_generic) {27043 if (fn_info.is_generic) {
27044 try sema.errNote(src_loc, msg, "function is generic", .{});27044 try sema.errNote(src_loc, msg, "function is generic", .{});
...@@ -27055,14 +27055,14 @@ fn explainWhyTypeIsComptimeInner(...@@ -27055,14 +27055,14 @@ fn explainWhyTypeIsComptimeInner(
27055 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.childType(zcu), type_set);27055 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.childType(zcu), type_set);
27056 },27056 },
2705727057
27058 .Optional => {27058 .optional => {
27059 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.optionalChild(zcu), type_set);27059 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.optionalChild(zcu), type_set);
27060 },27060 },
27061 .ErrorUnion => {27061 .error_union => {
27062 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.errorUnionPayload(zcu), type_set);27062 try sema.explainWhyTypeIsComptimeInner(msg, src_loc, ty.errorUnionPayload(zcu), type_set);
27063 },27063 },
2706427064
27065 .Struct => {27065 .@"struct" => {
27066 if ((try type_set.getOrPut(sema.gpa, ty.toIntern())).found_existing) return;27066 if ((try type_set.getOrPut(sema.gpa, ty.toIntern())).found_existing) return;
2706727067
27068 if (zcu.typeToStruct(ty)) |struct_type| {27068 if (zcu.typeToStruct(ty)) |struct_type| {
...@@ -27082,7 +27082,7 @@ fn explainWhyTypeIsComptimeInner(...@@ -27082,7 +27082,7 @@ fn explainWhyTypeIsComptimeInner(
27082 // TODO tuples27082 // TODO tuples
27083 },27083 },
2708427084
27085 .Union => {27085 .@"union" => {
27086 if ((try type_set.getOrPut(sema.gpa, ty.toIntern())).found_existing) return;27086 if ((try type_set.getOrPut(sema.gpa, ty.toIntern())).found_existing) return;
2708727087
27088 if (zcu.typeToUnion(ty)) |union_obj| {27088 if (zcu.typeToUnion(ty)) |union_obj| {
...@@ -27123,34 +27123,34 @@ fn validateExternType(...@@ -27123,34 +27123,34 @@ fn validateExternType(
27123 const pt = sema.pt;27123 const pt = sema.pt;
27124 const zcu = pt.zcu;27124 const zcu = pt.zcu;
27125 switch (ty.zigTypeTag(zcu)) {27125 switch (ty.zigTypeTag(zcu)) {
27126 .Type,27126 .type,
27127 .ComptimeFloat,27127 .comptime_float,
27128 .ComptimeInt,27128 .comptime_int,
27129 .EnumLiteral,27129 .enum_literal,
27130 .Undefined,27130 .undefined,
27131 .Null,27131 .null,
27132 .ErrorUnion,27132 .error_union,
27133 .ErrorSet,27133 .error_set,
27134 .Frame,27134 .frame,
27135 => return false,27135 => return false,
27136 .Void => return position == .union_field or position == .ret_ty or position == .struct_field or position == .element,27136 .void => return position == .union_field or position == .ret_ty or position == .struct_field or position == .element,
27137 .NoReturn => return position == .ret_ty,27137 .noreturn => return position == .ret_ty,
27138 .Opaque,27138 .@"opaque",
27139 .Bool,27139 .bool,
27140 .Float,27140 .float,
27141 .AnyFrame,27141 .@"anyframe",
27142 => return true,27142 => return true,
27143 .Pointer => {27143 .pointer => {
27144 if (ty.childType(zcu).zigTypeTag(zcu) == .Fn) {27144 if (ty.childType(zcu).zigTypeTag(zcu) == .@"fn") {
27145 return ty.isConstPtr(zcu) and try sema.validateExternType(ty.childType(zcu), .other);27145 return ty.isConstPtr(zcu) and try sema.validateExternType(ty.childType(zcu), .other);
27146 }27146 }
27147 return !(ty.isSlice(zcu) or try ty.comptimeOnlySema(pt));27147 return !(ty.isSlice(zcu) or try ty.comptimeOnlySema(pt));
27148 },27148 },
27149 .Int => switch (ty.intInfo(zcu).bits) {27149 .int => switch (ty.intInfo(zcu).bits) {
27150 0, 8, 16, 32, 64, 128 => return true,27150 0, 8, 16, 32, 64, 128 => return true,
27151 else => return false,27151 else => return false,
27152 },27152 },
27153 .Fn => {27153 .@"fn" => {
27154 if (position != .other) return false;27154 if (position != .other) return false;
27155 const target = zcu.getTarget();27155 const target = zcu.getTarget();
27156 // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI.27156 // For now we want to authorize PTX kernel to use zig objects, even if we end up exposing the ABI.
...@@ -27160,10 +27160,10 @@ fn validateExternType(...@@ -27160,10 +27160,10 @@ fn validateExternType(
27160 }27160 }
27161 return !target_util.fnCallConvAllowsZigTypes(target, ty.fnCallingConvention(zcu));27161 return !target_util.fnCallConvAllowsZigTypes(target, ty.fnCallingConvention(zcu));
27162 },27162 },
27163 .Enum => {27163 .@"enum" => {
27164 return sema.validateExternType(ty.intTagType(zcu), position);27164 return sema.validateExternType(ty.intTagType(zcu), position);
27165 },27165 },
27166 .Struct, .Union => switch (ty.containerLayout(zcu)) {27166 .@"struct", .@"union" => switch (ty.containerLayout(zcu)) {
27167 .@"extern" => return true,27167 .@"extern" => return true,
27168 .@"packed" => {27168 .@"packed" => {
27169 const bit_size = try ty.bitSizeSema(pt);27169 const bit_size = try ty.bitSizeSema(pt);
...@@ -27174,12 +27174,12 @@ fn validateExternType(...@@ -27174,12 +27174,12 @@ fn validateExternType(
27174 },27174 },
27175 .auto => return !(try ty.hasRuntimeBitsSema(pt)),27175 .auto => return !(try ty.hasRuntimeBitsSema(pt)),
27176 },27176 },
27177 .Array => {27177 .array => {
27178 if (position == .ret_ty or position == .param_ty) return false;27178 if (position == .ret_ty or position == .param_ty) return false;
27179 return sema.validateExternType(ty.elemType2(zcu), .element);27179 return sema.validateExternType(ty.elemType2(zcu), .element);
27180 },27180 },
27181 .Vector => return sema.validateExternType(ty.elemType2(zcu), .element),27181 .vector => return sema.validateExternType(ty.elemType2(zcu), .element),
27182 .Optional => return ty.isPtrLikeOptional(zcu),27182 .optional => return ty.isPtrLikeOptional(zcu),
27183 }27183 }
27184}27184}
2718527185
...@@ -27193,29 +27193,29 @@ fn explainWhyTypeIsNotExtern(...@@ -27193,29 +27193,29 @@ fn explainWhyTypeIsNotExtern(
27193 const pt = sema.pt;27193 const pt = sema.pt;
27194 const zcu = pt.zcu;27194 const zcu = pt.zcu;
27195 switch (ty.zigTypeTag(zcu)) {27195 switch (ty.zigTypeTag(zcu)) {
27196 .Opaque,27196 .@"opaque",
27197 .Bool,27197 .bool,
27198 .Float,27198 .float,
27199 .AnyFrame,27199 .@"anyframe",
27200 => return,27200 => return,
2720127201
27202 .Type,27202 .type,
27203 .ComptimeFloat,27203 .comptime_float,
27204 .ComptimeInt,27204 .comptime_int,
27205 .EnumLiteral,27205 .enum_literal,
27206 .Undefined,27206 .undefined,
27207 .Null,27207 .null,
27208 .ErrorUnion,27208 .error_union,
27209 .ErrorSet,27209 .error_set,
27210 .Frame,27210 .frame,
27211 => return,27211 => return,
2721227212
27213 .Pointer => {27213 .pointer => {
27214 if (ty.isSlice(zcu)) {27214 if (ty.isSlice(zcu)) {
27215 try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{});27215 try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{});
27216 } else {27216 } else {
27217 const pointee_ty = ty.childType(zcu);27217 const pointee_ty = ty.childType(zcu);
27218 if (!ty.isConstPtr(zcu) and pointee_ty.zigTypeTag(zcu) == .Fn) {27218 if (!ty.isConstPtr(zcu) and pointee_ty.zigTypeTag(zcu) == .@"fn") {
27219 try sema.errNote(src_loc, msg, "pointer to extern function must be 'const'", .{});27219 try sema.errNote(src_loc, msg, "pointer to extern function must be 'const'", .{});
27220 } else if (try ty.comptimeOnlySema(pt)) {27220 } else if (try ty.comptimeOnlySema(pt)) {
27221 try sema.errNote(src_loc, msg, "pointer to comptime-only type '{}'", .{pointee_ty.fmt(pt)});27221 try sema.errNote(src_loc, msg, "pointer to comptime-only type '{}'", .{pointee_ty.fmt(pt)});
...@@ -27224,14 +27224,14 @@ fn explainWhyTypeIsNotExtern(...@@ -27224,14 +27224,14 @@ fn explainWhyTypeIsNotExtern(
27224 try sema.explainWhyTypeIsNotExtern(msg, src_loc, pointee_ty, .other);27224 try sema.explainWhyTypeIsNotExtern(msg, src_loc, pointee_ty, .other);
27225 }27225 }
27226 },27226 },
27227 .Void => try sema.errNote(src_loc, msg, "'void' is a zero bit type; for C 'void' use 'anyopaque'", .{}),27227 .void => try sema.errNote(src_loc, msg, "'void' is a zero bit type; for C 'void' use 'anyopaque'", .{}),
27228 .NoReturn => try sema.errNote(src_loc, msg, "'noreturn' is only allowed as a return type", .{}),27228 .noreturn => try sema.errNote(src_loc, msg, "'noreturn' is only allowed as a return type", .{}),
27229 .Int => if (!std.math.isPowerOfTwo(ty.intInfo(zcu).bits)) {27229 .int => if (!std.math.isPowerOfTwo(ty.intInfo(zcu).bits)) {
27230 try sema.errNote(src_loc, msg, "only integers with 0 or power of two bits are extern compatible", .{});27230 try sema.errNote(src_loc, msg, "only integers with 0 or power of two bits are extern compatible", .{});
27231 } else {27231 } else {
27232 try sema.errNote(src_loc, msg, "only integers with 0, 8, 16, 32, 64 and 128 bits are extern compatible", .{});27232 try sema.errNote(src_loc, msg, "only integers with 0, 8, 16, 32, 64 and 128 bits are extern compatible", .{});
27233 },27233 },
27234 .Fn => {27234 .@"fn" => {
27235 if (position != .other) {27235 if (position != .other) {
27236 try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{});27236 try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{});
27237 try sema.errNote(src_loc, msg, "use '*const ' to make a function pointer type", .{});27237 try sema.errNote(src_loc, msg, "use '*const ' to make a function pointer type", .{});
...@@ -27244,14 +27244,14 @@ fn explainWhyTypeIsNotExtern(...@@ -27244,14 +27244,14 @@ fn explainWhyTypeIsNotExtern(
27244 else => return,27244 else => return,
27245 }27245 }
27246 },27246 },
27247 .Enum => {27247 .@"enum" => {
27248 const tag_ty = ty.intTagType(zcu);27248 const tag_ty = ty.intTagType(zcu);
27249 try sema.errNote(src_loc, msg, "enum tag type '{}' is not extern compatible", .{tag_ty.fmt(pt)});27249 try sema.errNote(src_loc, msg, "enum tag type '{}' is not extern compatible", .{tag_ty.fmt(pt)});
27250 try sema.explainWhyTypeIsNotExtern(msg, src_loc, tag_ty, position);27250 try sema.explainWhyTypeIsNotExtern(msg, src_loc, tag_ty, position);
27251 },27251 },
27252 .Struct => try sema.errNote(src_loc, msg, "only extern structs and ABI sized packed structs are extern compatible", .{}),27252 .@"struct" => try sema.errNote(src_loc, msg, "only extern structs and ABI sized packed structs are extern compatible", .{}),
27253 .Union => try sema.errNote(src_loc, msg, "only extern unions and ABI sized packed unions are extern compatible", .{}),27253 .@"union" => try sema.errNote(src_loc, msg, "only extern unions and ABI sized packed unions are extern compatible", .{}),
27254 .Array => {27254 .array => {
27255 if (position == .ret_ty) {27255 if (position == .ret_ty) {
27256 return sema.errNote(src_loc, msg, "arrays are not allowed as a return type", .{});27256 return sema.errNote(src_loc, msg, "arrays are not allowed as a return type", .{});
27257 } else if (position == .param_ty) {27257 } else if (position == .param_ty) {
...@@ -27259,8 +27259,8 @@ fn explainWhyTypeIsNotExtern(...@@ -27259,8 +27259,8 @@ fn explainWhyTypeIsNotExtern(
27259 }27259 }
27260 try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element);27260 try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element);
27261 },27261 },
27262 .Vector => try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element),27262 .vector => try sema.explainWhyTypeIsNotExtern(msg, src_loc, ty.elemType2(zcu), .element),
27263 .Optional => try sema.errNote(src_loc, msg, "only pointer like optionals are extern compatible", .{}),27263 .optional => try sema.errNote(src_loc, msg, "only pointer like optionals are extern compatible", .{}),
27264 }27264 }
27265}27265}
2726627266
...@@ -27270,34 +27270,34 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool {...@@ -27270,34 +27270,34 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool {
27270 const pt = sema.pt;27270 const pt = sema.pt;
27271 const zcu = pt.zcu;27271 const zcu = pt.zcu;
27272 return switch (ty.zigTypeTag(zcu)) {27272 return switch (ty.zigTypeTag(zcu)) {
27273 .Type,27273 .type,
27274 .ComptimeFloat,27274 .comptime_float,
27275 .ComptimeInt,27275 .comptime_int,
27276 .EnumLiteral,27276 .enum_literal,
27277 .Undefined,27277 .undefined,
27278 .Null,27278 .null,
27279 .ErrorUnion,27279 .error_union,
27280 .ErrorSet,27280 .error_set,
27281 .Frame,27281 .frame,
27282 .NoReturn,27282 .noreturn,
27283 .Opaque,27283 .@"opaque",
27284 .AnyFrame,27284 .@"anyframe",
27285 .Fn,27285 .@"fn",
27286 .Array,27286 .array,
27287 => false,27287 => false,
27288 .Optional => return ty.isPtrLikeOptional(zcu),27288 .optional => return ty.isPtrLikeOptional(zcu),
27289 .Void,27289 .void,
27290 .Bool,27290 .bool,
27291 .Float,27291 .float,
27292 .Int,27292 .int,
27293 .Vector,27293 .vector,
27294 => true,27294 => true,
27295 .Enum => switch (zcu.intern_pool.loadEnumType(ty.toIntern()).tag_mode) {27295 .@"enum" => switch (zcu.intern_pool.loadEnumType(ty.toIntern()).tag_mode) {
27296 .auto => false,27296 .auto => false,
27297 .explicit, .nonexhaustive => true,27297 .explicit, .nonexhaustive => true,
27298 },27298 },
27299 .Pointer => !ty.isSlice(zcu) and !try ty.comptimeOnlySema(pt),27299 .pointer => !ty.isSlice(zcu) and !try ty.comptimeOnlySema(pt),
27300 .Struct, .Union => ty.containerLayout(zcu) == .@"packed",27300 .@"struct", .@"union" => ty.containerLayout(zcu) == .@"packed",
27301 };27301 };
27302}27302}
2730327303
...@@ -27310,40 +27310,40 @@ fn explainWhyTypeIsNotPacked(...@@ -27310,40 +27310,40 @@ fn explainWhyTypeIsNotPacked(
27310 const pt = sema.pt;27310 const pt = sema.pt;
27311 const zcu = pt.zcu;27311 const zcu = pt.zcu;
27312 switch (ty.zigTypeTag(zcu)) {27312 switch (ty.zigTypeTag(zcu)) {
27313 .Void,27313 .void,
27314 .Bool,27314 .bool,
27315 .Float,27315 .float,
27316 .Int,27316 .int,
27317 .Vector,27317 .vector,
27318 .Enum,27318 .@"enum",
27319 => return,27319 => return,
27320 .Type,27320 .type,
27321 .ComptimeFloat,27321 .comptime_float,
27322 .ComptimeInt,27322 .comptime_int,
27323 .EnumLiteral,27323 .enum_literal,
27324 .Undefined,27324 .undefined,
27325 .Null,27325 .null,
27326 .Frame,27326 .frame,
27327 .NoReturn,27327 .noreturn,
27328 .Opaque,27328 .@"opaque",
27329 .ErrorUnion,27329 .error_union,
27330 .ErrorSet,27330 .error_set,
27331 .AnyFrame,27331 .@"anyframe",
27332 .Optional,27332 .optional,
27333 .Array,27333 .array,
27334 => try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{}),27334 => try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{}),
27335 .Pointer => if (ty.isSlice(zcu)) {27335 .pointer => if (ty.isSlice(zcu)) {
27336 try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{});27336 try sema.errNote(src_loc, msg, "slices have no guaranteed in-memory representation", .{});
27337 } else {27337 } else {
27338 try sema.errNote(src_loc, msg, "comptime-only pointer has no guaranteed in-memory representation", .{});27338 try sema.errNote(src_loc, msg, "comptime-only pointer has no guaranteed in-memory representation", .{});
27339 try sema.explainWhyTypeIsComptime(msg, src_loc, ty);27339 try sema.explainWhyTypeIsComptime(msg, src_loc, ty);
27340 },27340 },
27341 .Fn => {27341 .@"fn" => {
27342 try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{});27342 try sema.errNote(src_loc, msg, "type has no guaranteed in-memory representation", .{});
27343 try sema.errNote(src_loc, msg, "use '*const ' to make a function pointer type", .{});27343 try sema.errNote(src_loc, msg, "use '*const ' to make a function pointer type", .{});
27344 },27344 },
27345 .Struct => try sema.errNote(src_loc, msg, "only packed structs layout are allowed in packed types", .{}),27345 .@"struct" => try sema.errNote(src_loc, msg, "only packed structs layout are allowed in packed types", .{}),
27346 .Union => try sema.errNote(src_loc, msg, "only packed unions layout are allowed in packed types", .{}),27346 .@"union" => try sema.errNote(src_loc, msg, "only packed unions layout are allowed in packed types", .{}),
27347 }27347 }
27348}27348}
2734927349
...@@ -27356,7 +27356,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block, src: LazySrcLoc) !void {...@@ -27356,7 +27356,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block, src: LazySrcLoc) !void {
27356 const fn_val = try sema.resolveConstValue(block, src, fn_ref, .{27356 const fn_val = try sema.resolveConstValue(block, src, fn_ref, .{
27357 .needed_comptime_reason = "panic handler must be comptime-known",27357 .needed_comptime_reason = "panic handler must be comptime-known",
27358 });27358 });
27359 assert(fn_val.typeOf(zcu).zigTypeTag(zcu) == .Fn);27359 assert(fn_val.typeOf(zcu).zigTypeTag(zcu) == .@"fn");
27360 assert(try fn_val.typeOf(zcu).fnHasRuntimeBitsSema(pt));27360 assert(try fn_val.typeOf(zcu).fnHasRuntimeBitsSema(pt));
27361 try zcu.ensureFuncBodyAnalysisQueued(fn_val.toIntern());27361 try zcu.ensureFuncBodyAnalysisQueued(fn_val.toIntern());
27362 zcu.panic_func_index = fn_val.toIntern();27362 zcu.panic_func_index = fn_val.toIntern();
...@@ -27444,9 +27444,9 @@ fn addSafetyCheckExtra(...@@ -27444,9 +27444,9 @@ fn addSafetyCheckExtra(
2744427444
27445 try parent_block.instructions.ensureUnusedCapacity(gpa, 1);27445 try parent_block.instructions.ensureUnusedCapacity(gpa, 1);
2744627446
27447 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +27447 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len +
27448 1 + // The main block only needs space for the cond_br.27448 1 + // The main block only needs space for the cond_br.
27449 @typeInfo(Air.CondBr).Struct.fields.len +27449 @typeInfo(Air.CondBr).@"struct".fields.len +
27450 1 + // The ok branch of the cond_br only needs space for the br.27450 1 + // The ok branch of the cond_br only needs space for the br.
27451 fail_block.instructions.items.len);27451 fail_block.instructions.items.len);
2745227452
...@@ -27614,7 +27614,7 @@ fn panicSentinelMismatch(...@@ -27614,7 +27614,7 @@ fn panicSentinelMismatch(
27614 break :blk try parent_block.addTyOp(.load, sentinel_ty, sentinel_ptr);27614 break :blk try parent_block.addTyOp(.load, sentinel_ty, sentinel_ptr);
27615 };27615 };
2761627616
27617 const ok = if (sentinel_ty.zigTypeTag(zcu) == .Vector) ok: {27617 const ok = if (sentinel_ty.zigTypeTag(zcu) == .vector) ok: {
27618 const eql =27618 const eql =
27619 try parent_block.addCmpVector(expected_sentinel, actual_sentinel, .eq);27619 try parent_block.addCmpVector(expected_sentinel, actual_sentinel, .eq);
27620 break :ok try parent_block.addInst(.{27620 break :ok try parent_block.addInst(.{
...@@ -27727,7 +27727,7 @@ fn fieldVal(...@@ -27727,7 +27727,7 @@ fn fieldVal(
27727 object_ty;27727 object_ty;
2772827728
27729 switch (inner_ty.zigTypeTag(zcu)) {27729 switch (inner_ty.zigTypeTag(zcu)) {
27730 .Array => {27730 .array => {
27731 if (field_name.eqlSlice("len", ip)) {27731 if (field_name.eqlSlice("len", ip)) {
27732 return Air.internedToRef((try pt.intValue(Type.usize, inner_ty.arrayLen(zcu))).toIntern());27732 return Air.internedToRef((try pt.intValue(Type.usize, inner_ty.arrayLen(zcu))).toIntern());
27733 } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) {27733 } else if (field_name.eqlSlice("ptr", ip) and is_pointer_to) {
...@@ -27756,7 +27756,7 @@ fn fieldVal(...@@ -27756,7 +27756,7 @@ fn fieldVal(
27756 );27756 );
27757 }27757 }
27758 },27758 },
27759 .Pointer => {27759 .pointer => {
27760 const ptr_info = inner_ty.ptrInfo(zcu);27760 const ptr_info = inner_ty.ptrInfo(zcu);
27761 if (ptr_info.flags.size == .Slice) {27761 if (ptr_info.flags.size == .Slice) {
27762 if (field_name.eqlSlice("ptr", ip)) {27762 if (field_name.eqlSlice("ptr", ip)) {
...@@ -27781,7 +27781,7 @@ fn fieldVal(...@@ -27781,7 +27781,7 @@ fn fieldVal(
27781 }27781 }
27782 }27782 }
27783 },27783 },
27784 .Type => {27784 .type => {
27785 const dereffed_type = if (is_pointer_to)27785 const dereffed_type = if (is_pointer_to)
27786 try sema.analyzeLoad(block, src, object, object_src)27786 try sema.analyzeLoad(block, src, object, object_src)
27787 else27787 else
...@@ -27791,7 +27791,7 @@ fn fieldVal(...@@ -27791,7 +27791,7 @@ fn fieldVal(
27791 const child_type = val.toType();27791 const child_type = val.toType();
2779227792
27793 switch (try child_type.zigTypeTagOrPoison(zcu)) {27793 switch (try child_type.zigTypeTagOrPoison(zcu)) {
27794 .ErrorSet => {27794 .error_set => {
27795 switch (ip.indexToKey(child_type.toIntern())) {27795 switch (ip.indexToKey(child_type.toIntern())) {
27796 .error_set_type => |error_set_type| blk: {27796 .error_set_type => |error_set_type| blk: {
27797 if (error_set_type.nameIndex(ip, field_name) != null) break :blk;27797 if (error_set_type.nameIndex(ip, field_name) != null) break :blk;
...@@ -27818,7 +27818,7 @@ fn fieldVal(...@@ -27818,7 +27818,7 @@ fn fieldVal(
27818 .name = field_name,27818 .name = field_name,
27819 } })));27819 } })));
27820 },27820 },
27821 .Union => {27821 .@"union" => {
27822 if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {27822 if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {
27823 return inst;27823 return inst;
27824 }27824 }
...@@ -27831,7 +27831,7 @@ fn fieldVal(...@@ -27831,7 +27831,7 @@ fn fieldVal(
27831 }27831 }
27832 return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name);27832 return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name);
27833 },27833 },
27834 .Enum => {27834 .@"enum" => {
27835 if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {27835 if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {
27836 return inst;27836 return inst;
27837 }27837 }
...@@ -27841,7 +27841,7 @@ fn fieldVal(...@@ -27841,7 +27841,7 @@ fn fieldVal(
27841 const enum_val = try pt.enumValueFieldIndex(child_type, field_index);27841 const enum_val = try pt.enumValueFieldIndex(child_type, field_index);
27842 return Air.internedToRef(enum_val.toIntern());27842 return Air.internedToRef(enum_val.toIntern());
27843 },27843 },
27844 .Struct, .Opaque => {27844 .@"struct", .@"opaque" => {
27845 switch (child_type.toIntern()) {27845 switch (child_type.toIntern()) {
27846 .empty_struct_type, .anyopaque_type => {}, // no namespace27846 .empty_struct_type, .anyopaque_type => {}, // no namespace
27847 else => if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {27847 else => if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {
...@@ -27854,19 +27854,19 @@ fn fieldVal(...@@ -27854,19 +27854,19 @@ fn fieldVal(
27854 const msg = try sema.errMsg(src, "type '{}' has no members", .{child_type.fmt(pt)});27854 const msg = try sema.errMsg(src, "type '{}' has no members", .{child_type.fmt(pt)});
27855 errdefer msg.destroy(sema.gpa);27855 errdefer msg.destroy(sema.gpa);
27856 if (child_type.isSlice(zcu)) try sema.errNote(src, msg, "slice values have 'len' and 'ptr' members", .{});27856 if (child_type.isSlice(zcu)) try sema.errNote(src, msg, "slice values have 'len' and 'ptr' members", .{});
27857 if (child_type.zigTypeTag(zcu) == .Array) try sema.errNote(src, msg, "array values have 'len' member", .{});27857 if (child_type.zigTypeTag(zcu) == .array) try sema.errNote(src, msg, "array values have 'len' member", .{});
27858 break :msg msg;27858 break :msg msg;
27859 }),27859 }),
27860 }27860 }
27861 },27861 },
27862 .Struct => if (is_pointer_to) {27862 .@"struct" => if (is_pointer_to) {
27863 // Avoid loading the entire struct by fetching a pointer and loading that27863 // Avoid loading the entire struct by fetching a pointer and loading that
27864 const field_ptr = try sema.structFieldPtr(block, src, object, field_name, field_name_src, inner_ty, false);27864 const field_ptr = try sema.structFieldPtr(block, src, object, field_name, field_name_src, inner_ty, false);
27865 return sema.analyzeLoad(block, src, field_ptr, object_src);27865 return sema.analyzeLoad(block, src, field_ptr, object_src);
27866 } else {27866 } else {
27867 return sema.structFieldVal(block, src, object, field_name, field_name_src, inner_ty);27867 return sema.structFieldVal(block, src, object, field_name, field_name_src, inner_ty);
27868 },27868 },
27869 .Union => if (is_pointer_to) {27869 .@"union" => if (is_pointer_to) {
27870 // Avoid loading the entire union by fetching a pointer and loading that27870 // Avoid loading the entire union by fetching a pointer and loading that
27871 const field_ptr = try sema.unionFieldPtr(block, src, object, field_name, field_name_src, inner_ty, false);27871 const field_ptr = try sema.unionFieldPtr(block, src, object, field_name, field_name_src, inner_ty, false);
27872 return sema.analyzeLoad(block, src, field_ptr, object_src);27872 return sema.analyzeLoad(block, src, field_ptr, object_src);
...@@ -27896,7 +27896,7 @@ fn fieldPtr(...@@ -27896,7 +27896,7 @@ fn fieldPtr(
27896 const object_ptr_src = src; // TODO better source location27896 const object_ptr_src = src; // TODO better source location
27897 const object_ptr_ty = sema.typeOf(object_ptr);27897 const object_ptr_ty = sema.typeOf(object_ptr);
27898 const object_ty = switch (object_ptr_ty.zigTypeTag(zcu)) {27898 const object_ty = switch (object_ptr_ty.zigTypeTag(zcu)) {
27899 .Pointer => object_ptr_ty.childType(zcu),27899 .pointer => object_ptr_ty.childType(zcu),
27900 else => return sema.fail(block, object_ptr_src, "expected pointer, found '{}'", .{object_ptr_ty.fmt(pt)}),27900 else => return sema.fail(block, object_ptr_src, "expected pointer, found '{}'", .{object_ptr_ty.fmt(pt)}),
27901 };27901 };
2790227902
...@@ -27911,7 +27911,7 @@ fn fieldPtr(...@@ -27911,7 +27911,7 @@ fn fieldPtr(
27911 object_ty;27911 object_ty;
2791227912
27913 switch (inner_ty.zigTypeTag(zcu)) {27913 switch (inner_ty.zigTypeTag(zcu)) {
27914 .Array => {27914 .array => {
27915 if (field_name.eqlSlice("len", ip)) {27915 if (field_name.eqlSlice("len", ip)) {
27916 const int_val = try pt.intValue(Type.usize, inner_ty.arrayLen(zcu));27916 const int_val = try pt.intValue(Type.usize, inner_ty.arrayLen(zcu));
27917 return uavRef(sema, int_val.toIntern());27917 return uavRef(sema, int_val.toIntern());
...@@ -27955,7 +27955,7 @@ fn fieldPtr(...@@ -27955,7 +27955,7 @@ fn fieldPtr(
27955 );27955 );
27956 }27956 }
27957 },27957 },
27958 .Pointer => if (inner_ty.isSlice(zcu)) {27958 .pointer => if (inner_ty.isSlice(zcu)) {
27959 const inner_ptr = if (is_pointer_to)27959 const inner_ptr = if (is_pointer_to)
27960 try sema.analyzeLoad(block, src, object_ptr, object_ptr_src)27960 try sema.analyzeLoad(block, src, object_ptr, object_ptr_src)
27961 else27961 else
...@@ -28010,7 +28010,7 @@ fn fieldPtr(...@@ -28010,7 +28010,7 @@ fn fieldPtr(
28010 );28010 );
28011 }28011 }
28012 },28012 },
28013 .Type => {28013 .type => {
28014 _ = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, object_ptr, undefined);28014 _ = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, object_ptr, undefined);
28015 const result = try sema.analyzeLoad(block, src, object_ptr, object_ptr_src);28015 const result = try sema.analyzeLoad(block, src, object_ptr, object_ptr_src);
28016 const inner = if (is_pointer_to)28016 const inner = if (is_pointer_to)
...@@ -28022,7 +28022,7 @@ fn fieldPtr(...@@ -28022,7 +28022,7 @@ fn fieldPtr(
28022 const child_type = val.toType();28022 const child_type = val.toType();
2802328023
28024 switch (child_type.zigTypeTag(zcu)) {28024 switch (child_type.zigTypeTag(zcu)) {
28025 .ErrorSet => {28025 .error_set => {
28026 switch (ip.indexToKey(child_type.toIntern())) {28026 switch (ip.indexToKey(child_type.toIntern())) {
28027 .error_set_type => |error_set_type| blk: {28027 .error_set_type => |error_set_type| blk: {
28028 if (error_set_type.nameIndex(ip, field_name) != null) {28028 if (error_set_type.nameIndex(ip, field_name) != null) {
...@@ -28051,7 +28051,7 @@ fn fieldPtr(...@@ -28051,7 +28051,7 @@ fn fieldPtr(
28051 .name = field_name,28051 .name = field_name,
28052 } }));28052 } }));
28053 },28053 },
28054 .Union => {28054 .@"union" => {
28055 if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {28055 if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {
28056 return inst;28056 return inst;
28057 }28057 }
...@@ -28065,7 +28065,7 @@ fn fieldPtr(...@@ -28065,7 +28065,7 @@ fn fieldPtr(
28065 }28065 }
28066 return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name);28066 return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name);
28067 },28067 },
28068 .Enum => {28068 .@"enum" => {
28069 if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {28069 if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {
28070 return inst;28070 return inst;
28071 }28071 }
...@@ -28076,7 +28076,7 @@ fn fieldPtr(...@@ -28076,7 +28076,7 @@ fn fieldPtr(
28076 const idx_val = try pt.enumValueFieldIndex(child_type, field_index_u32);28076 const idx_val = try pt.enumValueFieldIndex(child_type, field_index_u32);
28077 return uavRef(sema, idx_val.toIntern());28077 return uavRef(sema, idx_val.toIntern());
28078 },28078 },
28079 .Struct, .Opaque => {28079 .@"struct", .@"opaque" => {
28080 if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {28080 if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(zcu), field_name)) |inst| {
28081 return inst;28081 return inst;
28082 }28082 }
...@@ -28085,7 +28085,7 @@ fn fieldPtr(...@@ -28085,7 +28085,7 @@ fn fieldPtr(
28085 else => return sema.fail(block, src, "type '{}' has no members", .{child_type.fmt(pt)}),28085 else => return sema.fail(block, src, "type '{}' has no members", .{child_type.fmt(pt)}),
28086 }28086 }
28087 },28087 },
28088 .Struct => {28088 .@"struct" => {
28089 const inner_ptr = if (is_pointer_to)28089 const inner_ptr = if (is_pointer_to)
28090 try sema.analyzeLoad(block, src, object_ptr, object_ptr_src)28090 try sema.analyzeLoad(block, src, object_ptr, object_ptr_src)
28091 else28091 else
...@@ -28094,7 +28094,7 @@ fn fieldPtr(...@@ -28094,7 +28094,7 @@ fn fieldPtr(
28094 try sema.checkKnownAllocPtr(block, inner_ptr, field_ptr);28094 try sema.checkKnownAllocPtr(block, inner_ptr, field_ptr);
28095 return field_ptr;28095 return field_ptr;
28096 },28096 },
28097 .Union => {28097 .@"union" => {
28098 const inner_ptr = if (is_pointer_to)28098 const inner_ptr = if (is_pointer_to)
28099 try sema.analyzeLoad(block, src, object_ptr, object_ptr_src)28099 try sema.analyzeLoad(block, src, object_ptr, object_ptr_src)
28100 else28100 else
...@@ -28134,13 +28134,13 @@ fn fieldCallBind(...@@ -28134,13 +28134,13 @@ fn fieldCallBind(
28134 const ip = &zcu.intern_pool;28134 const ip = &zcu.intern_pool;
28135 const raw_ptr_src = src; // TODO better source location28135 const raw_ptr_src = src; // TODO better source location
28136 const raw_ptr_ty = sema.typeOf(raw_ptr);28136 const raw_ptr_ty = sema.typeOf(raw_ptr);
28137 const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .Pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C))28137 const inner_ty = if (raw_ptr_ty.zigTypeTag(zcu) == .pointer and (raw_ptr_ty.ptrSize(zcu) == .One or raw_ptr_ty.ptrSize(zcu) == .C))
28138 raw_ptr_ty.childType(zcu)28138 raw_ptr_ty.childType(zcu)
28139 else28139 else
28140 return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)});28140 return sema.fail(block, raw_ptr_src, "expected single pointer, found '{}'", .{raw_ptr_ty.fmt(pt)});
2814128141
28142 // Optionally dereference a second pointer to get the concrete type.28142 // Optionally dereference a second pointer to get the concrete type.
28143 const is_double_ptr = inner_ty.zigTypeTag(zcu) == .Pointer and inner_ty.ptrSize(zcu) == .One;28143 const is_double_ptr = inner_ty.zigTypeTag(zcu) == .pointer and inner_ty.ptrSize(zcu) == .One;
28144 const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty;28144 const concrete_ty = if (is_double_ptr) inner_ty.childType(zcu) else inner_ty;
28145 const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty;28145 const ptr_ty = if (is_double_ptr) inner_ty else raw_ptr_ty;
28146 const object_ptr = if (is_double_ptr)28146 const object_ptr = if (is_double_ptr)
...@@ -28150,7 +28150,7 @@ fn fieldCallBind(...@@ -28150,7 +28150,7 @@ fn fieldCallBind(
2815028150
28151 find_field: {28151 find_field: {
28152 switch (concrete_ty.zigTypeTag(zcu)) {28152 switch (concrete_ty.zigTypeTag(zcu)) {
28153 .Struct => {28153 .@"struct" => {
28154 try concrete_ty.resolveFields(pt);28154 try concrete_ty.resolveFields(pt);
28155 if (zcu.typeToStruct(concrete_ty)) |struct_type| {28155 if (zcu.typeToStruct(concrete_ty)) |struct_type| {
28156 const field_index = struct_type.nameIndex(ip, field_name) orelse28156 const field_index = struct_type.nameIndex(ip, field_name) orelse
...@@ -28176,14 +28176,14 @@ fn fieldCallBind(...@@ -28176,14 +28176,14 @@ fn fieldCallBind(
28176 }28176 }
28177 }28177 }
28178 },28178 },
28179 .Union => {28179 .@"union" => {
28180 try concrete_ty.resolveFields(pt);28180 try concrete_ty.resolveFields(pt);
28181 const union_obj = zcu.typeToUnion(concrete_ty).?;28181 const union_obj = zcu.typeToUnion(concrete_ty).?;
28182 _ = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse break :find_field;28182 _ = union_obj.loadTagType(ip).nameIndex(ip, field_name) orelse break :find_field;
28183 const field_ptr = try unionFieldPtr(sema, block, src, object_ptr, field_name, field_name_src, concrete_ty, false);28183 const field_ptr = try unionFieldPtr(sema, block, src, object_ptr, field_name, field_name_src, concrete_ty, false);
28184 return .{ .direct = try sema.analyzeLoad(block, src, field_ptr, src) };28184 return .{ .direct = try sema.analyzeLoad(block, src, field_ptr, src) };
28185 },28185 },
28186 .Type => {28186 .type => {
28187 const namespace = try sema.analyzeLoad(block, src, object_ptr, src);28187 const namespace = try sema.analyzeLoad(block, src, object_ptr, src);
28188 return .{ .direct = try sema.fieldVal(block, src, namespace, field_name, field_name_src) };28188 return .{ .direct = try sema.fieldVal(block, src, namespace, field_name, field_name_src) };
28189 },28189 },
...@@ -28205,7 +28205,7 @@ fn fieldCallBind(...@@ -28205,7 +28205,7 @@ fn fieldCallBind(
2820528205
28206 const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);28206 const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
28207 if (first_param_type.isGenericPoison() or28207 if (first_param_type.isGenericPoison() or
28208 (first_param_type.zigTypeTag(zcu) == .Pointer and28208 (first_param_type.zigTypeTag(zcu) == .pointer and
28209 (first_param_type.ptrSize(zcu) == .One or28209 (first_param_type.ptrSize(zcu) == .One or
28210 first_param_type.ptrSize(zcu) == .C) and28210 first_param_type.ptrSize(zcu) == .C) and
28211 first_param_type.childType(zcu).eql(concrete_ty, zcu)))28211 first_param_type.childType(zcu).eql(concrete_ty, zcu)))
...@@ -28225,7 +28225,7 @@ fn fieldCallBind(...@@ -28225,7 +28225,7 @@ fn fieldCallBind(
28225 .func_inst = decl_val,28225 .func_inst = decl_val,
28226 .arg0_inst = deref,28226 .arg0_inst = deref,
28227 } };28227 } };
28228 } else if (first_param_type.zigTypeTag(zcu) == .Optional) {28228 } else if (first_param_type.zigTypeTag(zcu) == .optional) {
28229 const child = first_param_type.optionalChild(zcu);28229 const child = first_param_type.optionalChild(zcu);
28230 if (child.eql(concrete_ty, zcu)) {28230 if (child.eql(concrete_ty, zcu)) {
28231 const deref = try sema.analyzeLoad(block, src, object_ptr, src);28231 const deref = try sema.analyzeLoad(block, src, object_ptr, src);
...@@ -28233,7 +28233,7 @@ fn fieldCallBind(...@@ -28233,7 +28233,7 @@ fn fieldCallBind(
28233 .func_inst = decl_val,28233 .func_inst = decl_val,
28234 .arg0_inst = deref,28234 .arg0_inst = deref,
28235 } };28235 } };
28236 } else if (child.zigTypeTag(zcu) == .Pointer and28236 } else if (child.zigTypeTag(zcu) == .pointer and
28237 child.ptrSize(zcu) == .One and28237 child.ptrSize(zcu) == .One and
28238 child.childType(zcu).eql(concrete_ty, zcu))28238 child.childType(zcu).eql(concrete_ty, zcu))
28239 {28239 {
...@@ -28242,7 +28242,7 @@ fn fieldCallBind(...@@ -28242,7 +28242,7 @@ fn fieldCallBind(
28242 .arg0_inst = object_ptr,28242 .arg0_inst = object_ptr,
28243 } };28243 } };
28244 }28244 }
28245 } else if (first_param_type.zigTypeTag(zcu) == .ErrorUnion and28245 } else if (first_param_type.zigTypeTag(zcu) == .error_union and
28246 first_param_type.errorUnionPayload(zcu).eql(concrete_ty, zcu))28246 first_param_type.errorUnionPayload(zcu).eql(concrete_ty, zcu))
28247 {28247 {
28248 const deref = try sema.analyzeLoad(block, src, object_ptr, src);28248 const deref = try sema.analyzeLoad(block, src, object_ptr, src);
...@@ -28270,7 +28270,7 @@ fn fieldCallBind(...@@ -28270,7 +28270,7 @@ fn fieldCallBind(
28270 .{field_name.fmt(ip)},28270 .{field_name.fmt(ip)},
28271 );28271 );
28272 }28272 }
28273 if (concrete_ty.zigTypeTag(zcu) == .ErrorUnion) {28273 if (concrete_ty.zigTypeTag(zcu) == .error_union) {
28274 try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{});28274 try sema.errNote(src, msg, "consider using 'try', 'catch', or 'if'", .{});
28275 }28275 }
28276 if (is_double_ptr) {28276 if (is_double_ptr) {
...@@ -28302,7 +28302,7 @@ fn finishFieldCallBind(...@@ -28302,7 +28302,7 @@ fn finishFieldCallBind(
28302 });28302 });
2830328303
28304 const container_ty = ptr_ty.childType(zcu);28304 const container_ty = ptr_ty.childType(zcu);
28305 if (container_ty.zigTypeTag(zcu) == .Struct) {28305 if (container_ty.zigTypeTag(zcu) == .@"struct") {
28306 if (container_ty.structFieldIsComptime(field_index, zcu)) {28306 if (container_ty.structFieldIsComptime(field_index, zcu)) {
28307 try container_ty.resolveStructFieldInits(pt);28307 try container_ty.resolveStructFieldInits(pt);
28308 const default_val = (try container_ty.structFieldValueComptime(pt, field_index)).?;28308 const default_val = (try container_ty.structFieldValueComptime(pt, field_index)).?;
...@@ -28382,7 +28382,7 @@ fn structFieldPtr(...@@ -28382,7 +28382,7 @@ fn structFieldPtr(
28382 const pt = sema.pt;28382 const pt = sema.pt;
28383 const zcu = pt.zcu;28383 const zcu = pt.zcu;
28384 const ip = &zcu.intern_pool;28384 const ip = &zcu.intern_pool;
28385 assert(struct_ty.zigTypeTag(zcu) == .Struct);28385 assert(struct_ty.zigTypeTag(zcu) == .@"struct");
2838628386
28387 try struct_ty.resolveFields(pt);28387 try struct_ty.resolveFields(pt);
28388 try struct_ty.resolveLayout(pt);28388 try struct_ty.resolveLayout(pt);
...@@ -28508,7 +28508,7 @@ fn structFieldVal(...@@ -28508,7 +28508,7 @@ fn structFieldVal(
28508 const pt = sema.pt;28508 const pt = sema.pt;
28509 const zcu = pt.zcu;28509 const zcu = pt.zcu;
28510 const ip = &zcu.intern_pool;28510 const ip = &zcu.intern_pool;
28511 assert(struct_ty.zigTypeTag(zcu) == .Struct);28511 assert(struct_ty.zigTypeTag(zcu) == .@"struct");
2851228512
28513 try struct_ty.resolveFields(pt);28513 try struct_ty.resolveFields(pt);
2851428514
...@@ -28646,7 +28646,7 @@ fn unionFieldPtr(...@@ -28646,7 +28646,7 @@ fn unionFieldPtr(
28646 const zcu = pt.zcu;28646 const zcu = pt.zcu;
28647 const ip = &zcu.intern_pool;28647 const ip = &zcu.intern_pool;
2864828648
28649 assert(union_ty.zigTypeTag(zcu) == .Union);28649 assert(union_ty.zigTypeTag(zcu) == .@"union");
2865028650
28651 const union_ptr_ty = sema.typeOf(union_ptr);28651 const union_ptr_ty = sema.typeOf(union_ptr);
28652 const union_ptr_info = union_ptr_ty.ptrInfo(zcu);28652 const union_ptr_info = union_ptr_ty.ptrInfo(zcu);
...@@ -28673,7 +28673,7 @@ fn unionFieldPtr(...@@ -28673,7 +28673,7 @@ fn unionFieldPtr(
28673 });28673 });
28674 const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_ty).enumFieldIndex(field_name, zcu).?);28674 const enum_field_index: u32 = @intCast(Type.fromInterned(union_obj.enum_tag_ty).enumFieldIndex(field_name, zcu).?);
2867528675
28676 if (initializing and field_ty.zigTypeTag(zcu) == .NoReturn) {28676 if (initializing and field_ty.zigTypeTag(zcu) == .noreturn) {
28677 const msg = msg: {28677 const msg = msg: {
28678 const msg = try sema.errMsg(src, "cannot initialize 'noreturn' field of union", .{});28678 const msg = try sema.errMsg(src, "cannot initialize 'noreturn' field of union", .{});
28679 errdefer msg.destroy(sema.gpa);28679 errdefer msg.destroy(sema.gpa);
...@@ -28736,7 +28736,7 @@ fn unionFieldPtr(...@@ -28736,7 +28736,7 @@ fn unionFieldPtr(
28736 const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_val);28736 const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_val);
28737 try sema.panicInactiveUnionField(block, src, active_tag, wanted_tag);28737 try sema.panicInactiveUnionField(block, src, active_tag, wanted_tag);
28738 }28738 }
28739 if (field_ty.zigTypeTag(zcu) == .NoReturn) {28739 if (field_ty.zigTypeTag(zcu) == .noreturn) {
28740 _ = try block.addNoOp(.unreach);28740 _ = try block.addNoOp(.unreach);
28741 return .unreachable_value;28741 return .unreachable_value;
28742 }28742 }
...@@ -28755,7 +28755,7 @@ fn unionFieldVal(...@@ -28755,7 +28755,7 @@ fn unionFieldVal(
28755 const pt = sema.pt;28755 const pt = sema.pt;
28756 const zcu = pt.zcu;28756 const zcu = pt.zcu;
28757 const ip = &zcu.intern_pool;28757 const ip = &zcu.intern_pool;
28758 assert(union_ty.zigTypeTag(zcu) == .Union);28758 assert(union_ty.zigTypeTag(zcu) == .@"union");
2875928759
28760 try union_ty.resolveFields(pt);28760 try union_ty.resolveFields(pt);
28761 const union_obj = zcu.typeToUnion(union_ty).?;28761 const union_obj = zcu.typeToUnion(union_ty).?;
...@@ -28811,7 +28811,7 @@ fn unionFieldVal(...@@ -28811,7 +28811,7 @@ fn unionFieldVal(
28811 const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_byval);28811 const active_tag = try block.addTyOp(.get_union_tag, Type.fromInterned(union_obj.enum_tag_ty), union_byval);
28812 try sema.panicInactiveUnionField(block, src, active_tag, wanted_tag);28812 try sema.panicInactiveUnionField(block, src, active_tag, wanted_tag);
28813 }28813 }
28814 if (field_ty.zigTypeTag(zcu) == .NoReturn) {28814 if (field_ty.zigTypeTag(zcu) == .noreturn) {
28815 _ = try block.addNoOp(.unreach);28815 _ = try block.addNoOp(.unreach);
28816 return .unreachable_value;28816 return .unreachable_value;
28817 }28817 }
...@@ -28835,14 +28835,14 @@ fn elemPtr(...@@ -28835,14 +28835,14 @@ fn elemPtr(
28835 const indexable_ptr_ty = sema.typeOf(indexable_ptr);28835 const indexable_ptr_ty = sema.typeOf(indexable_ptr);
2883628836
28837 const indexable_ty = switch (indexable_ptr_ty.zigTypeTag(zcu)) {28837 const indexable_ty = switch (indexable_ptr_ty.zigTypeTag(zcu)) {
28838 .Pointer => indexable_ptr_ty.childType(zcu),28838 .pointer => indexable_ptr_ty.childType(zcu),
28839 else => return sema.fail(block, indexable_ptr_src, "expected pointer, found '{}'", .{indexable_ptr_ty.fmt(pt)}),28839 else => return sema.fail(block, indexable_ptr_src, "expected pointer, found '{}'", .{indexable_ptr_ty.fmt(pt)}),
28840 };28840 };
28841 try checkIndexable(sema, block, src, indexable_ty);28841 try checkIndexable(sema, block, src, indexable_ty);
2884228842
28843 const elem_ptr = switch (indexable_ty.zigTypeTag(zcu)) {28843 const elem_ptr = switch (indexable_ty.zigTypeTag(zcu)) {
28844 .Array, .Vector => try sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init, oob_safety),28844 .array, .vector => try sema.elemPtrArray(block, src, indexable_ptr_src, indexable_ptr, elem_index_src, elem_index, init, oob_safety),
28845 .Struct => blk: {28845 .@"struct" => blk: {
28846 // Tuple field access.28846 // Tuple field access.
28847 const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{28847 const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{
28848 .needed_comptime_reason = "tuple field access index must be comptime-known",28848 .needed_comptime_reason = "tuple field access index must be comptime-known",
...@@ -28898,8 +28898,8 @@ fn elemPtrOneLayerOnly(...@@ -28898,8 +28898,8 @@ fn elemPtrOneLayerOnly(
28898 .One => {28898 .One => {
28899 const child_ty = indexable_ty.childType(zcu);28899 const child_ty = indexable_ty.childType(zcu);
28900 const elem_ptr = switch (child_ty.zigTypeTag(zcu)) {28900 const elem_ptr = switch (child_ty.zigTypeTag(zcu)) {
28901 .Array, .Vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety),28901 .array, .vector => try sema.elemPtrArray(block, src, indexable_src, indexable, elem_index_src, elem_index, init, oob_safety),
28902 .Struct => blk: {28902 .@"struct" => blk: {
28903 assert(child_ty.isTuple(zcu));28903 assert(child_ty.isTuple(zcu));
28904 const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{28904 const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{
28905 .needed_comptime_reason = "tuple field access index must be comptime-known",28905 .needed_comptime_reason = "tuple field access index must be comptime-known",
...@@ -28936,7 +28936,7 @@ fn elemVal(...@@ -28936,7 +28936,7 @@ fn elemVal(
28936 const elem_index = try sema.coerce(block, Type.usize, elem_index_uncasted, elem_index_src);28936 const elem_index = try sema.coerce(block, Type.usize, elem_index_uncasted, elem_index_src);
2893728937
28938 switch (indexable_ty.zigTypeTag(zcu)) {28938 switch (indexable_ty.zigTypeTag(zcu)) {
28939 .Pointer => switch (indexable_ty.ptrSize(zcu)) {28939 .pointer => switch (indexable_ty.ptrSize(zcu)) {
28940 .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),28940 .Slice => return sema.elemValSlice(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28941 .Many, .C => {28941 .Many, .C => {
28942 const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable);28942 const maybe_indexable_val = try sema.resolveDefinedValue(block, indexable_src, indexable);
...@@ -28963,7 +28963,7 @@ fn elemVal(...@@ -28963,7 +28963,7 @@ fn elemVal(
28963 .One => {28963 .One => {
28964 arr_sent: {28964 arr_sent: {
28965 const inner_ty = indexable_ty.childType(zcu);28965 const inner_ty = indexable_ty.childType(zcu);
28966 if (inner_ty.zigTypeTag(zcu) != .Array) break :arr_sent;28966 if (inner_ty.zigTypeTag(zcu) != .array) break :arr_sent;
28967 const sentinel = inner_ty.sentinel(zcu) orelse break :arr_sent;28967 const sentinel = inner_ty.sentinel(zcu) orelse break :arr_sent;
28968 const index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index) orelse break :arr_sent;28968 const index_val = try sema.resolveDefinedValue(block, elem_index_src, elem_index) orelse break :arr_sent;
28969 const index = try sema.usizeCast(block, src, try index_val.toUnsignedIntSema(pt));28969 const index = try sema.usizeCast(block, src, try index_val.toUnsignedIntSema(pt));
...@@ -28974,12 +28974,12 @@ fn elemVal(...@@ -28974,12 +28974,12 @@ fn elemVal(
28974 return sema.analyzeLoad(block, indexable_src, elem_ptr, elem_index_src);28974 return sema.analyzeLoad(block, indexable_src, elem_ptr, elem_index_src);
28975 },28975 },
28976 },28976 },
28977 .Array => return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),28977 .array => return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety),
28978 .Vector => {28978 .vector => {
28979 // TODO: If the index is a vector, the result should be a vector.28979 // TODO: If the index is a vector, the result should be a vector.
28980 return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety);28980 return sema.elemValArray(block, src, indexable_src, indexable, elem_index_src, elem_index, oob_safety);
28981 },28981 },
28982 .Struct => {28982 .@"struct" => {
28983 // Tuple field access.28983 // Tuple field access.
28984 const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{28984 const index_val = try sema.resolveConstDefinedValue(block, elem_index_src, elem_index, .{
28985 .needed_comptime_reason = "tuple field access index must be comptime-known",28985 .needed_comptime_reason = "tuple field access index must be comptime-known",
...@@ -29448,7 +29448,7 @@ fn coerceExtra(...@@ -29448,7 +29448,7 @@ fn coerceExtra(
29448 }29448 }
2944929449
29450 switch (dest_ty.zigTypeTag(zcu)) {29450 switch (dest_ty.zigTypeTag(zcu)) {
29451 .Optional => optional: {29451 .optional => optional: {
29452 if (maybe_inst_val) |val| {29452 if (maybe_inst_val) |val| {
29453 // undefined sets the optional bit also to undefined.29453 // undefined sets the optional bit also to undefined.
29454 if (val.toIntern() == .undef) {29454 if (val.toIntern() == .undef) {
...@@ -29472,7 +29472,7 @@ fn coerceExtra(...@@ -29472,7 +29472,7 @@ fn coerceExtra(
29472 anyopaque_check: {29472 anyopaque_check: {
29473 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional;29473 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional;
29474 const elem_ty = inst_ty.elemType2(zcu);29474 const elem_ty = inst_ty.elemType2(zcu);
29475 if (elem_ty.zigTypeTag(zcu) == .Pointer or elem_ty.isPtrLikeOptional(zcu)) {29475 if (elem_ty.zigTypeTag(zcu) == .pointer or elem_ty.isPtrLikeOptional(zcu)) {
29476 in_memory_result = .{ .double_ptr_to_anyopaque = .{29476 in_memory_result = .{ .double_ptr_to_anyopaque = .{
29477 .actual = inst_ty,29477 .actual = inst_ty,
29478 .wanted = dest_ty,29478 .wanted = dest_ty,
...@@ -29499,11 +29499,11 @@ fn coerceExtra(...@@ -29499,11 +29499,11 @@ fn coerceExtra(
29499 };29499 };
29500 return try sema.wrapOptional(block, dest_ty, intermediate, inst_src);29500 return try sema.wrapOptional(block, dest_ty, intermediate, inst_src);
29501 },29501 },
29502 .Pointer => pointer: {29502 .pointer => pointer: {
29503 const dest_info = dest_ty.ptrInfo(zcu);29503 const dest_info = dest_ty.ptrInfo(zcu);
2950429504
29505 // Function body to function pointer.29505 // Function body to function pointer.
29506 if (inst_ty.zigTypeTag(zcu) == .Fn) {29506 if (inst_ty.zigTypeTag(zcu) == .@"fn") {
29507 const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);29507 const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);
29508 const fn_nav = switch (zcu.intern_pool.indexToKey(fn_val.toIntern())) {29508 const fn_nav = switch (zcu.intern_pool.indexToKey(fn_val.toIntern())) {
29509 .func => |f| f.owner_nav,29509 .func => |f| f.owner_nav,
...@@ -29521,7 +29521,7 @@ fn coerceExtra(...@@ -29521,7 +29521,7 @@ fn coerceExtra(
29521 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;29521 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
29522 const ptr_elem_ty = inst_ty.childType(zcu);29522 const ptr_elem_ty = inst_ty.childType(zcu);
29523 const array_ty = Type.fromInterned(dest_info.child);29523 const array_ty = Type.fromInterned(dest_info.child);
29524 if (array_ty.zigTypeTag(zcu) != .Array) break :single_item;29524 if (array_ty.zigTypeTag(zcu) != .array) break :single_item;
29525 const array_elem_ty = array_ty.childType(zcu);29525 const array_elem_ty = array_ty.childType(zcu);
29526 if (array_ty.arrayLen(zcu) != 1) break :single_item;29526 if (array_ty.arrayLen(zcu) != 1) break :single_item;
29527 const dest_is_mut = !dest_info.flags.is_const;29527 const dest_is_mut = !dest_info.flags.is_const;
...@@ -29537,7 +29537,7 @@ fn coerceExtra(...@@ -29537,7 +29537,7 @@ fn coerceExtra(
29537 if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr;29537 if (!inst_ty.isSinglePointer(zcu)) break :src_array_ptr;
29538 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;29538 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
29539 const array_ty = inst_ty.childType(zcu);29539 const array_ty = inst_ty.childType(zcu);
29540 if (array_ty.zigTypeTag(zcu) != .Array) break :src_array_ptr;29540 if (array_ty.zigTypeTag(zcu) != .array) break :src_array_ptr;
29541 const array_elem_type = array_ty.childType(zcu);29541 const array_elem_type = array_ty.childType(zcu);
29542 const dest_is_mut = !dest_info.flags.is_const;29542 const dest_is_mut = !dest_info.flags.is_const;
2954329543
...@@ -29612,10 +29612,10 @@ fn coerceExtra(...@@ -29612,10 +29612,10 @@ fn coerceExtra(
2961229612
29613 // cast from *T and [*]T to *anyopaque29613 // cast from *T and [*]T to *anyopaque
29614 // but don't do it if the source type is a double pointer29614 // but don't do it if the source type is a double pointer
29615 if (dest_info.child == .anyopaque_type and inst_ty.zigTypeTag(zcu) == .Pointer) to_anyopaque: {29615 if (dest_info.child == .anyopaque_type and inst_ty.zigTypeTag(zcu) == .pointer) to_anyopaque: {
29616 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;29616 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer;
29617 const elem_ty = inst_ty.elemType2(zcu);29617 const elem_ty = inst_ty.elemType2(zcu);
29618 if (elem_ty.zigTypeTag(zcu) == .Pointer or elem_ty.isPtrLikeOptional(zcu)) {29618 if (elem_ty.zigTypeTag(zcu) == .pointer or elem_ty.isPtrLikeOptional(zcu)) {
29619 in_memory_result = .{ .double_ptr_to_anyopaque = .{29619 in_memory_result = .{ .double_ptr_to_anyopaque = .{
29620 .actual = inst_ty,29620 .actual = inst_ty,
29621 .wanted = dest_ty,29621 .wanted = dest_ty,
...@@ -29636,19 +29636,19 @@ fn coerceExtra(...@@ -29636,19 +29636,19 @@ fn coerceExtra(
29636 switch (dest_info.flags.size) {29636 switch (dest_info.flags.size) {
29637 // coercion to C pointer29637 // coercion to C pointer
29638 .C => switch (inst_ty.zigTypeTag(zcu)) {29638 .C => switch (inst_ty.zigTypeTag(zcu)) {
29639 .Null => return Air.internedToRef(try pt.intern(.{ .ptr = .{29639 .null => return Air.internedToRef(try pt.intern(.{ .ptr = .{
29640 .ty = dest_ty.toIntern(),29640 .ty = dest_ty.toIntern(),
29641 .base_addr = .int,29641 .base_addr = .int,
29642 .byte_offset = 0,29642 .byte_offset = 0,
29643 } })),29643 } })),
29644 .ComptimeInt => {29644 .comptime_int => {
29645 const addr = sema.coerceExtra(block, Type.usize, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) {29645 const addr = sema.coerceExtra(block, Type.usize, inst, inst_src, .{ .report_err = false }) catch |err| switch (err) {
29646 error.NotCoercible => break :pointer,29646 error.NotCoercible => break :pointer,
29647 else => |e| return e,29647 else => |e| return e,
29648 };29648 };
29649 return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src);29649 return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src);
29650 },29650 },
29651 .Int => {29651 .int => {
29652 const ptr_size_ty = switch (inst_ty.intInfo(zcu).signedness) {29652 const ptr_size_ty = switch (inst_ty.intInfo(zcu).signedness) {
29653 .signed => Type.isize,29653 .signed => Type.isize,
29654 .unsigned => Type.usize,29654 .unsigned => Type.usize,
...@@ -29663,7 +29663,7 @@ fn coerceExtra(...@@ -29663,7 +29663,7 @@ fn coerceExtra(
29663 };29663 };
29664 return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src);29664 return try sema.coerceCompatiblePtrs(block, dest_ty, addr, inst_src);
29665 },29665 },
29666 .Pointer => p: {29666 .pointer => p: {
29667 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p;29667 if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :p;
29668 const inst_info = inst_ty.ptrInfo(zcu);29668 const inst_info = inst_ty.ptrInfo(zcu);
29669 switch (try sema.coerceInMemoryAllowed(29669 switch (try sema.coerceInMemoryAllowed(
...@@ -29693,7 +29693,7 @@ fn coerceExtra(...@@ -29693,7 +29693,7 @@ fn coerceExtra(
29693 else => {},29693 else => {},
29694 },29694 },
29695 .One => switch (Type.fromInterned(dest_info.child).zigTypeTag(zcu)) {29695 .One => switch (Type.fromInterned(dest_info.child).zigTypeTag(zcu)) {
29696 .Union => {29696 .@"union" => {
29697 // pointer to anonymous struct to pointer to union29697 // pointer to anonymous struct to pointer to union
29698 if (inst_ty.isSinglePointer(zcu) and29698 if (inst_ty.isSinglePointer(zcu) and
29699 inst_ty.childType(zcu).isAnonStruct(zcu) and29699 inst_ty.childType(zcu).isAnonStruct(zcu) and
...@@ -29702,7 +29702,7 @@ fn coerceExtra(...@@ -29702,7 +29702,7 @@ fn coerceExtra(
29702 return sema.coerceAnonStructToUnionPtrs(block, dest_ty, dest_ty_src, inst, inst_src);29702 return sema.coerceAnonStructToUnionPtrs(block, dest_ty, dest_ty_src, inst, inst_src);
29703 }29703 }
29704 },29704 },
29705 .Struct => {29705 .@"struct" => {
29706 // pointer to anonymous struct to pointer to struct29706 // pointer to anonymous struct to pointer to struct
29707 if (inst_ty.isSinglePointer(zcu) and29707 if (inst_ty.isSinglePointer(zcu) and
29708 inst_ty.childType(zcu).isAnonStruct(zcu) and29708 inst_ty.childType(zcu).isAnonStruct(zcu) and
...@@ -29714,7 +29714,7 @@ fn coerceExtra(...@@ -29714,7 +29714,7 @@ fn coerceExtra(
29714 };29714 };
29715 }29715 }
29716 },29716 },
29717 .Array => {29717 .array => {
29718 // pointer to tuple to pointer to array29718 // pointer to tuple to pointer to array
29719 if (inst_ty.isSinglePointer(zcu) and29719 if (inst_ty.isSinglePointer(zcu) and
29720 inst_ty.childType(zcu).isTuple(zcu) and29720 inst_ty.childType(zcu).isTuple(zcu) and
...@@ -29726,7 +29726,7 @@ fn coerceExtra(...@@ -29726,7 +29726,7 @@ fn coerceExtra(
29726 else => {},29726 else => {},
29727 },29727 },
29728 .Slice => to_slice: {29728 .Slice => to_slice: {
29729 if (inst_ty.zigTypeTag(zcu) == .Array) {29729 if (inst_ty.zigTypeTag(zcu) == .array) {
29730 return sema.fail(29730 return sema.fail(
29731 block,29731 block,
29732 inst_src,29732 inst_src,
...@@ -29795,10 +29795,10 @@ fn coerceExtra(...@@ -29795,10 +29795,10 @@ fn coerceExtra(
29795 },29795 },
29796 }29796 }
29797 },29797 },
29798 .Int, .ComptimeInt => switch (inst_ty.zigTypeTag(zcu)) {29798 .int, .comptime_int => switch (inst_ty.zigTypeTag(zcu)) {
29799 .Float, .ComptimeFloat => float: {29799 .float, .comptime_float => float: {
29800 const val = maybe_inst_val orelse {29800 const val = maybe_inst_val orelse {
29801 if (dest_ty.zigTypeTag(zcu) == .ComptimeInt) {29801 if (dest_ty.zigTypeTag(zcu) == .comptime_int) {
29802 if (!opts.report_err) return error.NotCoercible;29802 if (!opts.report_err) return error.NotCoercible;
29803 return sema.failWithNeededComptime(block, inst_src, .{29803 return sema.failWithNeededComptime(block, inst_src, .{
29804 .needed_comptime_reason = "value being casted to 'comptime_int' must be comptime-known",29804 .needed_comptime_reason = "value being casted to 'comptime_int' must be comptime-known",
...@@ -29809,7 +29809,7 @@ fn coerceExtra(...@@ -29809,7 +29809,7 @@ fn coerceExtra(
29809 const result_val = try sema.intFromFloat(block, inst_src, val, inst_ty, dest_ty, .exact);29809 const result_val = try sema.intFromFloat(block, inst_src, val, inst_ty, dest_ty, .exact);
29810 return Air.internedToRef(result_val.toIntern());29810 return Air.internedToRef(result_val.toIntern());
29811 },29811 },
29812 .Int, .ComptimeInt => {29812 .int, .comptime_int => {
29813 if (maybe_inst_val) |val| {29813 if (maybe_inst_val) |val| {
29814 // comptime-known integer to other number29814 // comptime-known integer to other number
29815 if (!(try sema.intFitsInType(val, dest_ty, null))) {29815 if (!(try sema.intFitsInType(val, dest_ty, null))) {
...@@ -29824,7 +29824,7 @@ fn coerceExtra(...@@ -29824,7 +29824,7 @@ fn coerceExtra(
29824 else => unreachable,29824 else => unreachable,
29825 };29825 };
29826 }29826 }
29827 if (dest_ty.zigTypeTag(zcu) == .ComptimeInt) {29827 if (dest_ty.zigTypeTag(zcu) == .comptime_int) {
29828 if (!opts.report_err) return error.NotCoercible;29828 if (!opts.report_err) return error.NotCoercible;
29829 if (opts.no_cast_to_comptime_int) return inst;29829 if (opts.no_cast_to_comptime_int) return inst;
29830 return sema.failWithNeededComptime(block, inst_src, .{29830 return sema.failWithNeededComptime(block, inst_src, .{
...@@ -29845,13 +29845,13 @@ fn coerceExtra(...@@ -29845,13 +29845,13 @@ fn coerceExtra(
29845 },29845 },
29846 else => {},29846 else => {},
29847 },29847 },
29848 .Float, .ComptimeFloat => switch (inst_ty.zigTypeTag(zcu)) {29848 .float, .comptime_float => switch (inst_ty.zigTypeTag(zcu)) {
29849 .ComptimeFloat => {29849 .comptime_float => {
29850 const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);29850 const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);
29851 const result_val = try val.floatCast(dest_ty, pt);29851 const result_val = try val.floatCast(dest_ty, pt);
29852 return Air.internedToRef(result_val.toIntern());29852 return Air.internedToRef(result_val.toIntern());
29853 },29853 },
29854 .Float => {29854 .float => {
29855 if (maybe_inst_val) |val| {29855 if (maybe_inst_val) |val| {
29856 const result_val = try val.floatCast(dest_ty, pt);29856 const result_val = try val.floatCast(dest_ty, pt);
29857 if (!val.eql(try result_val.floatCast(inst_ty, pt), inst_ty, zcu)) {29857 if (!val.eql(try result_val.floatCast(inst_ty, pt), inst_ty, zcu)) {
...@@ -29863,7 +29863,7 @@ fn coerceExtra(...@@ -29863,7 +29863,7 @@ fn coerceExtra(
29863 );29863 );
29864 }29864 }
29865 return Air.internedToRef(result_val.toIntern());29865 return Air.internedToRef(result_val.toIntern());
29866 } else if (dest_ty.zigTypeTag(zcu) == .ComptimeFloat) {29866 } else if (dest_ty.zigTypeTag(zcu) == .comptime_float) {
29867 if (!opts.report_err) return error.NotCoercible;29867 if (!opts.report_err) return error.NotCoercible;
29868 return sema.failWithNeededComptime(block, inst_src, .{29868 return sema.failWithNeededComptime(block, inst_src, .{
29869 .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known",29869 .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known",
...@@ -29878,9 +29878,9 @@ fn coerceExtra(...@@ -29878,9 +29878,9 @@ fn coerceExtra(
29878 return block.addTyOp(.fpext, dest_ty, inst);29878 return block.addTyOp(.fpext, dest_ty, inst);
29879 }29879 }
29880 },29880 },
29881 .Int, .ComptimeInt => int: {29881 .int, .comptime_int => int: {
29882 const val = maybe_inst_val orelse {29882 const val = maybe_inst_val orelse {
29883 if (dest_ty.zigTypeTag(zcu) == .ComptimeFloat) {29883 if (dest_ty.zigTypeTag(zcu) == .comptime_float) {
29884 if (!opts.report_err) return error.NotCoercible;29884 if (!opts.report_err) return error.NotCoercible;
29885 return sema.failWithNeededComptime(block, inst_src, .{29885 return sema.failWithNeededComptime(block, inst_src, .{
29886 .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known",29886 .needed_comptime_reason = "value being casted to 'comptime_float' must be comptime-known",
...@@ -29903,8 +29903,8 @@ fn coerceExtra(...@@ -29903,8 +29903,8 @@ fn coerceExtra(
29903 },29903 },
29904 else => {},29904 else => {},
29905 },29905 },
29906 .Enum => switch (inst_ty.zigTypeTag(zcu)) {29906 .@"enum" => switch (inst_ty.zigTypeTag(zcu)) {
29907 .EnumLiteral => {29907 .enum_literal => {
29908 // enum literal to enum29908 // enum literal to enum
29909 const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);29909 const val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);
29910 const string = zcu.intern_pool.indexToKey(val.toIntern()).enum_literal;29910 const string = zcu.intern_pool.indexToKey(val.toIntern()).enum_literal;
...@@ -29915,7 +29915,7 @@ fn coerceExtra(...@@ -29915,7 +29915,7 @@ fn coerceExtra(
29915 };29915 };
29916 return Air.internedToRef((try pt.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern());29916 return Air.internedToRef((try pt.enumValueFieldIndex(dest_ty, @intCast(field_index))).toIntern());
29917 },29917 },
29918 .Union => blk: {29918 .@"union" => blk: {
29919 // union to its own tag type29919 // union to its own tag type
29920 const union_tag_ty = inst_ty.unionTagType(zcu) orelse break :blk;29920 const union_tag_ty = inst_ty.unionTagType(zcu) orelse break :blk;
29921 if (union_tag_ty.eql(dest_ty, zcu)) {29921 if (union_tag_ty.eql(dest_ty, zcu)) {
...@@ -29924,8 +29924,8 @@ fn coerceExtra(...@@ -29924,8 +29924,8 @@ fn coerceExtra(
29924 },29924 },
29925 else => {},29925 else => {},
29926 },29926 },
29927 .ErrorUnion => switch (inst_ty.zigTypeTag(zcu)) {29927 .error_union => switch (inst_ty.zigTypeTag(zcu)) {
29928 .ErrorUnion => eu: {29928 .error_union => eu: {
29929 if (maybe_inst_val) |inst_val| {29929 if (maybe_inst_val) |inst_val| {
29930 switch (inst_val.toIntern()) {29930 switch (inst_val.toIntern()) {
29931 .undef => return pt.undefRef(dest_ty),29931 .undef => return pt.undefRef(dest_ty),
...@@ -29952,7 +29952,7 @@ fn coerceExtra(...@@ -29952,7 +29952,7 @@ fn coerceExtra(
29952 }29952 }
29953 }29953 }
29954 },29954 },
29955 .ErrorSet => {29955 .error_set => {
29956 // E to E!T29956 // E to E!T
29957 return sema.wrapErrorUnionSet(block, dest_ty, inst, inst_src);29957 return sema.wrapErrorUnionSet(block, dest_ty, inst, inst_src);
29958 },29958 },
...@@ -29971,17 +29971,17 @@ fn coerceExtra(...@@ -29971,17 +29971,17 @@ fn coerceExtra(
29971 };29971 };
29972 },29972 },
29973 },29973 },
29974 .Union => switch (inst_ty.zigTypeTag(zcu)) {29974 .@"union" => switch (inst_ty.zigTypeTag(zcu)) {
29975 .Enum, .EnumLiteral => return sema.coerceEnumToUnion(block, dest_ty, dest_ty_src, inst, inst_src),29975 .@"enum", .enum_literal => return sema.coerceEnumToUnion(block, dest_ty, dest_ty_src, inst, inst_src),
29976 .Struct => {29976 .@"struct" => {
29977 if (inst_ty.isAnonStruct(zcu)) {29977 if (inst_ty.isAnonStruct(zcu)) {
29978 return sema.coerceAnonStructToUnion(block, dest_ty, dest_ty_src, inst, inst_src);29978 return sema.coerceAnonStructToUnion(block, dest_ty, dest_ty_src, inst, inst_src);
29979 }29979 }
29980 },29980 },
29981 else => {},29981 else => {},
29982 },29982 },
29983 .Array => switch (inst_ty.zigTypeTag(zcu)) {29983 .array => switch (inst_ty.zigTypeTag(zcu)) {
29984 .Array => array_to_array: {29984 .array => array_to_array: {
29985 // Array coercions are allowed only if the child is IMC and the sentinel is unchanged or removed.29985 // Array coercions are allowed only if the child is IMC and the sentinel is unchanged or removed.
29986 if (.ok != try sema.coerceInMemoryAllowed(29986 if (.ok != try sema.coerceInMemoryAllowed(
29987 block,29987 block,
...@@ -30005,8 +30005,8 @@ fn coerceExtra(...@@ -30005,8 +30005,8 @@ fn coerceExtra(
3000530005
30006 return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src);30006 return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src);
30007 },30007 },
30008 .Vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src),30008 .vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src),
30009 .Struct => {30009 .@"struct" => {
30010 if (inst == .empty_struct) {30010 if (inst == .empty_struct) {
30011 return sema.arrayInitEmpty(block, inst_src, dest_ty);30011 return sema.arrayInitEmpty(block, inst_src, dest_ty);
30012 }30012 }
...@@ -30016,16 +30016,16 @@ fn coerceExtra(...@@ -30016,16 +30016,16 @@ fn coerceExtra(
30016 },30016 },
30017 else => {},30017 else => {},
30018 },30018 },
30019 .Vector => switch (inst_ty.zigTypeTag(zcu)) {30019 .vector => switch (inst_ty.zigTypeTag(zcu)) {
30020 .Array, .Vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src),30020 .array, .vector => return sema.coerceArrayLike(block, dest_ty, dest_ty_src, inst, inst_src),
30021 .Struct => {30021 .@"struct" => {
30022 if (inst_ty.isTuple(zcu)) {30022 if (inst_ty.isTuple(zcu)) {
30023 return sema.coerceTupleToArray(block, dest_ty, dest_ty_src, inst, inst_src);30023 return sema.coerceTupleToArray(block, dest_ty, dest_ty_src, inst, inst_src);
30024 }30024 }
30025 },30025 },
30026 else => {},30026 else => {},
30027 },30027 },
30028 .Struct => blk: {30028 .@"struct" => blk: {
30029 if (inst == .empty_struct) {30029 if (inst == .empty_struct) {
30030 return sema.structInitEmpty(block, dest_ty, dest_ty_src, inst_src);30030 return sema.structInitEmpty(block, dest_ty, dest_ty_src, inst_src);
30031 }30031 }
...@@ -30046,7 +30046,7 @@ fn coerceExtra(...@@ -30046,7 +30046,7 @@ fn coerceExtra(
3004630046
30047 if (!opts.report_err) return error.NotCoercible;30047 if (!opts.report_err) return error.NotCoercible;
3004830048
30049 if (opts.is_ret and dest_ty.zigTypeTag(zcu) == .NoReturn) {30049 if (opts.is_ret and dest_ty.zigTypeTag(zcu) == .noreturn) {
30050 const msg = msg: {30050 const msg = msg: {
30051 const msg = try sema.errMsg(inst_src, "function declared 'noreturn' returns", .{});30051 const msg = try sema.errMsg(inst_src, "function declared 'noreturn' returns", .{});
30052 errdefer msg.destroy(sema.gpa);30052 errdefer msg.destroy(sema.gpa);
...@@ -30066,7 +30066,7 @@ fn coerceExtra(...@@ -30066,7 +30066,7 @@ fn coerceExtra(
30066 errdefer msg.destroy(sema.gpa);30066 errdefer msg.destroy(sema.gpa);
3006730067
30068 // E!T to T30068 // E!T to T
30069 if (inst_ty.zigTypeTag(zcu) == .ErrorUnion and30069 if (inst_ty.zigTypeTag(zcu) == .error_union and
30070 (try sema.coerceInMemoryAllowed(block, inst_ty.errorUnionPayload(zcu), dest_ty, false, target, dest_ty_src, inst_src, maybe_inst_val)) == .ok)30070 (try sema.coerceInMemoryAllowed(block, inst_ty.errorUnionPayload(zcu), dest_ty, false, target, dest_ty_src, inst_src, maybe_inst_val)) == .ok)
30071 {30071 {
30072 try sema.errNote(inst_src, msg, "cannot convert error union to payload type", .{});30072 try sema.errNote(inst_src, msg, "cannot convert error union to payload type", .{});
...@@ -30074,7 +30074,7 @@ fn coerceExtra(...@@ -30074,7 +30074,7 @@ fn coerceExtra(
30074 }30074 }
3007530075
30076 // ?T to T30076 // ?T to T
30077 if (inst_ty.zigTypeTag(zcu) == .Optional and30077 if (inst_ty.zigTypeTag(zcu) == .optional and
30078 (try sema.coerceInMemoryAllowed(block, inst_ty.optionalChild(zcu), dest_ty, false, target, dest_ty_src, inst_src, maybe_inst_val)) == .ok)30078 (try sema.coerceInMemoryAllowed(block, inst_ty.optionalChild(zcu), dest_ty, false, target, dest_ty_src, inst_src, maybe_inst_val)) == .ok)
30079 {30079 {
30080 try sema.errNote(inst_src, msg, "cannot convert optional to payload type", .{});30080 try sema.errNote(inst_src, msg, "cannot convert optional to payload type", .{});
...@@ -30515,7 +30515,7 @@ pub fn coerceInMemoryAllowed(...@@ -30515,7 +30515,7 @@ pub fn coerceInMemoryAllowed(
30515 const src_tag = src_ty.zigTypeTag(zcu);30515 const src_tag = src_ty.zigTypeTag(zcu);
3051630516
30517 // Differently-named integers with the same number of bits.30517 // Differently-named integers with the same number of bits.
30518 if (dest_tag == .Int and src_tag == .Int) {30518 if (dest_tag == .int and src_tag == .int) {
30519 const dest_info = dest_ty.intInfo(zcu);30519 const dest_info = dest_ty.intInfo(zcu);
30520 const src_info = src_ty.intInfo(zcu);30520 const src_info = src_ty.intInfo(zcu);
3052130521
...@@ -30540,7 +30540,7 @@ pub fn coerceInMemoryAllowed(...@@ -30540,7 +30540,7 @@ pub fn coerceInMemoryAllowed(
30540 }30540 }
3054130541
30542 // Comptime int to regular int.30542 // Comptime int to regular int.
30543 if (dest_tag == .Int and src_tag == .ComptimeInt) {30543 if (dest_tag == .int and src_tag == .comptime_int) {
30544 if (src_val) |val| {30544 if (src_val) |val| {
30545 if (!(try sema.intFitsInType(val, dest_ty, null))) {30545 if (!(try sema.intFitsInType(val, dest_ty, null))) {
30546 return .{ .comptime_int_not_coercible = .{ .wanted = dest_ty, .actual = val } };30546 return .{ .comptime_int_not_coercible = .{ .wanted = dest_ty, .actual = val } };
...@@ -30549,7 +30549,7 @@ pub fn coerceInMemoryAllowed(...@@ -30549,7 +30549,7 @@ pub fn coerceInMemoryAllowed(
30549 }30549 }
3055030550
30551 // Differently-named floats with the same number of bits.30551 // Differently-named floats with the same number of bits.
30552 if (dest_tag == .Float and src_tag == .Float) {30552 if (dest_tag == .float and src_tag == .float) {
30553 const dest_bits = dest_ty.floatBits(target);30553 const dest_bits = dest_ty.floatBits(target);
30554 const src_bits = src_ty.floatBits(target);30554 const src_bits = src_ty.floatBits(target);
30555 if (dest_bits == src_bits) {30555 if (dest_bits == src_bits) {
...@@ -30572,12 +30572,12 @@ pub fn coerceInMemoryAllowed(...@@ -30572,12 +30572,12 @@ pub fn coerceInMemoryAllowed(
30572 }30572 }
3057330573
30574 // Functions30574 // Functions
30575 if (dest_tag == .Fn and src_tag == .Fn) {30575 if (dest_tag == .@"fn" and src_tag == .@"fn") {
30576 return try sema.coerceInMemoryAllowedFns(block, dest_ty, src_ty, target, dest_src, src_src);30576 return try sema.coerceInMemoryAllowedFns(block, dest_ty, src_ty, target, dest_src, src_src);
30577 }30577 }
3057830578
30579 // Error Unions30579 // Error Unions
30580 if (dest_tag == .ErrorUnion and src_tag == .ErrorUnion) {30580 if (dest_tag == .error_union and src_tag == .error_union) {
30581 const dest_payload = dest_ty.errorUnionPayload(zcu);30581 const dest_payload = dest_ty.errorUnionPayload(zcu);
30582 const src_payload = src_ty.errorUnionPayload(zcu);30582 const src_payload = src_ty.errorUnionPayload(zcu);
30583 const child = try sema.coerceInMemoryAllowed(block, dest_payload, src_payload, dest_is_mut, target, dest_src, src_src, null);30583 const child = try sema.coerceInMemoryAllowed(block, dest_payload, src_payload, dest_is_mut, target, dest_src, src_src, null);
...@@ -30592,12 +30592,12 @@ pub fn coerceInMemoryAllowed(...@@ -30592,12 +30592,12 @@ pub fn coerceInMemoryAllowed(
30592 }30592 }
3059330593
30594 // Error Sets30594 // Error Sets
30595 if (dest_tag == .ErrorSet and src_tag == .ErrorSet) {30595 if (dest_tag == .error_set and src_tag == .error_set) {
30596 return try sema.coerceInMemoryAllowedErrorSets(block, dest_ty, src_ty, dest_src, src_src);30596 return try sema.coerceInMemoryAllowedErrorSets(block, dest_ty, src_ty, dest_src, src_src);
30597 }30597 }
3059830598
30599 // Arrays30599 // Arrays
30600 if (dest_tag == .Array and src_tag == .Array) {30600 if (dest_tag == .array and src_tag == .array) {
30601 const dest_info = dest_ty.arrayInfo(zcu);30601 const dest_info = dest_ty.arrayInfo(zcu);
30602 const src_info = src_ty.arrayInfo(zcu);30602 const src_info = src_ty.arrayInfo(zcu);
30603 if (dest_info.len != src_info.len) {30603 if (dest_info.len != src_info.len) {
...@@ -30638,7 +30638,7 @@ pub fn coerceInMemoryAllowed(...@@ -30638,7 +30638,7 @@ pub fn coerceInMemoryAllowed(
30638 }30638 }
3063930639
30640 // Vectors30640 // Vectors
30641 if (dest_tag == .Vector and src_tag == .Vector) {30641 if (dest_tag == .vector and src_tag == .vector) {
30642 const dest_len = dest_ty.vectorLen(zcu);30642 const dest_len = dest_ty.vectorLen(zcu);
30643 const src_len = src_ty.vectorLen(zcu);30643 const src_len = src_ty.vectorLen(zcu);
30644 if (dest_len != src_len) {30644 if (dest_len != src_len) {
...@@ -30663,8 +30663,8 @@ pub fn coerceInMemoryAllowed(...@@ -30663,8 +30663,8 @@ pub fn coerceInMemoryAllowed(
30663 }30663 }
3066430664
30665 // Arrays <-> Vectors30665 // Arrays <-> Vectors
30666 if ((dest_tag == .Vector and src_tag == .Array) or30666 if ((dest_tag == .vector and src_tag == .array) or
30667 (dest_tag == .Array and src_tag == .Vector))30667 (dest_tag == .array and src_tag == .vector))
30668 {30668 {
30669 const dest_len = dest_ty.arrayLen(zcu);30669 const dest_len = dest_ty.arrayLen(zcu);
30670 const src_len = src_ty.arrayLen(zcu);30670 const src_len = src_ty.arrayLen(zcu);
...@@ -30686,7 +30686,7 @@ pub fn coerceInMemoryAllowed(...@@ -30686,7 +30686,7 @@ pub fn coerceInMemoryAllowed(
30686 } };30686 } };
30687 }30687 }
3068830688
30689 if (dest_tag == .Array) {30689 if (dest_tag == .array) {
30690 const dest_info = dest_ty.arrayInfo(zcu);30690 const dest_info = dest_ty.arrayInfo(zcu);
30691 if (dest_info.sentinel != null) {30691 if (dest_info.sentinel != null) {
30692 return InMemoryCoercionResult{ .array_sentinel = .{30692 return InMemoryCoercionResult{ .array_sentinel = .{
...@@ -30707,7 +30707,7 @@ pub fn coerceInMemoryAllowed(...@@ -30707,7 +30707,7 @@ pub fn coerceInMemoryAllowed(
30707 }30707 }
3070830708
30709 // Optionals30709 // Optionals
30710 if (dest_tag == .Optional and src_tag == .Optional) {30710 if (dest_tag == .optional and src_tag == .optional) {
30711 if ((maybe_dest_ptr_ty != null) != (maybe_src_ptr_ty != null)) {30711 if ((maybe_dest_ptr_ty != null) != (maybe_src_ptr_ty != null)) {
30712 return InMemoryCoercionResult{ .optional_shape = .{30712 return InMemoryCoercionResult{ .optional_shape = .{
30713 .actual = src_ty,30713 .actual = src_ty,
...@@ -31000,7 +31000,7 @@ fn coerceInMemoryAllowedPtrs(...@@ -31000,7 +31000,7 @@ fn coerceInMemoryAllowedPtrs(
31000 if (child != .ok) allow: {31000 if (child != .ok) allow: {
31001 // As a special case, we also allow coercing `*[n:s]T` to `*[n]T`, akin to dropping the sentinel from a slice.31001 // As a special case, we also allow coercing `*[n:s]T` to `*[n]T`, akin to dropping the sentinel from a slice.
31002 // `*[n:s]T` cannot coerce in memory to `*[n]T` since they have different sizes.31002 // `*[n:s]T` cannot coerce in memory to `*[n]T` since they have different sizes.
31003 if (src_child.zigTypeTag(zcu) == .Array and dest_child.zigTypeTag(zcu) == .Array and31003 if (src_child.zigTypeTag(zcu) == .array and dest_child.zigTypeTag(zcu) == .array and
31004 src_child.sentinel(zcu) != null and dest_child.sentinel(zcu) == null and31004 src_child.sentinel(zcu) != null and dest_child.sentinel(zcu) == null and
31005 .ok == try sema.coerceInMemoryAllowed(block, dest_child.childType(zcu), src_child.childType(zcu), !dest_info.flags.is_const, target, dest_src, src_src, null))31005 .ok == try sema.coerceInMemoryAllowed(block, dest_child.childType(zcu), src_child.childType(zcu), !dest_info.flags.is_const, target, dest_src, src_src, null))
31006 {31006 {
...@@ -31095,19 +31095,19 @@ fn coerceVarArgParam(...@@ -31095,19 +31095,19 @@ fn coerceVarArgParam(
31095 const uncasted_ty = sema.typeOf(inst);31095 const uncasted_ty = sema.typeOf(inst);
31096 const coerced = switch (uncasted_ty.zigTypeTag(zcu)) {31096 const coerced = switch (uncasted_ty.zigTypeTag(zcu)) {
31097 // TODO consider casting to c_int/f64 if they fit31097 // TODO consider casting to c_int/f64 if they fit
31098 .ComptimeInt, .ComptimeFloat => return sema.fail(31098 .comptime_int, .comptime_float => return sema.fail(
31099 block,31099 block,
31100 inst_src,31100 inst_src,
31101 "integer and float literals passed to variadic function must be casted to a fixed-size number type",31101 "integer and float literals passed to variadic function must be casted to a fixed-size number type",
31102 .{},31102 .{},
31103 ),31103 ),
31104 .Fn => fn_ptr: {31104 .@"fn" => fn_ptr: {
31105 const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);31105 const fn_val = try sema.resolveConstDefinedValue(block, LazySrcLoc.unneeded, inst, undefined);
31106 const fn_nav = zcu.funcInfo(fn_val.toIntern()).owner_nav;31106 const fn_nav = zcu.funcInfo(fn_val.toIntern()).owner_nav;
31107 break :fn_ptr try sema.analyzeNavRef(inst_src, fn_nav);31107 break :fn_ptr try sema.analyzeNavRef(inst_src, fn_nav);
31108 },31108 },
31109 .Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}),31109 .array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}),
31110 .Float => float: {31110 .float => float: {
31111 const target = zcu.getTarget();31111 const target = zcu.getTarget();
31112 const double_bits = target.cTypeBitSize(.double);31112 const double_bits = target.cTypeBitSize(.double);
31113 const inst_bits = uncasted_ty.floatBits(target);31113 const inst_bits = uncasted_ty.floatBits(target);
...@@ -31202,7 +31202,7 @@ fn storePtr2(...@@ -31202,7 +31202,7 @@ fn storePtr2(
31202 // this code does not handle tuple-to-struct coercion which requires dealing with missing31202 // this code does not handle tuple-to-struct coercion which requires dealing with missing
31203 // fields.31203 // fields.
31204 const operand_ty = sema.typeOf(uncasted_operand);31204 const operand_ty = sema.typeOf(uncasted_operand);
31205 if (operand_ty.isTuple(zcu) and elem_ty.zigTypeTag(zcu) == .Array) {31205 if (operand_ty.isTuple(zcu) and elem_ty.zigTypeTag(zcu) == .array) {
31206 const field_count = operand_ty.structFieldCount(zcu);31206 const field_count = operand_ty.structFieldCount(zcu);
31207 var i: u32 = 0;31207 var i: u32 = 0;
31208 while (i < field_count) : (i += 1) {31208 while (i < field_count) : (i += 1) {
...@@ -31397,16 +31397,16 @@ fn obtainBitCastedVectorPtr(sema: *Sema, ptr: Air.Inst.Ref) ?Air.Inst.Ref {...@@ -31397,16 +31397,16 @@ fn obtainBitCastedVectorPtr(sema: *Sema, ptr: Air.Inst.Ref) ?Air.Inst.Ref {
31397 const pt = sema.pt;31397 const pt = sema.pt;
31398 const zcu = pt.zcu;31398 const zcu = pt.zcu;
31399 const array_ty = sema.typeOf(ptr).childType(zcu);31399 const array_ty = sema.typeOf(ptr).childType(zcu);
31400 if (array_ty.zigTypeTag(zcu) != .Array) return null;31400 if (array_ty.zigTypeTag(zcu) != .array) return null;
31401 var ptr_ref = ptr;31401 var ptr_ref = ptr;
31402 var ptr_inst = ptr_ref.toIndex() orelse return null;31402 var ptr_inst = ptr_ref.toIndex() orelse return null;
31403 const air_datas = sema.air_instructions.items(.data);31403 const air_datas = sema.air_instructions.items(.data);
31404 const air_tags = sema.air_instructions.items(.tag);31404 const air_tags = sema.air_instructions.items(.tag);
31405 const vector_ty = while (air_tags[@intFromEnum(ptr_inst)] == .bitcast) {31405 const vector_ty = while (air_tags[@intFromEnum(ptr_inst)] == .bitcast) {
31406 ptr_ref = air_datas[@intFromEnum(ptr_inst)].ty_op.operand;31406 ptr_ref = air_datas[@intFromEnum(ptr_inst)].ty_op.operand;
31407 if (!sema.isKnownZigType(ptr_ref, .Pointer)) return null;31407 if (!sema.isKnownZigType(ptr_ref, .pointer)) return null;
31408 const child_ty = sema.typeOf(ptr_ref).childType(zcu);31408 const child_ty = sema.typeOf(ptr_ref).childType(zcu);
31409 if (child_ty.zigTypeTag(zcu) == .Vector) break child_ty;31409 if (child_ty.zigTypeTag(zcu) == .vector) break child_ty;
31410 ptr_inst = ptr_ref.toIndex() orelse return null;31410 ptr_inst = ptr_ref.toIndex() orelse return null;
31411 } else return null;31411 } else return null;
3141231412
...@@ -31504,7 +31504,7 @@ fn bitCast(...@@ -31504,7 +31504,7 @@ fn bitCast(
31504 if (try sema.resolveValue(inst)) |val| {31504 if (try sema.resolveValue(inst)) |val| {
31505 if (val.isUndef(zcu))31505 if (val.isUndef(zcu))
31506 return pt.undefRef(dest_ty);31506 return pt.undefRef(dest_ty);
31507 if (old_ty.zigTypeTag(zcu) == .ErrorSet and dest_ty.zigTypeTag(zcu) == .ErrorSet) {31507 if (old_ty.zigTypeTag(zcu) == .error_set and dest_ty.zigTypeTag(zcu) == .error_set) {
31508 // Special case: we sometimes call `bitCast` on error set values, but they31508 // Special case: we sometimes call `bitCast` on error set values, but they
31509 // don't have a well-defined layout, so we can't use `bitCastVal` on them.31509 // don't have a well-defined layout, so we can't use `bitCastVal` on them.
31510 return Air.internedToRef((try pt.getCoerced(val, dest_ty)).toIntern());31510 return Air.internedToRef((try pt.getCoerced(val, dest_ty)).toIntern());
...@@ -31548,7 +31548,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul...@@ -31548,7 +31548,7 @@ fn checkPtrAttributes(sema: *Sema, dest_ty: Type, inst_ty: Type, in_memory_resul
31548 const zcu = pt.zcu;31548 const zcu = pt.zcu;
31549 const dest_info = dest_ty.ptrInfo(zcu);31549 const dest_info = dest_ty.ptrInfo(zcu);
31550 const inst_info = inst_ty.ptrInfo(zcu);31550 const inst_info = inst_ty.ptrInfo(zcu);
31551 const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .Array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or31551 const len0 = (Type.fromInterned(inst_info.child).zigTypeTag(zcu) == .array and (Type.fromInterned(inst_info.child).arrayLenIncludingSentinel(zcu) == 0 or
31552 (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .C and dest_info.flags.size != .Many))) or31552 (Type.fromInterned(inst_info.child).arrayLen(zcu) == 0 and dest_info.sentinel == .none and dest_info.flags.size != .C and dest_info.flags.size != .Many))) or
31553 (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0);31553 (Type.fromInterned(inst_info.child).isTuple(zcu) and Type.fromInterned(inst_info.child).structFieldCount(zcu) == 0);
3155431554
...@@ -31615,9 +31615,9 @@ fn coerceCompatiblePtrs(...@@ -31615,9 +31615,9 @@ fn coerceCompatiblePtrs(
31615 );31615 );
31616 }31616 }
31617 try sema.requireRuntimeBlock(block, inst_src, null);31617 try sema.requireRuntimeBlock(block, inst_src, null);
31618 const inst_allows_zero = inst_ty.zigTypeTag(zcu) != .Pointer or inst_ty.ptrAllowsZero(zcu);31618 const inst_allows_zero = inst_ty.zigTypeTag(zcu) != .pointer or inst_ty.ptrAllowsZero(zcu);
31619 if (block.wantSafety() and inst_allows_zero and !dest_ty.ptrAllowsZero(zcu) and31619 if (block.wantSafety() and inst_allows_zero and !dest_ty.ptrAllowsZero(zcu) and
31620 (try dest_ty.elemType2(zcu).hasRuntimeBitsSema(pt) or dest_ty.elemType2(zcu).zigTypeTag(zcu) == .Fn))31620 (try dest_ty.elemType2(zcu).hasRuntimeBitsSema(pt) or dest_ty.elemType2(zcu).zigTypeTag(zcu) == .@"fn"))
31621 {31621 {
31622 const actual_ptr = if (inst_ty.isSlice(zcu))31622 const actual_ptr = if (inst_ty.isSlice(zcu))
31623 try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty)31623 try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty)
...@@ -31674,7 +31674,7 @@ fn coerceEnumToUnion(...@@ -31674,7 +31674,7 @@ fn coerceEnumToUnion(
31674 const union_obj = zcu.typeToUnion(union_ty).?;31674 const union_obj = zcu.typeToUnion(union_ty).?;
31675 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);31675 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
31676 try field_ty.resolveFields(pt);31676 try field_ty.resolveFields(pt);
31677 if (field_ty.zigTypeTag(zcu) == .NoReturn) {31677 if (field_ty.zigTypeTag(zcu) == .noreturn) {
31678 const msg = msg: {31678 const msg = msg: {
31679 const msg = try sema.errMsg(inst_src, "cannot initialize 'noreturn' field of union", .{});31679 const msg = try sema.errMsg(inst_src, "cannot initialize 'noreturn' field of union", .{});
31680 errdefer msg.destroy(sema.gpa);31680 errdefer msg.destroy(sema.gpa);
...@@ -31729,7 +31729,7 @@ fn coerceEnumToUnion(...@@ -31729,7 +31729,7 @@ fn coerceEnumToUnion(
31729 errdefer if (msg) |some| some.destroy(sema.gpa);31729 errdefer if (msg) |some| some.destroy(sema.gpa);
3173031730
31731 for (union_obj.field_types.get(ip), 0..) |field_ty, field_index| {31731 for (union_obj.field_types.get(ip), 0..) |field_ty, field_index| {
31732 if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .NoReturn) {31732 if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .noreturn) {
31733 const err_msg = msg orelse try sema.errMsg(31733 const err_msg = msg orelse try sema.errMsg(
31734 inst_src,31734 inst_src,
31735 "runtime coercion from enum '{}' to union '{}' which has a 'noreturn' field",31735 "runtime coercion from enum '{}' to union '{}' which has a 'noreturn' field",
...@@ -31911,7 +31911,7 @@ fn coerceArrayLike(...@@ -31911,7 +31911,7 @@ fn coerceArrayLike(
31911 if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and (try sema.resolveValue(inst)) == null) {31911 if (dest_ty.isVector(zcu) and inst_ty.isVector(zcu) and (try sema.resolveValue(inst)) == null) {
31912 const inst_elem_ty = inst_ty.childType(zcu);31912 const inst_elem_ty = inst_ty.childType(zcu);
31913 switch (dest_elem_ty.zigTypeTag(zcu)) {31913 switch (dest_elem_ty.zigTypeTag(zcu)) {
31914 .Int => if (inst_elem_ty.isInt(zcu)) {31914 .int => if (inst_elem_ty.isInt(zcu)) {
31915 // integer widening31915 // integer widening
31916 const dst_info = dest_elem_ty.intInfo(zcu);31916 const dst_info = dest_elem_ty.intInfo(zcu);
31917 const src_info = inst_elem_ty.intInfo(zcu);31917 const src_info = inst_elem_ty.intInfo(zcu);
...@@ -31923,7 +31923,7 @@ fn coerceArrayLike(...@@ -31923,7 +31923,7 @@ fn coerceArrayLike(
31923 return block.addTyOp(.intcast, dest_ty, inst);31923 return block.addTyOp(.intcast, dest_ty, inst);
31924 }31924 }
31925 },31925 },
31926 .Float => if (inst_elem_ty.isRuntimeFloat()) {31926 .float => if (inst_elem_ty.isRuntimeFloat()) {
31927 // float widening31927 // float widening
31928 const src_bits = inst_elem_ty.floatBits(target);31928 const src_bits = inst_elem_ty.floatBits(target);
31929 const dst_bits = dest_elem_ty.floatBits(target);31929 const dst_bits = dest_elem_ty.floatBits(target);
...@@ -32504,10 +32504,10 @@ fn analyzeLoad(...@@ -32504,10 +32504,10 @@ fn analyzeLoad(
32504 const zcu = pt.zcu;32504 const zcu = pt.zcu;
32505 const ptr_ty = sema.typeOf(ptr);32505 const ptr_ty = sema.typeOf(ptr);
32506 const elem_ty = switch (ptr_ty.zigTypeTag(zcu)) {32506 const elem_ty = switch (ptr_ty.zigTypeTag(zcu)) {
32507 .Pointer => ptr_ty.childType(zcu),32507 .pointer => ptr_ty.childType(zcu),
32508 else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(pt)}),32508 else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(pt)}),
32509 };32509 };
32510 if (elem_ty.zigTypeTag(zcu) == .Opaque) {32510 if (elem_ty.zigTypeTag(zcu) == .@"opaque") {
32511 return sema.fail(block, ptr_src, "cannot load opaque type '{}'", .{elem_ty.fmt(pt)});32511 return sema.fail(block, ptr_src, "cannot load opaque type '{}'", .{elem_ty.fmt(pt)});
32512 }32512 }
3251332513
...@@ -32621,10 +32621,10 @@ fn analyzeIsNull(...@@ -32621,10 +32621,10 @@ fn analyzeIsNull(
3262132621
32622 const inverted_non_null_res: Air.Inst.Ref = if (invert_logic) .bool_true else .bool_false;32622 const inverted_non_null_res: Air.Inst.Ref = if (invert_logic) .bool_true else .bool_false;
32623 const operand_ty = sema.typeOf(operand);32623 const operand_ty = sema.typeOf(operand);
32624 if (operand_ty.zigTypeTag(zcu) == .Optional and operand_ty.optionalChild(zcu).zigTypeTag(zcu) == .NoReturn) {32624 if (operand_ty.zigTypeTag(zcu) == .optional and operand_ty.optionalChild(zcu).zigTypeTag(zcu) == .noreturn) {
32625 return inverted_non_null_res;32625 return inverted_non_null_res;
32626 }32626 }
32627 if (operand_ty.zigTypeTag(zcu) != .Optional and !operand_ty.isPtrLikeOptional(zcu)) {32627 if (operand_ty.zigTypeTag(zcu) != .optional and !operand_ty.isPtrLikeOptional(zcu)) {
32628 return inverted_non_null_res;32628 return inverted_non_null_res;
32629 }32629 }
32630 try sema.requireRuntimeBlock(block, src, null);32630 try sema.requireRuntimeBlock(block, src, null);
...@@ -32641,13 +32641,13 @@ fn analyzePtrIsNonErrComptimeOnly(...@@ -32641,13 +32641,13 @@ fn analyzePtrIsNonErrComptimeOnly(
32641 const pt = sema.pt;32641 const pt = sema.pt;
32642 const zcu = pt.zcu;32642 const zcu = pt.zcu;
32643 const ptr_ty = sema.typeOf(operand);32643 const ptr_ty = sema.typeOf(operand);
32644 assert(ptr_ty.zigTypeTag(zcu) == .Pointer);32644 assert(ptr_ty.zigTypeTag(zcu) == .pointer);
32645 const child_ty = ptr_ty.childType(zcu);32645 const child_ty = ptr_ty.childType(zcu);
3264632646
32647 const child_tag = child_ty.zigTypeTag(zcu);32647 const child_tag = child_ty.zigTypeTag(zcu);
32648 if (child_tag != .ErrorSet and child_tag != .ErrorUnion) return .bool_true;32648 if (child_tag != .error_set and child_tag != .error_union) return .bool_true;
32649 if (child_tag == .ErrorSet) return .bool_false;32649 if (child_tag == .error_set) return .bool_false;
32650 assert(child_tag == .ErrorUnion);32650 assert(child_tag == .error_union);
3265132651
32652 _ = block;32652 _ = block;
32653 _ = src;32653 _ = src;
...@@ -32666,12 +32666,12 @@ fn analyzeIsNonErrComptimeOnly(...@@ -32666,12 +32666,12 @@ fn analyzeIsNonErrComptimeOnly(
32666 const ip = &zcu.intern_pool;32666 const ip = &zcu.intern_pool;
32667 const operand_ty = sema.typeOf(operand);32667 const operand_ty = sema.typeOf(operand);
32668 const ot = operand_ty.zigTypeTag(zcu);32668 const ot = operand_ty.zigTypeTag(zcu);
32669 if (ot != .ErrorSet and ot != .ErrorUnion) return .bool_true;32669 if (ot != .error_set and ot != .error_union) return .bool_true;
32670 if (ot == .ErrorSet) return .bool_false;32670 if (ot == .error_set) return .bool_false;
32671 assert(ot == .ErrorUnion);32671 assert(ot == .error_union);
3267232672
32673 const payload_ty = operand_ty.errorUnionPayload(zcu);32673 const payload_ty = operand_ty.errorUnionPayload(zcu);
32674 if (payload_ty.zigTypeTag(zcu) == .NoReturn) {32674 if (payload_ty.zigTypeTag(zcu) == .noreturn) {
32675 return .bool_false;32675 return .bool_false;
32676 }32676 }
3267732677
...@@ -32828,7 +32828,7 @@ fn analyzeSlice(...@@ -32828,7 +32828,7 @@ fn analyzeSlice(
32828 // the slice operand to be a pointer. In the case of a non-array, it will be a double pointer.32828 // the slice operand to be a pointer. In the case of a non-array, it will be a double pointer.
32829 const ptr_ptr_ty = sema.typeOf(ptr_ptr);32829 const ptr_ptr_ty = sema.typeOf(ptr_ptr);
32830 const ptr_ptr_child_ty = switch (ptr_ptr_ty.zigTypeTag(zcu)) {32830 const ptr_ptr_child_ty = switch (ptr_ptr_ty.zigTypeTag(zcu)) {
32831 .Pointer => ptr_ptr_ty.childType(zcu),32831 .pointer => ptr_ptr_ty.childType(zcu),
32832 else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ptr_ty.fmt(pt)}),32832 else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ptr_ty.fmt(pt)}),
32833 };32833 };
3283432834
...@@ -32838,15 +32838,15 @@ fn analyzeSlice(...@@ -32838,15 +32838,15 @@ fn analyzeSlice(
32838 var elem_ty: Type = undefined;32838 var elem_ty: Type = undefined;
32839 var ptr_sentinel: ?Value = null;32839 var ptr_sentinel: ?Value = null;
32840 switch (ptr_ptr_child_ty.zigTypeTag(zcu)) {32840 switch (ptr_ptr_child_ty.zigTypeTag(zcu)) {
32841 .Array => {32841 .array => {
32842 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);32842 ptr_sentinel = ptr_ptr_child_ty.sentinel(zcu);
32843 elem_ty = ptr_ptr_child_ty.childType(zcu);32843 elem_ty = ptr_ptr_child_ty.childType(zcu);
32844 },32844 },
32845 .Pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) {32845 .pointer => switch (ptr_ptr_child_ty.ptrSize(zcu)) {
32846 .One => {32846 .One => {
32847 const double_child_ty = ptr_ptr_child_ty.childType(zcu);32847 const double_child_ty = ptr_ptr_child_ty.childType(zcu);
32848 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);32848 ptr_or_slice = try sema.analyzeLoad(block, src, ptr_ptr, ptr_src);
32849 if (double_child_ty.zigTypeTag(zcu) == .Array) {32849 if (double_child_ty.zigTypeTag(zcu) == .array) {
32850 ptr_sentinel = double_child_ty.sentinel(zcu);32850 ptr_sentinel = double_child_ty.sentinel(zcu);
32851 slice_ty = ptr_ptr_child_ty;32851 slice_ty = ptr_ptr_child_ty;
32852 array_ty = double_child_ty;32852 array_ty = double_child_ty;
...@@ -32961,7 +32961,7 @@ fn analyzeSlice(...@@ -32961,7 +32961,7 @@ fn analyzeSlice(
3296132961
32962 const ptr = if (slice_ty.isSlice(zcu))32962 const ptr = if (slice_ty.isSlice(zcu))
32963 try sema.analyzeSlicePtr(block, ptr_src, ptr_or_slice, slice_ty)32963 try sema.analyzeSlicePtr(block, ptr_src, ptr_or_slice, slice_ty)
32964 else if (array_ty.zigTypeTag(zcu) == .Array) ptr: {32964 else if (array_ty.zigTypeTag(zcu) == .array) ptr: {
32965 var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type;32965 var manyptr_ty_key = zcu.intern_pool.indexToKey(slice_ty.toIntern()).ptr_type;
32966 assert(manyptr_ty_key.child == array_ty.toIntern());32966 assert(manyptr_ty_key.child == array_ty.toIntern());
32967 assert(manyptr_ty_key.flags.size == .One);32967 assert(manyptr_ty_key.flags.size == .One);
...@@ -32980,7 +32980,7 @@ fn analyzeSlice(...@@ -32980,7 +32980,7 @@ fn analyzeSlice(
32980 // we might learn of the length because it is a comptime-known slice value.32980 // we might learn of the length because it is a comptime-known slice value.
32981 var end_is_len = uncasted_end_opt == .none;32981 var end_is_len = uncasted_end_opt == .none;
32982 const end = e: {32982 const end = e: {
32983 if (array_ty.zigTypeTag(zcu) == .Array) {32983 if (array_ty.zigTypeTag(zcu) == .array) {
32984 const len_val = try pt.intValue(Type.usize, array_ty.arrayLen(zcu));32984 const len_val = try pt.intValue(Type.usize, array_ty.arrayLen(zcu));
3298532985
32986 if (!end_is_len) {32986 if (!end_is_len) {
...@@ -33215,7 +33215,7 @@ fn analyzeSlice(...@@ -33215,7 +33215,7 @@ fn analyzeSlice(
33215 }33215 }
3321633216
33217 bounds_check: {33217 bounds_check: {
33218 const actual_len = if (array_ty.zigTypeTag(zcu) == .Array)33218 const actual_len = if (array_ty.zigTypeTag(zcu) == .array)
33219 try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu))33219 try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu))
33220 else if (slice_ty.isSlice(zcu)) l: {33220 else if (slice_ty.isSlice(zcu)) l: {
33221 const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice);33221 const slice_len_inst = try block.addTyOp(.slice_len, Type.usize, ptr_or_slice);
...@@ -33273,7 +33273,7 @@ fn analyzeSlice(...@@ -33273,7 +33273,7 @@ fn analyzeSlice(
33273 }33273 }
3327433274
33275 // requirement: end <= len33275 // requirement: end <= len
33276 const opt_len_inst = if (array_ty.zigTypeTag(zcu) == .Array)33276 const opt_len_inst = if (array_ty.zigTypeTag(zcu) == .array)
33277 try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu))33277 try pt.intRef(Type.usize, array_ty.arrayLenIncludingSentinel(zcu))
33278 else if (slice_ty.isSlice(zcu)) blk: {33278 else if (slice_ty.isSlice(zcu)) blk: {
33279 if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| {33279 if (try sema.resolveDefinedValue(block, src, ptr_or_slice)) |slice_val| {
...@@ -33342,12 +33342,12 @@ fn cmpNumeric(...@@ -33342,12 +33342,12 @@ fn cmpNumeric(
33342 // One exception to heterogeneous comparison: comptime_float needs to33342 // One exception to heterogeneous comparison: comptime_float needs to
33343 // coerce to fixed-width float.33343 // coerce to fixed-width float.
3334433344
33345 const lhs = if (lhs_ty_tag == .ComptimeFloat and rhs_ty_tag == .Float)33345 const lhs = if (lhs_ty_tag == .comptime_float and rhs_ty_tag == .float)
33346 try sema.coerce(block, rhs_ty, uncasted_lhs, lhs_src)33346 try sema.coerce(block, rhs_ty, uncasted_lhs, lhs_src)
33347 else33347 else
33348 uncasted_lhs;33348 uncasted_lhs;
3334933349
33350 const rhs = if (lhs_ty_tag == .Float and rhs_ty_tag == .ComptimeFloat)33350 const rhs = if (lhs_ty_tag == .float and rhs_ty_tag == .comptime_float)
33351 try sema.coerce(block, lhs_ty, uncasted_rhs, rhs_src)33351 try sema.coerce(block, lhs_ty, uncasted_rhs, rhs_src)
33352 else33352 else
33353 uncasted_rhs;33353 uncasted_rhs;
...@@ -33356,11 +33356,11 @@ fn cmpNumeric(...@@ -33356,11 +33356,11 @@ fn cmpNumeric(
33356 if (try sema.resolveValue(lhs)) |lhs_val| {33356 if (try sema.resolveValue(lhs)) |lhs_val| {
33357 if (try sema.resolveValue(rhs)) |rhs_val| {33357 if (try sema.resolveValue(rhs)) |rhs_val| {
33358 // Compare ints: const vs. undefined (or vice versa)33358 // Compare ints: const vs. undefined (or vice versa)
33359 if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(zcu) and rhs_val.isUndef(zcu)) {33359 if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .comptime_int) and rhs_ty.isInt(zcu) and rhs_val.isUndef(zcu)) {
33360 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| {33360 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| {
33361 return if (res) .bool_true else .bool_false;33361 return if (res) .bool_true else .bool_false;
33362 }33362 }
33363 } else if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(zcu) and lhs_val.isUndef(zcu)) {33363 } else if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .comptime_int) and lhs_ty.isInt(zcu) and lhs_val.isUndef(zcu)) {
33364 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| {33364 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| {
33365 return if (res) .bool_true else .bool_false;33365 return if (res) .bool_true else .bool_false;
33366 }33366 }
...@@ -33377,7 +33377,7 @@ fn cmpNumeric(...@@ -33377,7 +33377,7 @@ fn cmpNumeric(
33377 else33377 else
33378 .bool_false;33378 .bool_false;
33379 } else {33379 } else {
33380 if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .ComptimeInt) and rhs_ty.isInt(zcu)) {33380 if (!lhs_val.isUndef(zcu) and (lhs_ty.isInt(zcu) or lhs_ty_tag == .comptime_int) and rhs_ty.isInt(zcu)) {
33381 // Compare ints: const vs. var33381 // Compare ints: const vs. var
33382 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| {33382 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(lhs_val), op, rhs_ty)) |res| {
33383 return if (res) .bool_true else .bool_false;33383 return if (res) .bool_true else .bool_false;
...@@ -33387,7 +33387,7 @@ fn cmpNumeric(...@@ -33387,7 +33387,7 @@ fn cmpNumeric(
33387 }33387 }
33388 } else {33388 } else {
33389 if (try sema.resolveValueResolveLazy(rhs)) |rhs_val| {33389 if (try sema.resolveValueResolveLazy(rhs)) |rhs_val| {
33390 if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .ComptimeInt) and lhs_ty.isInt(zcu)) {33390 if (!rhs_val.isUndef(zcu) and (rhs_ty.isInt(zcu) or rhs_ty_tag == .comptime_int) and lhs_ty.isInt(zcu)) {
33391 // Compare ints: var vs. const33391 // Compare ints: var vs. const
33392 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| {33392 if (try sema.compareIntsOnlyPossibleResult(try sema.resolveLazyValue(rhs_val), op.reverse(), lhs_ty)) |res| {
33393 return if (res) .bool_true else .bool_false;33393 return if (res) .bool_true else .bool_false;
...@@ -33407,11 +33407,11 @@ fn cmpNumeric(...@@ -33407,11 +33407,11 @@ fn cmpNumeric(
3340733407
33408 // For floats, emit a float comparison instruction.33408 // For floats, emit a float comparison instruction.
33409 const lhs_is_float = switch (lhs_ty_tag) {33409 const lhs_is_float = switch (lhs_ty_tag) {
33410 .Float, .ComptimeFloat => true,33410 .float, .comptime_float => true,
33411 else => false,33411 else => false,
33412 };33412 };
33413 const rhs_is_float = switch (rhs_ty_tag) {33413 const rhs_is_float = switch (rhs_ty_tag) {
33414 .Float, .ComptimeFloat => true,33414 .float, .comptime_float => true,
33415 else => false,33415 else => false,
33416 };33416 };
3341733417
...@@ -33419,9 +33419,9 @@ fn cmpNumeric(...@@ -33419,9 +33419,9 @@ fn cmpNumeric(
33419 // Smaller fixed-width floats coerce to larger fixed-width floats.33419 // Smaller fixed-width floats coerce to larger fixed-width floats.
33420 // comptime_float coerces to fixed-width float.33420 // comptime_float coerces to fixed-width float.
33421 const dest_ty = x: {33421 const dest_ty = x: {
33422 if (lhs_ty_tag == .ComptimeFloat) {33422 if (lhs_ty_tag == .comptime_float) {
33423 break :x rhs_ty;33423 break :x rhs_ty;
33424 } else if (rhs_ty_tag == .ComptimeFloat) {33424 } else if (rhs_ty_tag == .comptime_float) {
33425 break :x lhs_ty;33425 break :x lhs_ty;
33426 }33426 }
33427 if (lhs_ty.floatBits(target) >= rhs_ty.floatBits(target)) {33427 if (lhs_ty.floatBits(target) >= rhs_ty.floatBits(target)) {
...@@ -33691,8 +33691,8 @@ fn cmpVector(...@@ -33691,8 +33691,8 @@ fn cmpVector(
33691 const zcu = pt.zcu;33691 const zcu = pt.zcu;
33692 const lhs_ty = sema.typeOf(lhs);33692 const lhs_ty = sema.typeOf(lhs);
33693 const rhs_ty = sema.typeOf(rhs);33693 const rhs_ty = sema.typeOf(rhs);
33694 assert(lhs_ty.zigTypeTag(zcu) == .Vector);33694 assert(lhs_ty.zigTypeTag(zcu) == .vector);
33695 assert(rhs_ty.zigTypeTag(zcu) == .Vector);33695 assert(rhs_ty.zigTypeTag(zcu) == .vector);
33696 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);33696 try sema.checkVectorizableBinaryOperands(block, src, lhs_ty, rhs_ty, lhs_src, rhs_src);
3369733697
33698 const resolved_ty = try sema.resolvePeerTypes(block, src, &.{ lhs, rhs }, .{ .override = &.{ lhs_src, rhs_src } });33698 const resolved_ty = try sema.resolvePeerTypes(block, src, &.{ lhs, rhs }, .{ .override = &.{ lhs_src, rhs_src } });
...@@ -34005,22 +34005,22 @@ const PeerResolveStrategy = enum {...@@ -34005,22 +34005,22 @@ const PeerResolveStrategy = enum {
3400534005
34006 fn select(ty: Type, zcu: *Zcu) PeerResolveStrategy {34006 fn select(ty: Type, zcu: *Zcu) PeerResolveStrategy {
34007 return switch (ty.zigTypeTag(zcu)) {34007 return switch (ty.zigTypeTag(zcu)) {
34008 .Type, .Void, .Bool, .Opaque, .Frame, .AnyFrame => .exact,34008 .type, .void, .bool, .@"opaque", .frame, .@"anyframe" => .exact,
34009 .NoReturn, .Undefined => .unknown,34009 .noreturn, .undefined => .unknown,
34010 .Null => .nullable,34010 .null => .nullable,
34011 .ComptimeInt => .comptime_int,34011 .comptime_int => .comptime_int,
34012 .Int => .fixed_int,34012 .int => .fixed_int,
34013 .ComptimeFloat => .comptime_float,34013 .comptime_float => .comptime_float,
34014 .Float => .fixed_float,34014 .float => .fixed_float,
34015 .Pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr,34015 .pointer => if (ty.ptrInfo(zcu).flags.size == .C) .c_ptr else .ptr,
34016 .Array => .array,34016 .array => .array,
34017 .Vector => .vector,34017 .vector => .vector,
34018 .Optional => .optional,34018 .optional => .optional,
34019 .ErrorSet => .error_set,34019 .error_set => .error_set,
34020 .ErrorUnion => .error_union,34020 .error_union => .error_union,
34021 .EnumLiteral, .Enum, .Union => .enum_or_union,34021 .enum_literal, .@"enum", .@"union" => .enum_or_union,
34022 .Struct => if (ty.isTupleOrAnonStruct(zcu)) .coercible_struct else .exact,34022 .@"struct" => if (ty.isTupleOrAnonStruct(zcu)) .coercible_struct else .exact,
34023 .Fn => .func,34023 .@"fn" => .func,
34024 };34024 };
34025 }34025 }
34026};34026};
...@@ -34213,7 +34213,7 @@ fn resolvePeerTypesInner(...@@ -34213,7 +34213,7 @@ fn resolvePeerTypesInner(
34213 for (peer_tys) |*ty_ptr| {34213 for (peer_tys) |*ty_ptr| {
34214 const ty = ty_ptr.* orelse continue;34214 const ty = ty_ptr.* orelse continue;
34215 switch (ty.zigTypeTag(zcu)) {34215 switch (ty.zigTypeTag(zcu)) {
34216 .NoReturn, .Undefined => ty_ptr.* = null,34216 .noreturn, .undefined => ty_ptr.* = null,
34217 else => {},34217 else => {},
34218 }34218 }
34219 }34219 }
...@@ -34228,7 +34228,7 @@ fn resolvePeerTypesInner(...@@ -34228,7 +34228,7 @@ fn resolvePeerTypesInner(
34228 var final_set: ?Type = null;34228 var final_set: ?Type = null;
34229 for (peer_tys, 0..) |opt_ty, i| {34229 for (peer_tys, 0..) |opt_ty, i| {
34230 const ty = opt_ty orelse continue;34230 const ty = opt_ty orelse continue;
34231 if (ty.zigTypeTag(zcu) != .ErrorSet) return .{ .conflict = .{34231 if (ty.zigTypeTag(zcu) != .error_set) return .{ .conflict = .{
34232 .peer_idx_a = strat_reason,34232 .peer_idx_a = strat_reason,
34233 .peer_idx_b = i,34233 .peer_idx_b = i,
34234 } };34234 } };
...@@ -34246,12 +34246,12 @@ fn resolvePeerTypesInner(...@@ -34246,12 +34246,12 @@ fn resolvePeerTypesInner(
34246 for (peer_tys, peer_vals) |*ty_ptr, *val_ptr| {34246 for (peer_tys, peer_vals) |*ty_ptr, *val_ptr| {
34247 const ty = ty_ptr.* orelse continue;34247 const ty = ty_ptr.* orelse continue;
34248 const set_ty = switch (ty.zigTypeTag(zcu)) {34248 const set_ty = switch (ty.zigTypeTag(zcu)) {
34249 .ErrorSet => blk: {34249 .error_set => blk: {
34250 ty_ptr.* = null; // no payload to decide on34250 ty_ptr.* = null; // no payload to decide on
34251 val_ptr.* = null;34251 val_ptr.* = null;
34252 break :blk ty;34252 break :blk ty;
34253 },34253 },
34254 .ErrorUnion => blk: {34254 .error_union => blk: {
34255 const set_ty = ty.errorUnionSet(zcu);34255 const set_ty = ty.errorUnionSet(zcu);
34256 ty_ptr.* = ty.errorUnionPayload(zcu);34256 ty_ptr.* = ty.errorUnionPayload(zcu);
34257 if (val_ptr.*) |eu_val| switch (ip.indexToKey(eu_val.toIntern())) {34257 if (val_ptr.*) |eu_val| switch (ip.indexToKey(eu_val.toIntern())) {
...@@ -34300,11 +34300,11 @@ fn resolvePeerTypesInner(...@@ -34300,11 +34300,11 @@ fn resolvePeerTypesInner(
34300 for (peer_tys, peer_vals) |*ty_ptr, *val_ptr| {34300 for (peer_tys, peer_vals) |*ty_ptr, *val_ptr| {
34301 const ty = ty_ptr.* orelse continue;34301 const ty = ty_ptr.* orelse continue;
34302 switch (ty.zigTypeTag(zcu)) {34302 switch (ty.zigTypeTag(zcu)) {
34303 .Null => {34303 .null => {
34304 ty_ptr.* = null;34304 ty_ptr.* = null;
34305 val_ptr.* = null;34305 val_ptr.* = null;
34306 },34306 },
34307 .Optional => {34307 .optional => {
34308 ty_ptr.* = ty.optionalChild(zcu);34308 ty_ptr.* = ty.optionalChild(zcu);
34309 if (val_ptr.*) |opt_val| val_ptr.* = if (!opt_val.isUndef(zcu)) opt_val.optionalValue(zcu) else null;34309 if (val_ptr.*) |opt_val| val_ptr.* = if (!opt_val.isUndef(zcu)) opt_val.optionalValue(zcu) else null;
34310 },34310 },
...@@ -34482,8 +34482,8 @@ fn resolvePeerTypesInner(...@@ -34482,8 +34482,8 @@ fn resolvePeerTypesInner(
34482 for (peer_tys, peer_vals, 0..) |opt_ty, opt_val, i| {34482 for (peer_tys, peer_vals, 0..) |opt_ty, opt_val, i| {
34483 const ty = opt_ty orelse continue;34483 const ty = opt_ty orelse continue;
34484 switch (ty.zigTypeTag(zcu)) {34484 switch (ty.zigTypeTag(zcu)) {
34485 .ComptimeInt => continue, // comptime-known integers can always coerce to C pointers34485 .comptime_int => continue, // comptime-known integers can always coerce to C pointers
34486 .Int => {34486 .int => {
34487 if (opt_val != null) {34487 if (opt_val != null) {
34488 // Always allow the coercion for comptime-known ints34488 // Always allow the coercion for comptime-known ints
34489 continue;34489 continue;
...@@ -34494,7 +34494,7 @@ fn resolvePeerTypesInner(...@@ -34494,7 +34494,7 @@ fn resolvePeerTypesInner(
34494 if (bits <= ptr_bits) continue;34494 if (bits <= ptr_bits) continue;
34495 }34495 }
34496 },34496 },
34497 .Null => continue,34497 .null => continue,
34498 else => {},34498 else => {},
34499 }34499 }
3450034500
...@@ -34581,8 +34581,8 @@ fn resolvePeerTypesInner(...@@ -34581,8 +34581,8 @@ fn resolvePeerTypesInner(
34581 for (peer_tys, 0..) |opt_ty, i| {34581 for (peer_tys, 0..) |opt_ty, i| {
34582 const ty = opt_ty orelse continue;34582 const ty = opt_ty orelse continue;
34583 const peer_info: InternPool.Key.PtrType = switch (ty.zigTypeTag(zcu)) {34583 const peer_info: InternPool.Key.PtrType = switch (ty.zigTypeTag(zcu)) {
34584 .Pointer => ty.ptrInfo(zcu),34584 .pointer => ty.ptrInfo(zcu),
34585 .Fn => .{34585 .@"fn" => .{
34586 .child = ty.toIntern(),34586 .child = ty.toIntern(),
34587 .flags = .{34587 .flags = .{
34588 .address_space = target_util.defaultAddressSpace(target, .global_constant),34588 .address_space = target_util.defaultAddressSpace(target, .global_constant),
...@@ -34889,7 +34889,7 @@ fn resolvePeerTypesInner(...@@ -34889,7 +34889,7 @@ fn resolvePeerTypesInner(
34889 first_idx = i;34889 first_idx = i;
34890 continue;34890 continue;
34891 };34891 };
34892 if (ty.zigTypeTag(zcu) != .Fn) return .{ .conflict = .{34892 if (ty.zigTypeTag(zcu) != .@"fn") return .{ .conflict = .{
34893 .peer_idx_a = strat_reason,34893 .peer_idx_a = strat_reason,
34894 .peer_idx_b = i,34894 .peer_idx_b = i,
34895 } };34895 } };
...@@ -34918,7 +34918,7 @@ fn resolvePeerTypesInner(...@@ -34918,7 +34918,7 @@ fn resolvePeerTypesInner(
34918 for (peer_tys, 0..) |opt_ty, i| {34918 for (peer_tys, 0..) |opt_ty, i| {
34919 const ty = opt_ty orelse continue;34919 const ty = opt_ty orelse continue;
34920 switch (ty.zigTypeTag(zcu)) {34920 switch (ty.zigTypeTag(zcu)) {
34921 .EnumLiteral, .Enum, .Union => {},34921 .enum_literal, .@"enum", .@"union" => {},
34922 else => return .{ .conflict = .{34922 else => return .{ .conflict = .{
34923 .peer_idx_a = strat_reason,34923 .peer_idx_a = strat_reason,
34924 .peer_idx_b = i,34924 .peer_idx_b = i,
...@@ -34937,16 +34937,16 @@ fn resolvePeerTypesInner(...@@ -34937,16 +34937,16 @@ fn resolvePeerTypesInner(
34937 } };34937 } };
3493834938
34939 switch (cur_ty.zigTypeTag(zcu)) {34939 switch (cur_ty.zigTypeTag(zcu)) {
34940 .EnumLiteral => {34940 .enum_literal => {
34941 opt_cur_ty = ty;34941 opt_cur_ty = ty;
34942 cur_ty_idx = i;34942 cur_ty_idx = i;
34943 },34943 },
34944 .Enum => switch (ty.zigTypeTag(zcu)) {34944 .@"enum" => switch (ty.zigTypeTag(zcu)) {
34945 .EnumLiteral => {},34945 .enum_literal => {},
34946 .Enum => {34946 .@"enum" => {
34947 if (!ty.eql(cur_ty, zcu)) return generic_err;34947 if (!ty.eql(cur_ty, zcu)) return generic_err;
34948 },34948 },
34949 .Union => {34949 .@"union" => {
34950 const tag_ty = ty.unionTagTypeHypothetical(zcu);34950 const tag_ty = ty.unionTagTypeHypothetical(zcu);
34951 if (!tag_ty.eql(cur_ty, zcu)) return generic_err;34951 if (!tag_ty.eql(cur_ty, zcu)) return generic_err;
34952 opt_cur_ty = ty;34952 opt_cur_ty = ty;
...@@ -34954,13 +34954,13 @@ fn resolvePeerTypesInner(...@@ -34954,13 +34954,13 @@ fn resolvePeerTypesInner(
34954 },34954 },
34955 else => unreachable,34955 else => unreachable,
34956 },34956 },
34957 .Union => switch (ty.zigTypeTag(zcu)) {34957 .@"union" => switch (ty.zigTypeTag(zcu)) {
34958 .EnumLiteral => {},34958 .enum_literal => {},
34959 .Enum => {34959 .@"enum" => {
34960 const cur_tag_ty = cur_ty.unionTagTypeHypothetical(zcu);34960 const cur_tag_ty = cur_ty.unionTagTypeHypothetical(zcu);
34961 if (!ty.eql(cur_tag_ty, zcu)) return generic_err;34961 if (!ty.eql(cur_tag_ty, zcu)) return generic_err;
34962 },34962 },
34963 .Union => {34963 .@"union" => {
34964 if (!ty.eql(cur_ty, zcu)) return generic_err;34964 if (!ty.eql(cur_ty, zcu)) return generic_err;
34965 },34965 },
34966 else => unreachable,34966 else => unreachable,
...@@ -34975,7 +34975,7 @@ fn resolvePeerTypesInner(...@@ -34975,7 +34975,7 @@ fn resolvePeerTypesInner(
34975 for (peer_tys, 0..) |opt_ty, i| {34975 for (peer_tys, 0..) |opt_ty, i| {
34976 const ty = opt_ty orelse continue;34976 const ty = opt_ty orelse continue;
34977 switch (ty.zigTypeTag(zcu)) {34977 switch (ty.zigTypeTag(zcu)) {
34978 .ComptimeInt => {},34978 .comptime_int => {},
34979 else => return .{ .conflict = .{34979 else => return .{ .conflict = .{
34980 .peer_idx_a = strat_reason,34980 .peer_idx_a = strat_reason,
34981 .peer_idx_b = i,34981 .peer_idx_b = i,
...@@ -34989,7 +34989,7 @@ fn resolvePeerTypesInner(...@@ -34989,7 +34989,7 @@ fn resolvePeerTypesInner(
34989 for (peer_tys, 0..) |opt_ty, i| {34989 for (peer_tys, 0..) |opt_ty, i| {
34990 const ty = opt_ty orelse continue;34990 const ty = opt_ty orelse continue;
34991 switch (ty.zigTypeTag(zcu)) {34991 switch (ty.zigTypeTag(zcu)) {
34992 .ComptimeInt, .ComptimeFloat => {},34992 .comptime_int, .comptime_float => {},
34993 else => return .{ .conflict = .{34993 else => return .{ .conflict = .{
34994 .peer_idx_a = strat_reason,34994 .peer_idx_a = strat_reason,
34995 .peer_idx_b = i,34995 .peer_idx_b = i,
...@@ -35012,7 +35012,7 @@ fn resolvePeerTypesInner(...@@ -35012,7 +35012,7 @@ fn resolvePeerTypesInner(
3501235012
35013 const peer_tag = ty.zigTypeTag(zcu);35013 const peer_tag = ty.zigTypeTag(zcu);
35014 switch (peer_tag) {35014 switch (peer_tag) {
35015 .ComptimeInt => {35015 .comptime_int => {
35016 // If the value is undefined, we can't refine to a fixed-width int35016 // If the value is undefined, we can't refine to a fixed-width int
35017 if (opt_val == null or opt_val.?.isUndef(zcu)) return .{ .conflict = .{35017 if (opt_val == null or opt_val.?.isUndef(zcu)) return .{ .conflict = .{
35018 .peer_idx_a = strat_reason,35018 .peer_idx_a = strat_reason,
...@@ -35022,7 +35022,7 @@ fn resolvePeerTypesInner(...@@ -35022,7 +35022,7 @@ fn resolvePeerTypesInner(
35022 ptr_opt_val.* = try sema.resolveLazyValue(opt_val.?);35022 ptr_opt_val.* = try sema.resolveLazyValue(opt_val.?);
35023 continue;35023 continue;
35024 },35024 },
35025 .Int => {},35025 .int => {},
35026 else => return .{ .conflict = .{35026 else => return .{ .conflict = .{
35027 .peer_idx_a = strat_reason,35027 .peer_idx_a = strat_reason,
35028 .peer_idx_b = i,35028 .peer_idx_b = i,
...@@ -35091,14 +35091,14 @@ fn resolvePeerTypesInner(...@@ -35091,14 +35091,14 @@ fn resolvePeerTypesInner(
35091 for (peer_tys, peer_vals, 0..) |opt_ty, opt_val, i| {35091 for (peer_tys, peer_vals, 0..) |opt_ty, opt_val, i| {
35092 const ty = opt_ty orelse continue;35092 const ty = opt_ty orelse continue;
35093 switch (ty.zigTypeTag(zcu)) {35093 switch (ty.zigTypeTag(zcu)) {
35094 .ComptimeFloat, .ComptimeInt => {},35094 .comptime_float, .comptime_int => {},
35095 .Int => {35095 .int => {
35096 if (opt_val == null) return .{ .conflict = .{35096 if (opt_val == null) return .{ .conflict = .{
35097 .peer_idx_a = strat_reason,35097 .peer_idx_a = strat_reason,
35098 .peer_idx_b = i,35098 .peer_idx_b = i,
35099 } };35099 } };
35100 },35100 },
35101 .Float => {35101 .float => {
35102 if (opt_cur_ty) |cur_ty| {35102 if (opt_cur_ty) |cur_ty| {
35103 if (cur_ty.eql(ty, zcu)) continue;35103 if (cur_ty.eql(ty, zcu)) continue;
35104 // Recreate the type so we eliminate any c_longdouble35104 // Recreate the type so we eliminate any c_longdouble
...@@ -35330,11 +35330,11 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike {...@@ -35330,11 +35330,11 @@ fn typeIsArrayLike(sema: *Sema, ty: Type) ?ArrayLike {
35330 const pt = sema.pt;35330 const pt = sema.pt;
35331 const zcu = pt.zcu;35331 const zcu = pt.zcu;
35332 return switch (ty.zigTypeTag(zcu)) {35332 return switch (ty.zigTypeTag(zcu)) {
35333 .Array => .{35333 .array => .{
35334 .len = ty.arrayLen(zcu),35334 .len = ty.arrayLen(zcu),
35335 .elem_ty = ty.childType(zcu),35335 .elem_ty = ty.childType(zcu),
35336 },35336 },
35337 .Struct => {35337 .@"struct" => {
35338 const field_count = ty.structFieldCount(zcu);35338 const field_count = ty.structFieldCount(zcu);
35339 if (field_count == 0) return .{35339 if (field_count == 0) return .{
35340 .len = 0,35340 .len = 0,
...@@ -35625,7 +35625,7 @@ fn backingIntType(...@@ -35625,7 +35625,7 @@ fn backingIntType(
35625 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);35625 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
3562635626
35627 if (small.has_backing_int) {35627 if (small.has_backing_int) {
35628 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;35628 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len;
35629 const captures_len = if (small.has_captures_len) blk: {35629 const captures_len = if (small.has_captures_len) blk: {
35630 const captures_len = zir.extra[extra_index];35630 const captures_len = zir.extra[extra_index];
35631 extra_index += 1;35631 extra_index += 1;
...@@ -35700,12 +35700,12 @@ fn checkIndexable(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void {...@@ -35700,12 +35700,12 @@ fn checkIndexable(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void {
35700fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void {35700fn checkMemOperand(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !void {
35701 const pt = sema.pt;35701 const pt = sema.pt;
35702 const zcu = pt.zcu;35702 const zcu = pt.zcu;
35703 if (ty.zigTypeTag(zcu) == .Pointer) {35703 if (ty.zigTypeTag(zcu) == .pointer) {
35704 switch (ty.ptrSize(zcu)) {35704 switch (ty.ptrSize(zcu)) {
35705 .Slice, .Many, .C => return,35705 .Slice, .Many, .C => return,
35706 .One => {35706 .One => {
35707 const elem_ty = ty.childType(zcu);35707 const elem_ty = ty.childType(zcu);
35708 if (elem_ty.zigTypeTag(zcu) == .Array) return;35708 if (elem_ty.zigTypeTag(zcu) == .array) return;
35709 // TODO https://github.com/ziglang/zig/issues/1547935709 // TODO https://github.com/ziglang/zig/issues/15479
35710 // if (elem_ty.isTuple()) return;35710 // if (elem_ty.isTuple()) return;
35711 },35711 },
...@@ -35797,7 +35797,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {...@@ -35797,7 +35797,7 @@ pub fn resolveUnionLayout(sema: *Sema, ty: Type) SemaError!void {
35797 for (0..union_type.field_types.len) |field_index| {35797 for (0..union_type.field_types.len) |field_index| {
35798 const field_ty = Type.fromInterned(union_type.field_types.get(ip)[field_index]);35798 const field_ty = Type.fromInterned(union_type.field_types.get(ip)[field_index]);
3579935799
35800 if (try field_ty.comptimeOnlySema(pt) or field_ty.zigTypeTag(pt.zcu) == .NoReturn) continue; // TODO: should this affect alignment?35800 if (try field_ty.comptimeOnlySema(pt) or field_ty.zigTypeTag(pt.zcu) == .noreturn) continue; // TODO: should this affect alignment?
3580135801
35802 max_size = @max(max_size, field_ty.abiSizeSema(pt) catch |err| switch (err) {35802 max_size = @max(max_size, field_ty.abiSizeSema(pt) catch |err| switch (err) {
35803 error.AnalysisFail => {35803 error.AnalysisFail => {
...@@ -36185,7 +36185,7 @@ fn structZirInfo(zir: Zir, zir_index: Zir.Inst.Index) struct {...@@ -36185,7 +36185,7 @@ fn structZirInfo(zir: Zir, zir_index: Zir.Inst.Index) struct {
36185 const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended;36185 const extended = zir.instructions.items(.data)[@intFromEnum(zir_index)].extended;
36186 assert(extended.opcode == .struct_decl);36186 assert(extended.opcode == .struct_decl);
36187 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);36187 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
36188 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;36188 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len;
3618936189
36190 const captures_len = if (small.has_captures_len) blk: {36190 const captures_len = if (small.has_captures_len) blk: {
36191 const captures_len = zir.extra[extra_index];36191 const captures_len = zir.extra[extra_index];
...@@ -36357,7 +36357,7 @@ fn structFields(...@@ -36357,7 +36357,7 @@ fn structFields(
3635736357
36358 struct_type.field_types.get(ip)[field_i] = field_ty.toIntern();36358 struct_type.field_types.get(ip)[field_i] = field_ty.toIntern();
3635936359
36360 if (field_ty.zigTypeTag(zcu) == .Opaque) {36360 if (field_ty.zigTypeTag(zcu) == .@"opaque") {
36361 const msg = msg: {36361 const msg = msg: {
36362 const msg = try sema.errMsg(ty_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});36362 const msg = try sema.errMsg(ty_src, "opaque types have unknown size and therefore cannot be directly embedded in structs", .{});
36363 errdefer msg.destroy(sema.gpa);36363 errdefer msg.destroy(sema.gpa);
...@@ -36367,7 +36367,7 @@ fn structFields(...@@ -36367,7 +36367,7 @@ fn structFields(
36367 };36367 };
36368 return sema.failWithOwnedErrorMsg(&block_scope, msg);36368 return sema.failWithOwnedErrorMsg(&block_scope, msg);
36369 }36369 }
36370 if (field_ty.zigTypeTag(zcu) == .NoReturn) {36370 if (field_ty.zigTypeTag(zcu) == .noreturn) {
36371 const msg = msg: {36371 const msg = msg: {
36372 const msg = try sema.errMsg(ty_src, "struct fields cannot be 'noreturn'", .{});36372 const msg = try sema.errMsg(ty_src, "struct fields cannot be 'noreturn'", .{});
36373 errdefer msg.destroy(sema.gpa);36373 errdefer msg.destroy(sema.gpa);
...@@ -36635,7 +36635,7 @@ fn unionFields(...@@ -36635,7 +36635,7 @@ fn unionFields(
36635 if (small.auto_enum_tag) {36635 if (small.auto_enum_tag) {
36636 // The provided type is an integer type and we must construct the enum tag type here.36636 // The provided type is an integer type and we must construct the enum tag type here.
36637 int_tag_ty = provided_ty;36637 int_tag_ty = provided_ty;
36638 if (int_tag_ty.zigTypeTag(zcu) != .Int and int_tag_ty.zigTypeTag(zcu) != .ComptimeInt) {36638 if (int_tag_ty.zigTypeTag(zcu) != .int and int_tag_ty.zigTypeTag(zcu) != .comptime_int) {
36639 return sema.fail(&block_scope, tag_ty_src, "expected integer tag type, found '{}'", .{int_tag_ty.fmt(pt)});36639 return sema.fail(&block_scope, tag_ty_src, "expected integer tag type, found '{}'", .{int_tag_ty.fmt(pt)});
36640 }36640 }
3664136641
...@@ -36834,7 +36834,7 @@ fn unionFields(...@@ -36834,7 +36834,7 @@ fn unionFields(
36834 }36834 }
36835 }36835 }
3683636836
36837 if (field_ty.zigTypeTag(zcu) == .Opaque) {36837 if (field_ty.zigTypeTag(zcu) == .@"opaque") {
36838 const msg = msg: {36838 const msg = msg: {
36839 const msg = try sema.errMsg(type_src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{});36839 const msg = try sema.errMsg(type_src, "opaque types have unknown size and therefore cannot be directly embedded in unions", .{});
36840 errdefer msg.destroy(sema.gpa);36840 errdefer msg.destroy(sema.gpa);
...@@ -36932,7 +36932,7 @@ fn generateUnionTagTypeNumbered(...@@ -36932,7 +36932,7 @@ fn generateUnionTagTypeNumbered(
36932 const name = try ip.getOrPutStringFmt(36932 const name = try ip.getOrPutStringFmt(
36933 gpa,36933 gpa,
36934 pt.tid,36934 pt.tid,
36935 "@typeInfo({}).Union.tag_type.?",36935 "@typeInfo({}).@\"union\".tag_type.?",
36936 .{union_name.fmt(ip)},36936 .{union_name.fmt(ip)},
36937 .no_embedded_nulls,36937 .no_embedded_nulls,
36938 );36938 );
...@@ -36968,7 +36968,7 @@ fn generateUnionTagTypeSimple(...@@ -36968,7 +36968,7 @@ fn generateUnionTagTypeSimple(
36968 const name = try ip.getOrPutStringFmt(36968 const name = try ip.getOrPutStringFmt(
36969 gpa,36969 gpa,
36970 pt.tid,36970 pt.tid,
36971 "@typeInfo({}).Union.tag_type.?",36971 "@typeInfo({}).@\"union\".tag_type.?",
36972 .{union_name.fmt(ip)},36972 .{union_name.fmt(ip)},
36973 .no_embedded_nulls,36973 .no_embedded_nulls,
36974 );36974 );
...@@ -37637,7 +37637,7 @@ fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize)...@@ -37637,7 +37637,7 @@ fn intAdd(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize)
37637fn intAddInner(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize) !Value {37637fn intAddInner(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize) !Value {
37638 const pt = sema.pt;37638 const pt = sema.pt;
37639 const zcu = pt.zcu;37639 const zcu = pt.zcu;
37640 if (ty.zigTypeTag(zcu) == .Vector) {37640 if (ty.zigTypeTag(zcu) == .vector) {
37641 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu));37641 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu));
37642 const scalar_ty = ty.scalarType(zcu);37642 const scalar_ty = ty.scalarType(zcu);
37643 for (result_data, 0..) |*scalar, i| {37643 for (result_data, 0..) |*scalar, i| {
...@@ -37693,7 +37693,7 @@ fn numberAddWrapScalar(...@@ -37693,7 +37693,7 @@ fn numberAddWrapScalar(
37693 const zcu = pt.zcu;37693 const zcu = pt.zcu;
37694 if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return pt.undefValue(ty);37694 if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return pt.undefValue(ty);
3769537695
37696 if (ty.zigTypeTag(zcu) == .ComptimeInt) {37696 if (ty.zigTypeTag(zcu) == .comptime_int) {
37697 return sema.intAdd(lhs, rhs, ty, undefined);37697 return sema.intAdd(lhs, rhs, ty, undefined);
37698 }37698 }
3769937699
...@@ -37729,7 +37729,7 @@ fn intSub(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize)...@@ -37729,7 +37729,7 @@ fn intSub(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize)
3772937729
37730fn intSubInner(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize) !Value {37730fn intSubInner(sema: *Sema, lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize) !Value {
37731 const pt = sema.pt;37731 const pt = sema.pt;
37732 if (ty.zigTypeTag(pt.zcu) == .Vector) {37732 if (ty.zigTypeTag(pt.zcu) == .vector) {
37733 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));37733 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
37734 const scalar_ty = ty.scalarType(pt.zcu);37734 const scalar_ty = ty.scalarType(pt.zcu);
37735 for (result_data, 0..) |*scalar, i| {37735 for (result_data, 0..) |*scalar, i| {
...@@ -37786,7 +37786,7 @@ fn numberSubWrapScalar(...@@ -37786,7 +37786,7 @@ fn numberSubWrapScalar(
37786 const zcu = pt.zcu;37786 const zcu = pt.zcu;
37787 if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return pt.undefValue(ty);37787 if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return pt.undefValue(ty);
3778837788
37789 if (ty.zigTypeTag(zcu) == .ComptimeInt) {37789 if (ty.zigTypeTag(zcu) == .comptime_int) {
37790 return sema.intSub(lhs, rhs, ty, undefined);37790 return sema.intSub(lhs, rhs, ty, undefined);
37791 }37791 }
3779237792
...@@ -37806,7 +37806,7 @@ fn intSubWithOverflow(...@@ -37806,7 +37806,7 @@ fn intSubWithOverflow(
37806) !Value.OverflowArithmeticResult {37806) !Value.OverflowArithmeticResult {
37807 const pt = sema.pt;37807 const pt = sema.pt;
37808 const zcu = pt.zcu;37808 const zcu = pt.zcu;
37809 if (ty.zigTypeTag(zcu) == .Vector) {37809 if (ty.zigTypeTag(zcu) == .vector) {
37810 const vec_len = ty.vectorLen(zcu);37810 const vec_len = ty.vectorLen(zcu);
37811 const overflowed_data = try sema.arena.alloc(InternPool.Index, vec_len);37811 const overflowed_data = try sema.arena.alloc(InternPool.Index, vec_len);
37812 const result_data = try sema.arena.alloc(InternPool.Index, vec_len);37812 const result_data = try sema.arena.alloc(InternPool.Index, vec_len);
...@@ -37879,7 +37879,7 @@ fn intFromFloat(...@@ -37879,7 +37879,7 @@ fn intFromFloat(
37879) CompileError!Value {37879) CompileError!Value {
37880 const pt = sema.pt;37880 const pt = sema.pt;
37881 const zcu = pt.zcu;37881 const zcu = pt.zcu;
37882 if (float_ty.zigTypeTag(zcu) == .Vector) {37882 if (float_ty.zigTypeTag(zcu) == .vector) {
37883 const result_data = try sema.arena.alloc(InternPool.Index, float_ty.vectorLen(zcu));37883 const result_data = try sema.arena.alloc(InternPool.Index, float_ty.vectorLen(zcu));
37884 for (result_data, 0..) |*scalar, i| {37884 for (result_data, 0..) |*scalar, i| {
37885 const elem_val = try val.elemValue(pt, i);37885 const elem_val = try val.elemValue(pt, i);
...@@ -38015,7 +38015,7 @@ fn intFitsInType(...@@ -38015,7 +38015,7 @@ fn intFitsInType(
38015 },38015 },
38016 },38016 },
38017 .aggregate => |aggregate| {38017 .aggregate => |aggregate| {
38018 assert(ty.zigTypeTag(zcu) == .Vector);38018 assert(ty.zigTypeTag(zcu) == .vector);
38019 return switch (aggregate.storage) {38019 return switch (aggregate.storage) {
38020 .bytes => |bytes| for (bytes.toSlice(ty.vectorLen(zcu), &zcu.intern_pool), 0..) |byte, i| {38020 .bytes => |bytes| for (bytes.toSlice(ty.vectorLen(zcu), &zcu.intern_pool), 0..) |byte, i| {
38021 if (byte == 0) continue;38021 if (byte == 0) continue;
...@@ -38070,7 +38070,7 @@ fn intAddWithOverflow(...@@ -38070,7 +38070,7 @@ fn intAddWithOverflow(
38070) !Value.OverflowArithmeticResult {38070) !Value.OverflowArithmeticResult {
38071 const pt = sema.pt;38071 const pt = sema.pt;
38072 const zcu = pt.zcu;38072 const zcu = pt.zcu;
38073 if (ty.zigTypeTag(zcu) == .Vector) {38073 if (ty.zigTypeTag(zcu) == .vector) {
38074 const vec_len = ty.vectorLen(zcu);38074 const vec_len = ty.vectorLen(zcu);
38075 const overflowed_data = try sema.arena.alloc(InternPool.Index, vec_len);38075 const overflowed_data = try sema.arena.alloc(InternPool.Index, vec_len);
38076 const result_data = try sema.arena.alloc(InternPool.Index, vec_len);38076 const result_data = try sema.arena.alloc(InternPool.Index, vec_len);
...@@ -38143,7 +38143,7 @@ fn compareAll(...@@ -38143,7 +38143,7 @@ fn compareAll(
38143) CompileError!bool {38143) CompileError!bool {
38144 const pt = sema.pt;38144 const pt = sema.pt;
38145 const zcu = pt.zcu;38145 const zcu = pt.zcu;
38146 if (ty.zigTypeTag(zcu) == .Vector) {38146 if (ty.zigTypeTag(zcu) == .vector) {
38147 var i: usize = 0;38147 var i: usize = 0;
38148 while (i < ty.vectorLen(zcu)) : (i += 1) {38148 while (i < ty.vectorLen(zcu)) : (i += 1) {
38149 const lhs_elem = try lhs.elemValue(pt, i);38149 const lhs_elem = try lhs.elemValue(pt, i);
...@@ -38194,7 +38194,7 @@ fn compareVector(...@@ -38194,7 +38194,7 @@ fn compareVector(
38194) !Value {38194) !Value {
38195 const pt = sema.pt;38195 const pt = sema.pt;
38196 const zcu = pt.zcu;38196 const zcu = pt.zcu;
38197 assert(ty.zigTypeTag(zcu) == .Vector);38197 assert(ty.zigTypeTag(zcu) == .vector);
38198 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu));38198 const result_data = try sema.arena.alloc(InternPool.Index, ty.vectorLen(zcu));
38199 for (result_data, 0..) |*scalar, i| {38199 for (result_data, 0..) |*scalar, i| {
38200 const lhs_elem = try lhs.elemValue(pt, i);38200 const lhs_elem = try lhs.elemValue(pt, i);
...@@ -38555,7 +38555,7 @@ pub fn resolveDeclaredEnum(...@@ -38555,7 +38555,7 @@ pub fn resolveDeclaredEnum(
3855538555
38556 if (tag_type_ref != .none) {38556 if (tag_type_ref != .none) {
38557 const ty = try sema.resolveType(&block, tag_ty_src, tag_type_ref);38557 const ty = try sema.resolveType(&block, tag_ty_src, tag_type_ref);
38558 if (ty.zigTypeTag(zcu) != .Int and ty.zigTypeTag(zcu) != .ComptimeInt) {38558 if (ty.zigTypeTag(zcu) != .int and ty.zigTypeTag(zcu) != .comptime_int) {
38559 return sema.fail(&block, tag_ty_src, "expected integer tag type, found '{}'", .{ty.fmt(pt)});38559 return sema.fail(&block, tag_ty_src, "expected integer tag type, found '{}'", .{ty.fmt(pt)});
38560 }38560 }
38561 break :ty ty;38561 break :ty ty;
src/Sema/bitcast.zig+7-7
...@@ -274,7 +274,7 @@ const UnpackValueBits = struct {...@@ -274,7 +274,7 @@ const UnpackValueBits = struct {
274 => try unpack.primitive(val),274 => try unpack.primitive(val),
275275
276 .aggregate => switch (ty.zigTypeTag(zcu)) {276 .aggregate => switch (ty.zigTypeTag(zcu)) {
277 .Vector => {277 .vector => {
278 const len: usize = @intCast(ty.arrayLen(zcu));278 const len: usize = @intCast(ty.arrayLen(zcu));
279 for (0..len) |i| {279 for (0..len) |i| {
280 // We reverse vector elements in packed memory on BE targets.280 // We reverse vector elements in packed memory on BE targets.
...@@ -286,7 +286,7 @@ const UnpackValueBits = struct {...@@ -286,7 +286,7 @@ const UnpackValueBits = struct {
286 try unpack.add(elem_val);286 try unpack.add(elem_val);
287 }287 }
288 },288 },
289 .Array => {289 .array => {
290 // Each element is padded up to its ABI size. Padding bits are undefined.290 // Each element is padded up to its ABI size. Padding bits are undefined.
291 // The final element does not have trailing padding.291 // The final element does not have trailing padding.
292 // Elements are reversed in packed memory on BE targets.292 // Elements are reversed in packed memory on BE targets.
...@@ -316,7 +316,7 @@ const UnpackValueBits = struct {...@@ -316,7 +316,7 @@ const UnpackValueBits = struct {
316 try unpack.add(s);316 try unpack.add(s);
317 };317 };
318 },318 },
319 .Struct => switch (ty.containerLayout(zcu)) {319 .@"struct" => switch (ty.containerLayout(zcu)) {
320 .auto => unreachable, // ill-defined layout320 .auto => unreachable, // ill-defined layout
321 .@"extern" => switch (endian) {321 .@"extern" => switch (endian) {
322 .little => {322 .little => {
...@@ -473,7 +473,7 @@ const PackValueBits = struct {...@@ -473,7 +473,7 @@ const PackValueBits = struct {
473 const ip = &zcu.intern_pool;473 const ip = &zcu.intern_pool;
474 const arena = pack.arena;474 const arena = pack.arena;
475 switch (ty.zigTypeTag(zcu)) {475 switch (ty.zigTypeTag(zcu)) {
476 .Vector => {476 .vector => {
477 // Elements are bit-packed.477 // Elements are bit-packed.
478 const len = ty.arrayLen(zcu);478 const len = ty.arrayLen(zcu);
479 const elem_ty = ty.childType(zcu);479 const elem_ty = ty.childType(zcu);
...@@ -496,7 +496,7 @@ const PackValueBits = struct {...@@ -496,7 +496,7 @@ const PackValueBits = struct {
496 .storage = .{ .elems = elems },496 .storage = .{ .elems = elems },
497 } }));497 } }));
498 },498 },
499 .Array => {499 .array => {
500 // Each element is padded up to its ABI size. The final element does not have trailing padding.500 // Each element is padded up to its ABI size. The final element does not have trailing padding.
501 const len = ty.arrayLen(zcu);501 const len = ty.arrayLen(zcu);
502 const elem_ty = ty.childType(zcu);502 const elem_ty = ty.childType(zcu);
...@@ -530,7 +530,7 @@ const PackValueBits = struct {...@@ -530,7 +530,7 @@ const PackValueBits = struct {
530 .storage = .{ .elems = elems },530 .storage = .{ .elems = elems },
531 } }));531 } }));
532 },532 },
533 .Struct => switch (ty.containerLayout(zcu)) {533 .@"struct" => switch (ty.containerLayout(zcu)) {
534 .auto => unreachable, // ill-defined layout534 .auto => unreachable, // ill-defined layout
535 .@"extern" => {535 .@"extern" => {
536 const elems = try arena.alloc(InternPool.Index, ty.structFieldCount(zcu));536 const elems = try arena.alloc(InternPool.Index, ty.structFieldCount(zcu));
...@@ -587,7 +587,7 @@ const PackValueBits = struct {...@@ -587,7 +587,7 @@ const PackValueBits = struct {
587 } }));587 } }));
588 },588 },
589 },589 },
590 .Union => {590 .@"union" => {
591 // We will attempt to read as the backing representation. If this emits591 // We will attempt to read as the backing representation. If this emits
592 // `error.ReinterpretDeclRef`, we will try each union field, preferring larger ones.592 // `error.ReinterpretDeclRef`, we will try each union field, preferring larger ones.
593 // We will also attempt smaller fields when we get `undefined`, as if some bits are593 // We will also attempt smaller fields when we get `undefined`, as if some bits are
src/Sema/comptime_ptr_access.zig+64-64
...@@ -226,7 +226,7 @@ fn loadComptimePtrInner(...@@ -226,7 +226,7 @@ fn loadComptimePtrInner(
226 .variable => return .runtime_load,226 .variable => return .runtime_load,
227 // We let `.@"extern"` through here if it's a function.227 // We let `.@"extern"` through here if it's a function.
228 // This allows you to alias `extern fn`s.228 // This allows you to alias `extern fn`s.
229 .@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .Fn)229 .@"extern" => |e| if (Type.fromInterned(e.ty).zigTypeTag(zcu) == .@"fn")
230 break :val .{ .interned = val }230 break :val .{ .interned = val }
231 else231 else
232 return .runtime_load,232 return .runtime_load,
...@@ -296,8 +296,8 @@ fn loadComptimePtrInner(...@@ -296,8 +296,8 @@ fn loadComptimePtrInner(
296296
297 const agg_ty = agg_val.typeOf(zcu);297 const agg_ty = agg_val.typeOf(zcu);
298 switch (agg_ty.zigTypeTag(zcu)) {298 switch (agg_ty.zigTypeTag(zcu)) {
299 .Struct, .Pointer => break :val try agg_val.getElem(sema.pt, @intCast(base_index.index)),299 .@"struct", .pointer => break :val try agg_val.getElem(sema.pt, @intCast(base_index.index)),
300 .Union => {300 .@"union" => {
301 const tag_val: Value, const payload_mv: MutableValue = switch (agg_val) {301 const tag_val: Value, const payload_mv: MutableValue = switch (agg_val) {
302 .un => |un| .{ Value.fromInterned(un.tag), un.payload.* },302 .un => |un| .{ Value.fromInterned(un.tag), un.payload.* },
303 .interned => |ip_index| switch (ip.indexToKey(ip_index)) {303 .interned => |ip_index| switch (ip.indexToKey(ip_index)) {
...@@ -321,7 +321,7 @@ fn loadComptimePtrInner(...@@ -321,7 +321,7 @@ fn loadComptimePtrInner(
321 };321 };
322322
323 if (ptr.byte_offset == 0 and host_bits == 0) {323 if (ptr.byte_offset == 0 and host_bits == 0) {
324 if (load_ty.zigTypeTag(zcu) != .Array or array_offset == 0) {324 if (load_ty.zigTypeTag(zcu) != .array or array_offset == 0) {
325 if (.ok == try sema.coerceInMemoryAllowed(325 if (.ok == try sema.coerceInMemoryAllowed(
326 block,326 block,
327 load_ty,327 load_ty,
...@@ -366,7 +366,7 @@ fn loadComptimePtrInner(...@@ -366,7 +366,7 @@ fn loadComptimePtrInner(
366 null,366 null,
367 )) {367 )) {
368 // Changing the length of an array.368 // Changing the length of an array.
369 const skip_base: u64 = extra_base_index + if (load_ty.zigTypeTag(zcu) == .Array) skip: {369 const skip_base: u64 = extra_base_index + if (load_ty.zigTypeTag(zcu) == .array) skip: {
370 break :skip load_ty.childType(zcu).arrayBase(zcu)[1] * array_offset;370 break :skip load_ty.childType(zcu).arrayBase(zcu)[1] * array_offset;
371 } else 0;371 } else 0;
372 if (skip_base + load_count > val_count) return .{ .out_of_bounds = base_val.typeOf(zcu) };372 if (skip_base + load_count > val_count) return .{ .out_of_bounds = base_val.typeOf(zcu) };
...@@ -394,7 +394,7 @@ fn loadComptimePtrInner(...@@ -394,7 +394,7 @@ fn loadComptimePtrInner(
394 var cur_val = base_val;394 var cur_val = base_val;
395 var cur_offset = ptr.byte_offset;395 var cur_offset = ptr.byte_offset;
396396
397 if (load_ty.zigTypeTag(zcu) == .Array and array_offset > 0) {397 if (load_ty.zigTypeTag(zcu) == .array and array_offset > 0) {
398 cur_offset += try load_ty.childType(zcu).abiSizeSema(pt) * array_offset;398 cur_offset += try load_ty.childType(zcu).abiSizeSema(pt) * array_offset;
399 }399 }
400400
...@@ -410,30 +410,30 @@ fn loadComptimePtrInner(...@@ -410,30 +410,30 @@ fn loadComptimePtrInner(
410 while (true) {410 while (true) {
411 const cur_ty = cur_val.typeOf(zcu);411 const cur_ty = cur_val.typeOf(zcu);
412 switch (cur_ty.zigTypeTag(zcu)) {412 switch (cur_ty.zigTypeTag(zcu)) {
413 .NoReturn,413 .noreturn,
414 .Type,414 .type,
415 .ComptimeInt,415 .comptime_int,
416 .ComptimeFloat,416 .comptime_float,
417 .Null,417 .null,
418 .Undefined,418 .undefined,
419 .EnumLiteral,419 .enum_literal,
420 .Opaque,420 .@"opaque",
421 .Fn,421 .@"fn",
422 .ErrorUnion,422 .error_union,
423 => unreachable, // ill-defined layout423 => unreachable, // ill-defined layout
424 .Int,424 .int,
425 .Float,425 .float,
426 .Bool,426 .bool,
427 .Void,427 .void,
428 .Pointer,428 .pointer,
429 .ErrorSet,429 .error_set,
430 .AnyFrame,430 .@"anyframe",
431 .Frame,431 .frame,
432 .Enum,432 .@"enum",
433 .Vector,433 .vector,
434 => break, // terminal types (no sub-values)434 => break, // terminal types (no sub-values)
435 .Optional => break, // this can only be a pointer-like optional so is terminal435 .optional => break, // this can only be a pointer-like optional so is terminal
436 .Array => {436 .array => {
437 const elem_ty = cur_ty.childType(zcu);437 const elem_ty = cur_ty.childType(zcu);
438 const elem_size = try elem_ty.abiSizeSema(pt);438 const elem_size = try elem_ty.abiSizeSema(pt);
439 const elem_idx = cur_offset / elem_size;439 const elem_idx = cur_offset / elem_size;
...@@ -446,7 +446,7 @@ fn loadComptimePtrInner(...@@ -446,7 +446,7 @@ fn loadComptimePtrInner(
446 break;446 break;
447 }447 }
448 },448 },
449 .Struct => switch (cur_ty.containerLayout(zcu)) {449 .@"struct" => switch (cur_ty.containerLayout(zcu)) {
450 .auto => unreachable, // ill-defined layout450 .auto => unreachable, // ill-defined layout
451 .@"packed" => break, // let the bitcast logic handle this451 .@"packed" => break, // let the bitcast logic handle this
452 .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {452 .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {
...@@ -459,7 +459,7 @@ fn loadComptimePtrInner(...@@ -459,7 +459,7 @@ fn loadComptimePtrInner(
459 }459 }
460 } else break, // pointer spans multiple fields460 } else break, // pointer spans multiple fields
461 },461 },
462 .Union => switch (cur_ty.containerLayout(zcu)) {462 .@"union" => switch (cur_ty.containerLayout(zcu)) {
463 .auto => unreachable, // ill-defined layout463 .auto => unreachable, // ill-defined layout
464 .@"packed" => break, // let the bitcast logic handle this464 .@"packed" => break, // let the bitcast logic handle this
465 .@"extern" => {465 .@"extern" => {
...@@ -692,11 +692,11 @@ fn prepareComptimePtrStore(...@@ -692,11 +692,11 @@ fn prepareComptimePtrStore(
692692
693 const agg_ty = agg_val.typeOf(zcu);693 const agg_ty = agg_val.typeOf(zcu);
694 switch (agg_ty.zigTypeTag(zcu)) {694 switch (agg_ty.zigTypeTag(zcu)) {
695 .Struct, .Pointer => break :strat .{ .direct = .{695 .@"struct", .pointer => break :strat .{ .direct = .{
696 .val = try agg_val.elem(pt, sema.arena, @intCast(base_index.index)),696 .val = try agg_val.elem(pt, sema.arena, @intCast(base_index.index)),
697 .alloc = alloc,697 .alloc = alloc,
698 } },698 } },
699 .Union => {699 .@"union" => {
700 if (agg_val.* == .interned and Value.fromInterned(agg_val.interned).isUndef(zcu)) {700 if (agg_val.* == .interned and Value.fromInterned(agg_val.interned).isUndef(zcu)) {
701 return .undef;701 return .undef;
702 }702 }
...@@ -717,7 +717,7 @@ fn prepareComptimePtrStore(...@@ -717,7 +717,7 @@ fn prepareComptimePtrStore(
717 };717 };
718718
719 if (ptr.byte_offset == 0) {719 if (ptr.byte_offset == 0) {
720 if (store_ty.zigTypeTag(zcu) != .Array or array_offset == 0) direct: {720 if (store_ty.zigTypeTag(zcu) != .array or array_offset == 0) direct: {
721 const base_val_ty = switch (base_strat) {721 const base_val_ty = switch (base_strat) {
722 .direct => |direct| direct.val.typeOf(zcu),722 .direct => |direct| direct.val.typeOf(zcu),
723 .index => |index| index.val.typeOf(zcu).childType(zcu),723 .index => |index| index.val.typeOf(zcu).childType(zcu),
...@@ -770,7 +770,7 @@ fn prepareComptimePtrStore(...@@ -770,7 +770,7 @@ fn prepareComptimePtrStore(
770 }770 }
771 if (base_elem_offset + extra_base_index + store_count > val_count) return .{ .out_of_bounds = oob_ty };771 if (base_elem_offset + extra_base_index + store_count > val_count) return .{ .out_of_bounds = oob_ty };
772772
773 if (store_ty.zigTypeTag(zcu) == .Array) {773 if (store_ty.zigTypeTag(zcu) == .array) {
774 const skip = store_ty.childType(zcu).arrayBase(zcu)[1] * array_offset;774 const skip = store_ty.childType(zcu).arrayBase(zcu)[1] * array_offset;
775 return .{ .flat_index = .{775 return .{ .flat_index = .{
776 .alloc = base_strat.alloc(),776 .alloc = base_strat.alloc(),
...@@ -780,7 +780,7 @@ fn prepareComptimePtrStore(...@@ -780,7 +780,7 @@ fn prepareComptimePtrStore(
780 }780 }
781781
782 // `base_val` must be an array, since otherwise the "direct reinterpret" logic above noticed it.782 // `base_val` must be an array, since otherwise the "direct reinterpret" logic above noticed it.
783 assert(base_val.typeOf(zcu).zigTypeTag(zcu) == .Array);783 assert(base_val.typeOf(zcu).zigTypeTag(zcu) == .array);
784784
785 var index: u64 = base_elem_offset + extra_base_index;785 var index: u64 = base_elem_offset + extra_base_index;
786 const arr_val, const arr_index = (try recursiveIndex(sema, base_val, &index)).?;786 const arr_val, const arr_index = (try recursiveIndex(sema, base_val, &index)).?;
...@@ -816,7 +816,7 @@ fn prepareComptimePtrStore(...@@ -816,7 +816,7 @@ fn prepareComptimePtrStore(
816 return .{ .needed_well_defined = cur_val.typeOf(zcu) };816 return .{ .needed_well_defined = cur_val.typeOf(zcu) };
817 }817 }
818818
819 if (store_ty.zigTypeTag(zcu) == .Array and array_offset > 0) {819 if (store_ty.zigTypeTag(zcu) == .array and array_offset > 0) {
820 cur_offset += try store_ty.childType(zcu).abiSizeSema(pt) * array_offset;820 cur_offset += try store_ty.childType(zcu).abiSizeSema(pt) * array_offset;
821 }821 }
822822
...@@ -832,30 +832,30 @@ fn prepareComptimePtrStore(...@@ -832,30 +832,30 @@ fn prepareComptimePtrStore(
832 while (true) {832 while (true) {
833 const cur_ty = cur_val.typeOf(zcu);833 const cur_ty = cur_val.typeOf(zcu);
834 switch (cur_ty.zigTypeTag(zcu)) {834 switch (cur_ty.zigTypeTag(zcu)) {
835 .NoReturn,835 .noreturn,
836 .Type,836 .type,
837 .ComptimeInt,837 .comptime_int,
838 .ComptimeFloat,838 .comptime_float,
839 .Null,839 .null,
840 .Undefined,840 .undefined,
841 .EnumLiteral,841 .enum_literal,
842 .Opaque,842 .@"opaque",
843 .Fn,843 .@"fn",
844 .ErrorUnion,844 .error_union,
845 => unreachable, // ill-defined layout845 => unreachable, // ill-defined layout
846 .Int,846 .int,
847 .Float,847 .float,
848 .Bool,848 .bool,
849 .Void,849 .void,
850 .Pointer,850 .pointer,
851 .ErrorSet,851 .error_set,
852 .AnyFrame,852 .@"anyframe",
853 .Frame,853 .frame,
854 .Enum,854 .@"enum",
855 .Vector,855 .vector,
856 => break, // terminal types (no sub-values)856 => break, // terminal types (no sub-values)
857 .Optional => break, // this can only be a pointer-like optional so is terminal857 .optional => break, // this can only be a pointer-like optional so is terminal
858 .Array => {858 .array => {
859 const elem_ty = cur_ty.childType(zcu);859 const elem_ty = cur_ty.childType(zcu);
860 const elem_size = try elem_ty.abiSizeSema(pt);860 const elem_size = try elem_ty.abiSizeSema(pt);
861 const elem_idx = cur_offset / elem_size;861 const elem_idx = cur_offset / elem_size;
...@@ -868,7 +868,7 @@ fn prepareComptimePtrStore(...@@ -868,7 +868,7 @@ fn prepareComptimePtrStore(
868 break;868 break;
869 }869 }
870 },870 },
871 .Struct => switch (cur_ty.containerLayout(zcu)) {871 .@"struct" => switch (cur_ty.containerLayout(zcu)) {
872 .auto => unreachable, // ill-defined layout872 .auto => unreachable, // ill-defined layout
873 .@"packed" => break, // let the bitcast logic handle this873 .@"packed" => break, // let the bitcast logic handle this
874 .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {874 .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {
...@@ -881,7 +881,7 @@ fn prepareComptimePtrStore(...@@ -881,7 +881,7 @@ fn prepareComptimePtrStore(
881 }881 }
882 } else break, // pointer spans multiple fields882 } else break, // pointer spans multiple fields
883 },883 },
884 .Union => switch (cur_ty.containerLayout(zcu)) {884 .@"union" => switch (cur_ty.containerLayout(zcu)) {
885 .auto => unreachable, // ill-defined layout885 .auto => unreachable, // ill-defined layout
886 .@"packed" => break, // let the bitcast logic handle this886 .@"packed" => break, // let the bitcast logic handle this
887 .@"extern" => {887 .@"extern" => {
...@@ -942,7 +942,7 @@ fn flattenArray(...@@ -942,7 +942,7 @@ fn flattenArray(
942 return;942 return;
943 }943 }
944944
945 if (ty.zigTypeTag(zcu) != .Array) {945 if (ty.zigTypeTag(zcu) != .array) {
946 out[@intCast(next_idx.*)] = (try val.intern(sema.pt, sema.arena)).toIntern();946 out[@intCast(next_idx.*)] = (try val.intern(sema.pt, sema.arena)).toIntern();
947 next_idx.* += 1;947 next_idx.* += 1;
948 return;948 return;
...@@ -975,7 +975,7 @@ fn unflattenArray(...@@ -975,7 +975,7 @@ fn unflattenArray(
975 const zcu = sema.pt.zcu;975 const zcu = sema.pt.zcu;
976 const arena = sema.arena;976 const arena = sema.arena;
977977
978 if (ty.zigTypeTag(zcu) != .Array) {978 if (ty.zigTypeTag(zcu) != .array) {
979 const val = Value.fromInterned(elems[@intCast(next_idx.*)]);979 const val = Value.fromInterned(elems[@intCast(next_idx.*)]);
980 next_idx.* += 1;980 next_idx.* += 1;
981 return sema.pt.getCoerced(val, ty);981 return sema.pt.getCoerced(val, ty);
...@@ -1008,7 +1008,7 @@ fn recursiveIndex(...@@ -1008,7 +1008,7 @@ fn recursiveIndex(
1008 const pt = sema.pt;1008 const pt = sema.pt;
10091009
1010 const ty = mv.typeOf(pt.zcu);1010 const ty = mv.typeOf(pt.zcu);
1011 assert(ty.zigTypeTag(pt.zcu) == .Array);1011 assert(ty.zigTypeTag(pt.zcu) == .array);
10121012
1013 const ty_base_elems = ty.arrayBase(pt.zcu)[1];1013 const ty_base_elems = ty.arrayBase(pt.zcu)[1];
1014 if (index.* >= ty_base_elems) {1014 if (index.* >= ty_base_elems) {
...@@ -1017,7 +1017,7 @@ fn recursiveIndex(...@@ -1017,7 +1017,7 @@ fn recursiveIndex(
1017 }1017 }
10181018
1019 const elem_ty = ty.childType(pt.zcu);1019 const elem_ty = ty.childType(pt.zcu);
1020 if (elem_ty.zigTypeTag(pt.zcu) != .Array) {1020 if (elem_ty.zigTypeTag(pt.zcu) != .array) {
1021 assert(index.* < ty.arrayLenIncludingSentinel(pt.zcu)); // should be handled by initial check1021 assert(index.* < ty.arrayLenIncludingSentinel(pt.zcu)); // should be handled by initial check
1022 return .{ mv, index.* };1022 return .{ mv, index.* };
1023 }1023 }
src/Type.zig+93-93
...@@ -31,8 +31,8 @@ pub fn zigTypeTagOrPoison(ty: Type, zcu: *const Zcu) error{GenericPoison}!std.bu...@@ -31,8 +31,8 @@ pub fn zigTypeTagOrPoison(ty: Type, zcu: *const Zcu) error{GenericPoison}!std.bu
3131
32pub fn baseZigTypeTag(self: Type, mod: *Zcu) std.builtin.TypeId {32pub fn baseZigTypeTag(self: Type, mod: *Zcu) std.builtin.TypeId {
33 return switch (self.zigTypeTag(mod)) {33 return switch (self.zigTypeTag(mod)) {
34 .ErrorUnion => self.errorUnionPayload(mod).baseZigTypeTag(mod),34 .error_union => self.errorUnionPayload(mod).baseZigTypeTag(mod),
35 .Optional => {35 .optional => {
36 return self.optionalChild(mod).baseZigTypeTag(mod);36 return self.optionalChild(mod).baseZigTypeTag(mod);
37 },37 },
38 else => |t| t,38 else => |t| t,
...@@ -41,37 +41,37 @@ pub fn baseZigTypeTag(self: Type, mod: *Zcu) std.builtin.TypeId {...@@ -41,37 +41,37 @@ pub fn baseZigTypeTag(self: Type, mod: *Zcu) std.builtin.TypeId {
4141
42pub fn isSelfComparable(ty: Type, zcu: *const Zcu, is_equality_cmp: bool) bool {42pub fn isSelfComparable(ty: Type, zcu: *const Zcu, is_equality_cmp: bool) bool {
43 return switch (ty.zigTypeTag(zcu)) {43 return switch (ty.zigTypeTag(zcu)) {
44 .Int,44 .int,
45 .Float,45 .float,
46 .ComptimeFloat,46 .comptime_float,
47 .ComptimeInt,47 .comptime_int,
48 => true,48 => true,
4949
50 .Vector => ty.elemType2(zcu).isSelfComparable(zcu, is_equality_cmp),50 .vector => ty.elemType2(zcu).isSelfComparable(zcu, is_equality_cmp),
5151
52 .Bool,52 .bool,
53 .Type,53 .type,
54 .Void,54 .void,
55 .ErrorSet,55 .error_set,
56 .Fn,56 .@"fn",
57 .Opaque,57 .@"opaque",
58 .AnyFrame,58 .@"anyframe",
59 .Enum,59 .@"enum",
60 .EnumLiteral,60 .enum_literal,
61 => is_equality_cmp,61 => is_equality_cmp,
6262
63 .NoReturn,63 .noreturn,
64 .Array,64 .array,
65 .Struct,65 .@"struct",
66 .Undefined,66 .undefined,
67 .Null,67 .null,
68 .ErrorUnion,68 .error_union,
69 .Union,69 .@"union",
70 .Frame,70 .frame,
71 => false,71 => false,
7272
73 .Pointer => !ty.isSlice(zcu) and (is_equality_cmp or ty.isCPtr(zcu)),73 .pointer => !ty.isSlice(zcu) and (is_equality_cmp or ty.isCPtr(zcu)),
74 .Optional => {74 .optional => {
75 if (!is_equality_cmp) return false;75 if (!is_equality_cmp) return false;
76 return ty.optionalChild(zcu).isSelfComparable(zcu, is_equality_cmp);76 return ty.optionalChild(zcu).isSelfComparable(zcu, is_equality_cmp);
77 },77 },
...@@ -80,9 +80,9 @@ pub fn isSelfComparable(ty: Type, zcu: *const Zcu, is_equality_cmp: bool) bool {...@@ -80,9 +80,9 @@ pub fn isSelfComparable(ty: Type, zcu: *const Zcu, is_equality_cmp: bool) bool {
8080
81/// If it is a function pointer, returns the function type. Otherwise returns null.81/// If it is a function pointer, returns the function type. Otherwise returns null.
82pub fn castPtrToFn(ty: Type, zcu: *const Zcu) ?Type {82pub fn castPtrToFn(ty: Type, zcu: *const Zcu) ?Type {
83 if (ty.zigTypeTag(zcu) != .Pointer) return null;83 if (ty.zigTypeTag(zcu) != .pointer) return null;
84 const elem_ty = ty.childType(zcu);84 const elem_ty = ty.childType(zcu);
85 if (elem_ty.zigTypeTag(zcu) != .Fn) return null;85 if (elem_ty.zigTypeTag(zcu) != .@"fn") return null;
86 return elem_ty;86 return elem_ty;
87}87}
8888
...@@ -267,7 +267,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error...@@ -267,7 +267,7 @@ pub fn print(ty: Type, writer: anytype, pt: Zcu.PerThread) @TypeOf(writer).Error
267 },267 },
268 .inferred_error_set_type => |func_index| {268 .inferred_error_set_type => |func_index| {
269 const func_nav = ip.getNav(zcu.funcInfo(func_index).owner_nav);269 const func_nav = ip.getNav(zcu.funcInfo(func_index).owner_nav);
270 try writer.print("@typeInfo(@typeInfo(@TypeOf({})).Fn.return_type.?).ErrorUnion.error_set", .{270 try writer.print("@typeInfo(@typeInfo(@TypeOf({})).@\"fn\".return_type.?).error_union.error_set", .{
271 func_nav.fqn.fmt(ip),271 func_nav.fqn.fmt(ip),
272 });272 });
273 },273 },
...@@ -796,7 +796,7 @@ pub fn fnHasRuntimeBitsInner(...@@ -796,7 +796,7 @@ pub fn fnHasRuntimeBitsInner(
796796
797pub fn isFnOrHasRuntimeBits(ty: Type, zcu: *Zcu) bool {797pub fn isFnOrHasRuntimeBits(ty: Type, zcu: *Zcu) bool {
798 switch (ty.zigTypeTag(zcu)) {798 switch (ty.zigTypeTag(zcu)) {
799 .Fn => return ty.fnHasRuntimeBits(zcu),799 .@"fn" => return ty.fnHasRuntimeBits(zcu),
800 else => return ty.hasRuntimeBits(zcu),800 else => return ty.hasRuntimeBits(zcu),
801 }801 }
802}802}
...@@ -804,7 +804,7 @@ pub fn isFnOrHasRuntimeBits(ty: Type, zcu: *Zcu) bool {...@@ -804,7 +804,7 @@ pub fn isFnOrHasRuntimeBits(ty: Type, zcu: *Zcu) bool {
804/// Same as `isFnOrHasRuntimeBits` but comptime-only types may return a false positive.804/// Same as `isFnOrHasRuntimeBits` but comptime-only types may return a false positive.
805pub fn isFnOrHasRuntimeBitsIgnoreComptime(ty: Type, zcu: *Zcu) bool {805pub fn isFnOrHasRuntimeBitsIgnoreComptime(ty: Type, zcu: *Zcu) bool {
806 return switch (ty.zigTypeTag(zcu)) {806 return switch (ty.zigTypeTag(zcu)) {
807 .Fn => true,807 .@"fn" => true,
808 else => return ty.hasRuntimeBitsIgnoreComptime(zcu),808 else => return ty.hasRuntimeBitsIgnoreComptime(zcu),
809 };809 };
810}810}
...@@ -1216,9 +1216,9 @@ fn abiAlignmentInnerOptional(...@@ -1216,9 +1216,9 @@ fn abiAlignmentInnerOptional(
1216 const child_type = ty.optionalChild(zcu);1216 const child_type = ty.optionalChild(zcu);
12171217
1218 switch (child_type.zigTypeTag(zcu)) {1218 switch (child_type.zigTypeTag(zcu)) {
1219 .Pointer => return .{ .scalar = ptrAbiAlignment(target) },1219 .pointer => return .{ .scalar = ptrAbiAlignment(target) },
1220 .ErrorSet => return Type.anyerror.abiAlignmentInner(strat, zcu, tid),1220 .error_set => return Type.anyerror.abiAlignmentInner(strat, zcu, tid),
1221 .NoReturn => return .{ .scalar = .@"1" },1221 .noreturn => return .{ .scalar = .@"1" },
1222 else => {},1222 else => {},
1223 }1223 }
12241224
...@@ -2053,7 +2053,7 @@ pub fn elemType2(ty: Type, zcu: *const Zcu) Type {...@@ -2053,7 +2053,7 @@ pub fn elemType2(ty: Type, zcu: *const Zcu) Type {
20532053
2054fn shallowElemType(child_ty: Type, zcu: *const Zcu) Type {2054fn shallowElemType(child_ty: Type, zcu: *const Zcu) Type {
2055 return switch (child_ty.zigTypeTag(zcu)) {2055 return switch (child_ty.zigTypeTag(zcu)) {
2056 .Array, .Vector => child_ty.childType(zcu),2056 .array, .vector => child_ty.childType(zcu),
2057 else => child_ty,2057 else => child_ty,
2058 };2058 };
2059}2059}
...@@ -2061,7 +2061,7 @@ fn shallowElemType(child_ty: Type, zcu: *const Zcu) Type {...@@ -2061,7 +2061,7 @@ fn shallowElemType(child_ty: Type, zcu: *const Zcu) Type {
2061/// For vectors, returns the element type. Otherwise returns self.2061/// For vectors, returns the element type. Otherwise returns self.
2062pub fn scalarType(ty: Type, zcu: *const Zcu) Type {2062pub fn scalarType(ty: Type, zcu: *const Zcu) Type {
2063 return switch (ty.zigTypeTag(zcu)) {2063 return switch (ty.zigTypeTag(zcu)) {
2064 .Vector => ty.childType(zcu),2064 .vector => ty.childType(zcu),
2065 else => ty,2065 else => ty,
2066 };2066 };
2067}2067}
...@@ -2217,7 +2217,7 @@ pub fn isAnyError(ty: Type, zcu: *const Zcu) bool {...@@ -2217,7 +2217,7 @@ pub fn isAnyError(ty: Type, zcu: *const Zcu) bool {
22172217
2218pub fn isError(ty: Type, zcu: *const Zcu) bool {2218pub fn isError(ty: Type, zcu: *const Zcu) bool {
2219 return switch (ty.zigTypeTag(zcu)) {2219 return switch (ty.zigTypeTag(zcu)) {
2220 .ErrorUnion, .ErrorSet => true,2220 .error_union, .error_set => true,
2221 else => false,2221 else => false,
2222 };2222 };
2223}2223}
...@@ -2341,8 +2341,8 @@ pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool {...@@ -2341,8 +2341,8 @@ pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool {
2341/// If this function returns true, then intInfo() can be called on the type.2341/// If this function returns true, then intInfo() can be called on the type.
2342pub fn isAbiInt(ty: Type, zcu: *const Zcu) bool {2342pub fn isAbiInt(ty: Type, zcu: *const Zcu) bool {
2343 return switch (ty.zigTypeTag(zcu)) {2343 return switch (ty.zigTypeTag(zcu)) {
2344 .Int, .Enum, .ErrorSet => true,2344 .int, .@"enum", .error_set => true,
2345 .Struct => ty.containerLayout(zcu) == .@"packed",2345 .@"struct" => ty.containerLayout(zcu) == .@"packed",
2346 else => false,2346 else => false,
2347 };2347 };
2348}2348}
...@@ -2494,14 +2494,14 @@ pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.CallingConvent...@@ -2494,14 +2494,14 @@ pub fn fnCallingConvention(ty: Type, zcu: *const Zcu) std.builtin.CallingConvent
24942494
2495pub fn isValidParamType(self: Type, zcu: *const Zcu) bool {2495pub fn isValidParamType(self: Type, zcu: *const Zcu) bool {
2496 return switch (self.zigTypeTagOrPoison(zcu) catch return true) {2496 return switch (self.zigTypeTagOrPoison(zcu) catch return true) {
2497 .Opaque, .NoReturn => false,2497 .@"opaque", .noreturn => false,
2498 else => true,2498 else => true,
2499 };2499 };
2500}2500}
25012501
2502pub fn isValidReturnType(self: Type, zcu: *const Zcu) bool {2502pub fn isValidReturnType(self: Type, zcu: *const Zcu) bool {
2503 return switch (self.zigTypeTagOrPoison(zcu) catch return true) {2503 return switch (self.zigTypeTagOrPoison(zcu) catch return true) {
2504 .Opaque => false,2504 .@"opaque" => false,
2505 else => true,2505 else => true,
2506 };2506 };
2507}2507}
...@@ -2782,8 +2782,8 @@ pub fn comptimeOnlyInner(...@@ -2782,8 +2782,8 @@ pub fn comptimeOnlyInner(
2782 .ptr_type => |ptr_type| {2782 .ptr_type => |ptr_type| {
2783 const child_ty = Type.fromInterned(ptr_type.child);2783 const child_ty = Type.fromInterned(ptr_type.child);
2784 switch (child_ty.zigTypeTag(zcu)) {2784 switch (child_ty.zigTypeTag(zcu)) {
2785 .Fn => return !try child_ty.fnHasRuntimeBitsInner(strat, zcu, tid),2785 .@"fn" => return !try child_ty.fnHasRuntimeBitsInner(strat, zcu, tid),
2786 .Opaque => return false,2786 .@"opaque" => return false,
2787 else => return child_ty.comptimeOnlyInner(strat, zcu, tid),2787 else => return child_ty.comptimeOnlyInner(strat, zcu, tid),
2788 }2788 }
2789 },2789 },
...@@ -2954,7 +2954,7 @@ pub fn comptimeOnlyInner(...@@ -2954,7 +2954,7 @@ pub fn comptimeOnlyInner(
2954}2954}
29552955
2956pub fn isVector(ty: Type, zcu: *const Zcu) bool {2956pub fn isVector(ty: Type, zcu: *const Zcu) bool {
2957 return ty.zigTypeTag(zcu) == .Vector;2957 return ty.zigTypeTag(zcu) == .vector;
2958}2958}
29592959
2960/// Returns 0 if not a vector, otherwise returns @bitSizeOf(Element) * vector_len.2960/// Returns 0 if not a vector, otherwise returns @bitSizeOf(Element) * vector_len.
...@@ -2966,40 +2966,40 @@ pub fn totalVectorBits(ty: Type, zcu: *Zcu) u64 {...@@ -2966,40 +2966,40 @@ pub fn totalVectorBits(ty: Type, zcu: *Zcu) u64 {
29662966
2967pub fn isArrayOrVector(ty: Type, zcu: *const Zcu) bool {2967pub fn isArrayOrVector(ty: Type, zcu: *const Zcu) bool {
2968 return switch (ty.zigTypeTag(zcu)) {2968 return switch (ty.zigTypeTag(zcu)) {
2969 .Array, .Vector => true,2969 .array, .vector => true,
2970 else => false,2970 else => false,
2971 };2971 };
2972}2972}
29732973
2974pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {2974pub fn isIndexable(ty: Type, zcu: *const Zcu) bool {
2975 return switch (ty.zigTypeTag(zcu)) {2975 return switch (ty.zigTypeTag(zcu)) {
2976 .Array, .Vector => true,2976 .array, .vector => true,
2977 .Pointer => switch (ty.ptrSize(zcu)) {2977 .pointer => switch (ty.ptrSize(zcu)) {
2978 .Slice, .Many, .C => true,2978 .Slice, .Many, .C => true,
2979 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {2979 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
2980 .Array, .Vector => true,2980 .array, .vector => true,
2981 .Struct => ty.childType(zcu).isTuple(zcu),2981 .@"struct" => ty.childType(zcu).isTuple(zcu),
2982 else => false,2982 else => false,
2983 },2983 },
2984 },2984 },
2985 .Struct => ty.isTuple(zcu),2985 .@"struct" => ty.isTuple(zcu),
2986 else => false,2986 else => false,
2987 };2987 };
2988}2988}
29892989
2990pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {2990pub fn indexableHasLen(ty: Type, zcu: *const Zcu) bool {
2991 return switch (ty.zigTypeTag(zcu)) {2991 return switch (ty.zigTypeTag(zcu)) {
2992 .Array, .Vector => true,2992 .array, .vector => true,
2993 .Pointer => switch (ty.ptrSize(zcu)) {2993 .pointer => switch (ty.ptrSize(zcu)) {
2994 .Many, .C => false,2994 .Many, .C => false,
2995 .Slice => true,2995 .Slice => true,
2996 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {2996 .One => switch (ty.childType(zcu).zigTypeTag(zcu)) {
2997 .Array, .Vector => true,2997 .array, .vector => true,
2998 .Struct => ty.childType(zcu).isTuple(zcu),2998 .@"struct" => ty.childType(zcu).isTuple(zcu),
2999 else => false,2999 else => false,
3000 },3000 },
3001 },3001 },
3002 .Struct => ty.isTuple(zcu),3002 .@"struct" => ty.isTuple(zcu),
3003 else => false,3003 else => false,
3004 };3004 };
3005}3005}
...@@ -3030,7 +3030,7 @@ pub fn getParentNamespace(ty: Type, zcu: *Zcu) InternPool.OptionalNamespaceIndex...@@ -3030,7 +3030,7 @@ pub fn getParentNamespace(ty: Type, zcu: *Zcu) InternPool.OptionalNamespaceIndex
3030pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {3030pub fn minInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {
3031 const zcu = pt.zcu;3031 const zcu = pt.zcu;
3032 const scalar = try minIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu));3032 const scalar = try minIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu));
3033 return if (ty.zigTypeTag(zcu) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{3033 return if (ty.zigTypeTag(zcu) == .vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{
3034 .ty = dest_ty.toIntern(),3034 .ty = dest_ty.toIntern(),
3035 .storage = .{ .repeated_elem = scalar.toIntern() },3035 .storage = .{ .repeated_elem = scalar.toIntern() },
3036 } })) else scalar;3036 } })) else scalar;
...@@ -3061,7 +3061,7 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {...@@ -3061,7 +3061,7 @@ pub fn minIntScalar(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {
3061pub fn maxInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {3061pub fn maxInt(ty: Type, pt: Zcu.PerThread, dest_ty: Type) !Value {
3062 const zcu = pt.zcu;3062 const zcu = pt.zcu;
3063 const scalar = try maxIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu));3063 const scalar = try maxIntScalar(ty.scalarType(zcu), pt, dest_ty.scalarType(zcu));
3064 return if (ty.zigTypeTag(zcu) == .Vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{3064 return if (ty.zigTypeTag(zcu) == .vector) Value.fromInterned(try pt.intern(.{ .aggregate = .{
3065 .ty = dest_ty.toIntern(),3065 .ty = dest_ty.toIntern(),
3066 .storage = .{ .repeated_elem = scalar.toIntern() },3066 .storage = .{ .repeated_elem = scalar.toIntern() },
3067 } })) else scalar;3067 } })) else scalar;
...@@ -3539,8 +3539,8 @@ pub fn isSimpleTupleOrAnonStruct(ty: Type, zcu: *const Zcu) bool {...@@ -3539,8 +3539,8 @@ pub fn isSimpleTupleOrAnonStruct(ty: Type, zcu: *const Zcu) bool {
3539pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type {3539pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type {
3540 var cur = ty;3540 var cur = ty;
3541 while (true) switch (cur.zigTypeTag(zcu)) {3541 while (true) switch (cur.zigTypeTag(zcu)) {
3542 .Optional => cur = cur.optionalChild(zcu),3542 .optional => cur = cur.optionalChild(zcu),
3543 .ErrorUnion => cur = cur.errorUnionPayload(zcu),3543 .error_union => cur = cur.errorUnionPayload(zcu),
3544 else => return cur,3544 else => return cur,
3545 };3545 };
3546}3546}
...@@ -3548,8 +3548,8 @@ pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type {...@@ -3548,8 +3548,8 @@ pub fn optEuBaseType(ty: Type, zcu: *const Zcu) Type {
3548pub fn toUnsigned(ty: Type, pt: Zcu.PerThread) !Type {3548pub fn toUnsigned(ty: Type, pt: Zcu.PerThread) !Type {
3549 const zcu = pt.zcu;3549 const zcu = pt.zcu;
3550 return switch (ty.zigTypeTag(zcu)) {3550 return switch (ty.zigTypeTag(zcu)) {
3551 .Int => pt.intType(.unsigned, ty.intInfo(zcu).bits),3551 .int => pt.intType(.unsigned, ty.intInfo(zcu).bits),
3552 .Vector => try pt.vectorType(.{3552 .vector => try pt.vectorType(.{
3553 .len = ty.vectorLen(zcu),3553 .len = ty.vectorLen(zcu),
3554 .child = (try ty.childType(zcu).toUnsigned(pt)).toIntern(),3554 .child = (try ty.childType(zcu).toUnsigned(pt)).toIntern(),
3555 }),3555 }),
...@@ -3625,7 +3625,7 @@ pub fn getCaptures(ty: Type, zcu: *const Zcu) InternPool.CaptureValue.Slice {...@@ -3625,7 +3625,7 @@ pub fn getCaptures(ty: Type, zcu: *const Zcu) InternPool.CaptureValue.Slice {
3625pub fn arrayBase(ty: Type, zcu: *const Zcu) struct { Type, u64 } {3625pub fn arrayBase(ty: Type, zcu: *const Zcu) struct { Type, u64 } {
3626 var cur_ty: Type = ty;3626 var cur_ty: Type = ty;
3627 var cur_len: u64 = 1;3627 var cur_len: u64 = 1;
3628 while (cur_ty.zigTypeTag(zcu) == .Array) {3628 while (cur_ty.zigTypeTag(zcu) == .array) {
3629 cur_len *= cur_ty.arrayLenIncludingSentinel(zcu);3629 cur_len *= cur_ty.arrayLenIncludingSentinel(zcu);
3630 cur_ty = cur_ty.childType(zcu);3630 cur_ty = cur_ty.childType(zcu);
3631 }3631 }
...@@ -3692,7 +3692,7 @@ pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3692,7 +3692,7 @@ pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void {
3692 const zcu = pt.zcu;3692 const zcu = pt.zcu;
3693 const ip = &zcu.intern_pool;3693 const ip = &zcu.intern_pool;
3694 switch (ty.zigTypeTag(zcu)) {3694 switch (ty.zigTypeTag(zcu)) {
3695 .Struct => switch (ip.indexToKey(ty.toIntern())) {3695 .@"struct" => switch (ip.indexToKey(ty.toIntern())) {
3696 .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| {3696 .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| {
3697 const field_ty = Type.fromInterned(anon_struct_type.types.get(ip)[i]);3697 const field_ty = Type.fromInterned(anon_struct_type.types.get(ip)[i]);
3698 try field_ty.resolveLayout(pt);3698 try field_ty.resolveLayout(pt);
...@@ -3700,21 +3700,21 @@ pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3700,21 +3700,21 @@ pub fn resolveLayout(ty: Type, pt: Zcu.PerThread) SemaError!void {
3700 .struct_type => return ty.resolveStructInner(pt, .layout),3700 .struct_type => return ty.resolveStructInner(pt, .layout),
3701 else => unreachable,3701 else => unreachable,
3702 },3702 },
3703 .Union => return ty.resolveUnionInner(pt, .layout),3703 .@"union" => return ty.resolveUnionInner(pt, .layout),
3704 .Array => {3704 .array => {
3705 if (ty.arrayLenIncludingSentinel(zcu) == 0) return;3705 if (ty.arrayLenIncludingSentinel(zcu) == 0) return;
3706 const elem_ty = ty.childType(zcu);3706 const elem_ty = ty.childType(zcu);
3707 return elem_ty.resolveLayout(pt);3707 return elem_ty.resolveLayout(pt);
3708 },3708 },
3709 .Optional => {3709 .optional => {
3710 const payload_ty = ty.optionalChild(zcu);3710 const payload_ty = ty.optionalChild(zcu);
3711 return payload_ty.resolveLayout(pt);3711 return payload_ty.resolveLayout(pt);
3712 },3712 },
3713 .ErrorUnion => {3713 .error_union => {
3714 const payload_ty = ty.errorUnionPayload(zcu);3714 const payload_ty = ty.errorUnionPayload(zcu);
3715 return payload_ty.resolveLayout(pt);3715 return payload_ty.resolveLayout(pt);
3716 },3716 },
3717 .Fn => {3717 .@"fn" => {
3718 const info = zcu.typeToFunc(ty).?;3718 const info = zcu.typeToFunc(ty).?;
3719 if (info.is_generic) {3719 if (info.is_generic) {
3720 // Resolving of generic function types is deferred to when3720 // Resolving of generic function types is deferred to when
...@@ -3830,30 +3830,30 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3830,30 +3830,30 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {
3830 const ip = &zcu.intern_pool;3830 const ip = &zcu.intern_pool;
38313831
3832 switch (ty.zigTypeTag(zcu)) {3832 switch (ty.zigTypeTag(zcu)) {
3833 .Type,3833 .type,
3834 .Void,3834 .void,
3835 .Bool,3835 .bool,
3836 .NoReturn,3836 .noreturn,
3837 .Int,3837 .int,
3838 .Float,3838 .float,
3839 .ComptimeFloat,3839 .comptime_float,
3840 .ComptimeInt,3840 .comptime_int,
3841 .Undefined,3841 .undefined,
3842 .Null,3842 .null,
3843 .ErrorSet,3843 .error_set,
3844 .Enum,3844 .@"enum",
3845 .Opaque,3845 .@"opaque",
3846 .Frame,3846 .frame,
3847 .AnyFrame,3847 .@"anyframe",
3848 .Vector,3848 .vector,
3849 .EnumLiteral,3849 .enum_literal,
3850 => {},3850 => {},
38513851
3852 .Pointer => return ty.childType(zcu).resolveFully(pt),3852 .pointer => return ty.childType(zcu).resolveFully(pt),
3853 .Array => return ty.childType(zcu).resolveFully(pt),3853 .array => return ty.childType(zcu).resolveFully(pt),
3854 .Optional => return ty.optionalChild(zcu).resolveFully(pt),3854 .optional => return ty.optionalChild(zcu).resolveFully(pt),
3855 .ErrorUnion => return ty.errorUnionPayload(zcu).resolveFully(pt),3855 .error_union => return ty.errorUnionPayload(zcu).resolveFully(pt),
3856 .Fn => {3856 .@"fn" => {
3857 const info = zcu.typeToFunc(ty).?;3857 const info = zcu.typeToFunc(ty).?;
3858 if (info.is_generic) return;3858 if (info.is_generic) return;
3859 for (0..info.param_types.len) |i| {3859 for (0..info.param_types.len) |i| {
...@@ -3863,7 +3863,7 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3863,7 +3863,7 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {
3863 try Type.fromInterned(info.return_type).resolveFully(pt);3863 try Type.fromInterned(info.return_type).resolveFully(pt);
3864 },3864 },
38653865
3866 .Struct => switch (ip.indexToKey(ty.toIntern())) {3866 .@"struct" => switch (ip.indexToKey(ty.toIntern())) {
3867 .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| {3867 .anon_struct_type => |anon_struct_type| for (0..anon_struct_type.types.len) |i| {
3868 const field_ty = Type.fromInterned(anon_struct_type.types.get(ip)[i]);3868 const field_ty = Type.fromInterned(anon_struct_type.types.get(ip)[i]);
3869 try field_ty.resolveFully(pt);3869 try field_ty.resolveFully(pt);
...@@ -3871,7 +3871,7 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {...@@ -3871,7 +3871,7 @@ pub fn resolveFully(ty: Type, pt: Zcu.PerThread) SemaError!void {
3871 .struct_type => return ty.resolveStructInner(pt, .full),3871 .struct_type => return ty.resolveStructInner(pt, .full),
3872 else => unreachable,3872 else => unreachable,
3873 },3873 },
3874 .Union => return ty.resolveUnionInner(pt, .full),3874 .@"union" => return ty.resolveUnionInner(pt, .full),
3875 }3875 }
3876}3876}
38773877
src/Value.zig+130-130
...@@ -64,7 +64,7 @@ pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Formatter(print_...@@ -64,7 +64,7 @@ pub fn fmtValueSemaFull(ctx: print_value.FormatContext) std.fmt.Formatter(print_
64/// Asserts `val` is an array of `u8`64/// Asserts `val` is an array of `u8`
65pub fn toIpString(val: Value, ty: Type, pt: Zcu.PerThread) !InternPool.NullTerminatedString {65pub fn toIpString(val: Value, ty: Type, pt: Zcu.PerThread) !InternPool.NullTerminatedString {
66 const zcu = pt.zcu;66 const zcu = pt.zcu;
67 assert(ty.zigTypeTag(zcu) == .Array);67 assert(ty.zigTypeTag(zcu) == .array);
68 assert(ty.childType(zcu).toIntern() == .u8_type);68 assert(ty.childType(zcu).toIntern() == .u8_type);
69 const ip = &zcu.intern_pool;69 const ip = &zcu.intern_pool;
70 switch (zcu.intern_pool.indexToKey(val.toIntern()).aggregate.storage) {70 switch (zcu.intern_pool.indexToKey(val.toIntern()).aggregate.storage) {
...@@ -349,12 +349,12 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{...@@ -349,12 +349,12 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
349 return;349 return;
350 }350 }
351 switch (ty.zigTypeTag(zcu)) {351 switch (ty.zigTypeTag(zcu)) {
352 .Void => {},352 .void => {},
353 .Bool => {353 .bool => {
354 buffer[0] = @intFromBool(val.toBool());354 buffer[0] = @intFromBool(val.toBool());
355 },355 },
356 .Int, .Enum, .ErrorSet, .Pointer => |tag| {356 .int, .@"enum", .error_set, .pointer => |tag| {
357 const int_ty = if (tag == .Pointer) int_ty: {357 const int_ty = if (tag == .pointer) int_ty: {
358 if (ty.isSlice(zcu)) return error.IllDefinedMemoryLayout;358 if (ty.isSlice(zcu)) return error.IllDefinedMemoryLayout;
359 if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef;359 if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef;
360 break :int_ty Type.usize;360 break :int_ty Type.usize;
...@@ -367,7 +367,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{...@@ -367,7 +367,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
367 const bigint = val.toBigInt(&bigint_buffer, zcu);367 const bigint = val.toBigInt(&bigint_buffer, zcu);
368 bigint.writeTwosComplement(buffer[0..byte_count], endian);368 bigint.writeTwosComplement(buffer[0..byte_count], endian);
369 },369 },
370 .Float => switch (ty.floatBits(target)) {370 .float => switch (ty.floatBits(target)) {
371 16 => std.mem.writeInt(u16, buffer[0..2], @bitCast(val.toFloat(f16, zcu)), endian),371 16 => std.mem.writeInt(u16, buffer[0..2], @bitCast(val.toFloat(f16, zcu)), endian),
372 32 => std.mem.writeInt(u32, buffer[0..4], @bitCast(val.toFloat(f32, zcu)), endian),372 32 => std.mem.writeInt(u32, buffer[0..4], @bitCast(val.toFloat(f32, zcu)), endian),
373 64 => std.mem.writeInt(u64, buffer[0..8], @bitCast(val.toFloat(f64, zcu)), endian),373 64 => std.mem.writeInt(u64, buffer[0..8], @bitCast(val.toFloat(f64, zcu)), endian),
...@@ -375,7 +375,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{...@@ -375,7 +375,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
375 128 => std.mem.writeInt(u128, buffer[0..16], @bitCast(val.toFloat(f128, zcu)), endian),375 128 => std.mem.writeInt(u128, buffer[0..16], @bitCast(val.toFloat(f128, zcu)), endian),
376 else => unreachable,376 else => unreachable,
377 },377 },
378 .Array => {378 .array => {
379 const len = ty.arrayLen(zcu);379 const len = ty.arrayLen(zcu);
380 const elem_ty = ty.childType(zcu);380 const elem_ty = ty.childType(zcu);
381 const elem_size: usize = @intCast(elem_ty.abiSize(zcu));381 const elem_size: usize = @intCast(elem_ty.abiSize(zcu));
...@@ -387,13 +387,13 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{...@@ -387,13 +387,13 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
387 buf_off += elem_size;387 buf_off += elem_size;
388 }388 }
389 },389 },
390 .Vector => {390 .vector => {
391 // We use byte_count instead of abi_size here, so that any padding bytes391 // We use byte_count instead of abi_size here, so that any padding bytes
392 // follow the data bytes, on both big- and little-endian systems.392 // follow the data bytes, on both big- and little-endian systems.
393 const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8;393 const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8;
394 return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0);394 return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0);
395 },395 },
396 .Struct => {396 .@"struct" => {
397 const struct_type = zcu.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout;397 const struct_type = zcu.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout;
398 switch (struct_type.layout) {398 switch (struct_type.layout) {
399 .auto => return error.IllDefinedMemoryLayout,399 .auto => return error.IllDefinedMemoryLayout,
...@@ -415,7 +415,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{...@@ -415,7 +415,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
415 },415 },
416 }416 }
417 },417 },
418 .Union => switch (ty.containerLayout(zcu)) {418 .@"union" => switch (ty.containerLayout(zcu)) {
419 .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already419 .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already
420 .@"extern" => {420 .@"extern" => {
421 if (val.unionTag(zcu)) |union_tag| {421 if (val.unionTag(zcu)) |union_tag| {
...@@ -437,7 +437,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{...@@ -437,7 +437,7 @@ pub fn writeToMemory(val: Value, pt: Zcu.PerThread, buffer: []u8) error{
437 return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0);437 return writeToPackedMemory(val, ty, pt, buffer[0..byte_count], 0);
438 },438 },
439 },439 },
440 .Optional => {440 .optional => {
441 if (!ty.isPtrLikeOptional(zcu)) return error.IllDefinedMemoryLayout;441 if (!ty.isPtrLikeOptional(zcu)) return error.IllDefinedMemoryLayout;
442 const opt_val = val.optionalValue(zcu);442 const opt_val = val.optionalValue(zcu);
443 if (opt_val) |some| {443 if (opt_val) |some| {
...@@ -473,8 +473,8 @@ pub fn writeToPackedMemory(...@@ -473,8 +473,8 @@ pub fn writeToPackedMemory(
473 return;473 return;
474 }474 }
475 switch (ty.zigTypeTag(zcu)) {475 switch (ty.zigTypeTag(zcu)) {
476 .Void => {},476 .void => {},
477 .Bool => {477 .bool => {
478 const byte_index = switch (endian) {478 const byte_index = switch (endian) {
479 .little => bit_offset / 8,479 .little => bit_offset / 8,
480 .big => buffer.len - bit_offset / 8 - 1,480 .big => buffer.len - bit_offset / 8 - 1,
...@@ -485,7 +485,7 @@ pub fn writeToPackedMemory(...@@ -485,7 +485,7 @@ pub fn writeToPackedMemory(
485 buffer[byte_index] &= ~(@as(u8, 1) << @as(u3, @intCast(bit_offset % 8)));485 buffer[byte_index] &= ~(@as(u8, 1) << @as(u3, @intCast(bit_offset % 8)));
486 }486 }
487 },487 },
488 .Int, .Enum => {488 .int, .@"enum" => {
489 if (buffer.len == 0) return;489 if (buffer.len == 0) return;
490 const bits = ty.intInfo(zcu).bits;490 const bits = ty.intInfo(zcu).bits;
491 if (bits == 0) return;491 if (bits == 0) return;
...@@ -503,7 +503,7 @@ pub fn writeToPackedMemory(...@@ -503,7 +503,7 @@ pub fn writeToPackedMemory(
503 },503 },
504 }504 }
505 },505 },
506 .Float => switch (ty.floatBits(target)) {506 .float => switch (ty.floatBits(target)) {
507 16 => std.mem.writePackedInt(u16, buffer, bit_offset, @bitCast(val.toFloat(f16, zcu)), endian),507 16 => std.mem.writePackedInt(u16, buffer, bit_offset, @bitCast(val.toFloat(f16, zcu)), endian),
508 32 => std.mem.writePackedInt(u32, buffer, bit_offset, @bitCast(val.toFloat(f32, zcu)), endian),508 32 => std.mem.writePackedInt(u32, buffer, bit_offset, @bitCast(val.toFloat(f32, zcu)), endian),
509 64 => std.mem.writePackedInt(u64, buffer, bit_offset, @bitCast(val.toFloat(f64, zcu)), endian),509 64 => std.mem.writePackedInt(u64, buffer, bit_offset, @bitCast(val.toFloat(f64, zcu)), endian),
...@@ -511,7 +511,7 @@ pub fn writeToPackedMemory(...@@ -511,7 +511,7 @@ pub fn writeToPackedMemory(
511 128 => std.mem.writePackedInt(u128, buffer, bit_offset, @bitCast(val.toFloat(f128, zcu)), endian),511 128 => std.mem.writePackedInt(u128, buffer, bit_offset, @bitCast(val.toFloat(f128, zcu)), endian),
512 else => unreachable,512 else => unreachable,
513 },513 },
514 .Vector => {514 .vector => {
515 const elem_ty = ty.childType(zcu);515 const elem_ty = ty.childType(zcu);
516 const elem_bit_size: u16 = @intCast(elem_ty.bitSize(zcu));516 const elem_bit_size: u16 = @intCast(elem_ty.bitSize(zcu));
517 const len: usize = @intCast(ty.arrayLen(zcu));517 const len: usize = @intCast(ty.arrayLen(zcu));
...@@ -526,7 +526,7 @@ pub fn writeToPackedMemory(...@@ -526,7 +526,7 @@ pub fn writeToPackedMemory(
526 bits += elem_bit_size;526 bits += elem_bit_size;
527 }527 }
528 },528 },
529 .Struct => {529 .@"struct" => {
530 const struct_type = ip.loadStructType(ty.toIntern());530 const struct_type = ip.loadStructType(ty.toIntern());
531 // Sema is supposed to have emitted a compile error already in the case of Auto,531 // Sema is supposed to have emitted a compile error already in the case of Auto,
532 // and Extern is handled in non-packed writeToMemory.532 // and Extern is handled in non-packed writeToMemory.
...@@ -544,7 +544,7 @@ pub fn writeToPackedMemory(...@@ -544,7 +544,7 @@ pub fn writeToPackedMemory(
544 bits += field_bits;544 bits += field_bits;
545 }545 }
546 },546 },
547 .Union => {547 .@"union" => {
548 const union_obj = zcu.typeToUnion(ty).?;548 const union_obj = zcu.typeToUnion(ty).?;
549 switch (union_obj.flagsUnordered(ip).layout) {549 switch (union_obj.flagsUnordered(ip).layout) {
550 .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory550 .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory
...@@ -561,12 +561,12 @@ pub fn writeToPackedMemory(...@@ -561,12 +561,12 @@ pub fn writeToPackedMemory(
561 },561 },
562 }562 }
563 },563 },
564 .Pointer => {564 .pointer => {
565 assert(!ty.isSlice(zcu)); // No well defined layout.565 assert(!ty.isSlice(zcu)); // No well defined layout.
566 if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef;566 if (ip.getBackingAddrTag(val.toIntern()).? != .int) return error.ReinterpretDeclRef;
567 return val.writeToPackedMemory(Type.usize, pt, buffer, bit_offset);567 return val.writeToPackedMemory(Type.usize, pt, buffer, bit_offset);
568 },568 },
569 .Optional => {569 .optional => {
570 assert(ty.isPtrLikeOptional(zcu));570 assert(ty.isPtrLikeOptional(zcu));
571 const child = ty.optionalChild(zcu);571 const child = ty.optionalChild(zcu);
572 const opt_val = val.optionalValue(zcu);572 const opt_val = val.optionalValue(zcu);
...@@ -599,18 +599,18 @@ pub fn readFromMemory(...@@ -599,18 +599,18 @@ pub fn readFromMemory(
599 const target = zcu.getTarget();599 const target = zcu.getTarget();
600 const endian = target.cpu.arch.endian();600 const endian = target.cpu.arch.endian();
601 switch (ty.zigTypeTag(zcu)) {601 switch (ty.zigTypeTag(zcu)) {
602 .Void => return Value.void,602 .void => return Value.void,
603 .Bool => {603 .bool => {
604 if (buffer[0] == 0) {604 if (buffer[0] == 0) {
605 return Value.false;605 return Value.false;
606 } else {606 } else {
607 return Value.true;607 return Value.true;
608 }608 }
609 },609 },
610 .Int, .Enum => |ty_tag| {610 .int, .@"enum" => |ty_tag| {
611 const int_ty = switch (ty_tag) {611 const int_ty = switch (ty_tag) {
612 .Int => ty,612 .int => ty,
613 .Enum => ty.intTagType(zcu),613 .@"enum" => ty.intTagType(zcu),
614 else => unreachable,614 else => unreachable,
615 };615 };
616 const int_info = int_ty.intInfo(zcu);616 const int_info = int_ty.intInfo(zcu);
...@@ -639,7 +639,7 @@ pub fn readFromMemory(...@@ -639,7 +639,7 @@ pub fn readFromMemory(
639 return zcu.getCoerced(try zcu.intValue_big(int_ty, bigint.toConst()), ty);639 return zcu.getCoerced(try zcu.intValue_big(int_ty, bigint.toConst()), ty);
640 }640 }
641 },641 },
642 .Float => return Value.fromInterned(try pt.intern(.{ .float = .{642 .float => return Value.fromInterned(try pt.intern(.{ .float = .{
643 .ty = ty.toIntern(),643 .ty = ty.toIntern(),
644 .storage = switch (ty.floatBits(target)) {644 .storage = switch (ty.floatBits(target)) {
645 16 => .{ .f16 = @bitCast(std.mem.readInt(u16, buffer[0..2], endian)) },645 16 => .{ .f16 = @bitCast(std.mem.readInt(u16, buffer[0..2], endian)) },
...@@ -650,7 +650,7 @@ pub fn readFromMemory(...@@ -650,7 +650,7 @@ pub fn readFromMemory(
650 else => unreachable,650 else => unreachable,
651 },651 },
652 } })),652 } })),
653 .Array => {653 .array => {
654 const elem_ty = ty.childType(zcu);654 const elem_ty = ty.childType(zcu);
655 const elem_size = elem_ty.abiSize(zcu);655 const elem_size = elem_ty.abiSize(zcu);
656 const elems = try arena.alloc(InternPool.Index, @intCast(ty.arrayLen(zcu)));656 const elems = try arena.alloc(InternPool.Index, @intCast(ty.arrayLen(zcu)));
...@@ -664,13 +664,13 @@ pub fn readFromMemory(...@@ -664,13 +664,13 @@ pub fn readFromMemory(
664 .storage = .{ .elems = elems },664 .storage = .{ .elems = elems },
665 } }));665 } }));
666 },666 },
667 .Vector => {667 .vector => {
668 // We use byte_count instead of abi_size here, so that any padding bytes668 // We use byte_count instead of abi_size here, so that any padding bytes
669 // follow the data bytes, on both big- and little-endian systems.669 // follow the data bytes, on both big- and little-endian systems.
670 const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8;670 const byte_count = (@as(usize, @intCast(ty.bitSize(zcu))) + 7) / 8;
671 return readFromPackedMemory(ty, zcu, buffer[0..byte_count], 0, arena);671 return readFromPackedMemory(ty, zcu, buffer[0..byte_count], 0, arena);
672 },672 },
673 .Struct => {673 .@"struct" => {
674 const struct_type = zcu.typeToStruct(ty).?;674 const struct_type = zcu.typeToStruct(ty).?;
675 switch (struct_type.layout) {675 switch (struct_type.layout) {
676 .auto => unreachable, // Sema is supposed to have emitted a compile error already676 .auto => unreachable, // Sema is supposed to have emitted a compile error already
...@@ -694,7 +694,7 @@ pub fn readFromMemory(...@@ -694,7 +694,7 @@ pub fn readFromMemory(
694 },694 },
695 }695 }
696 },696 },
697 .ErrorSet => {697 .error_set => {
698 const bits = zcu.errorSetBits();698 const bits = zcu.errorSetBits();
699 const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8);699 const byte_count: u16 = @intCast((@as(u17, bits) + 7) / 8);
700 const int = std.mem.readVarInt(u64, buffer[0..byte_count], endian);700 const int = std.mem.readVarInt(u64, buffer[0..byte_count], endian);
...@@ -706,7 +706,7 @@ pub fn readFromMemory(...@@ -706,7 +706,7 @@ pub fn readFromMemory(
706 .name = name,706 .name = name,
707 } }));707 } }));
708 },708 },
709 .Union => switch (ty.containerLayout(zcu)) {709 .@"union" => switch (ty.containerLayout(zcu)) {
710 .auto => return error.IllDefinedMemoryLayout,710 .auto => return error.IllDefinedMemoryLayout,
711 .@"extern" => {711 .@"extern" => {
712 const union_size = ty.abiSize(zcu);712 const union_size = ty.abiSize(zcu);
...@@ -723,7 +723,7 @@ pub fn readFromMemory(...@@ -723,7 +723,7 @@ pub fn readFromMemory(
723 return readFromPackedMemory(ty, zcu, buffer[0..byte_count], 0, arena);723 return readFromPackedMemory(ty, zcu, buffer[0..byte_count], 0, arena);
724 },724 },
725 },725 },
726 .Pointer => {726 .pointer => {
727 assert(!ty.isSlice(zcu)); // No well defined layout.727 assert(!ty.isSlice(zcu)); // No well defined layout.
728 const int_val = try readFromMemory(Type.usize, zcu, buffer, arena);728 const int_val = try readFromMemory(Type.usize, zcu, buffer, arena);
729 return Value.fromInterned(try pt.intern(.{ .ptr = .{729 return Value.fromInterned(try pt.intern(.{ .ptr = .{
...@@ -732,7 +732,7 @@ pub fn readFromMemory(...@@ -732,7 +732,7 @@ pub fn readFromMemory(
732 .byte_offset = int_val.toUnsignedInt(zcu),732 .byte_offset = int_val.toUnsignedInt(zcu),
733 } }));733 } }));
734 },734 },
735 .Optional => {735 .optional => {
736 assert(ty.isPtrLikeOptional(zcu));736 assert(ty.isPtrLikeOptional(zcu));
737 const child_ty = ty.optionalChild(zcu);737 const child_ty = ty.optionalChild(zcu);
738 const child_val = try readFromMemory(child_ty, zcu, buffer, arena);738 const child_val = try readFromMemory(child_ty, zcu, buffer, arena);
...@@ -768,8 +768,8 @@ pub fn readFromPackedMemory(...@@ -768,8 +768,8 @@ pub fn readFromPackedMemory(
768 const target = zcu.getTarget();768 const target = zcu.getTarget();
769 const endian = target.cpu.arch.endian();769 const endian = target.cpu.arch.endian();
770 switch (ty.zigTypeTag(zcu)) {770 switch (ty.zigTypeTag(zcu)) {
771 .Void => return Value.void,771 .void => return Value.void,
772 .Bool => {772 .bool => {
773 const byte = switch (endian) {773 const byte = switch (endian) {
774 .big => buffer[buffer.len - bit_offset / 8 - 1],774 .big => buffer[buffer.len - bit_offset / 8 - 1],
775 .little => buffer[bit_offset / 8],775 .little => buffer[bit_offset / 8],
...@@ -780,7 +780,7 @@ pub fn readFromPackedMemory(...@@ -780,7 +780,7 @@ pub fn readFromPackedMemory(
780 return Value.true;780 return Value.true;
781 }781 }
782 },782 },
783 .Int => {783 .int => {
784 if (buffer.len == 0) return pt.intValue(ty, 0);784 if (buffer.len == 0) return pt.intValue(ty, 0);
785 const int_info = ty.intInfo(zcu);785 const int_info = ty.intInfo(zcu);
786 const bits = int_info.bits;786 const bits = int_info.bits;
...@@ -804,12 +804,12 @@ pub fn readFromPackedMemory(...@@ -804,12 +804,12 @@ pub fn readFromPackedMemory(
804 bigint.readPackedTwosComplement(buffer, bit_offset, bits, endian, int_info.signedness);804 bigint.readPackedTwosComplement(buffer, bit_offset, bits, endian, int_info.signedness);
805 return pt.intValue_big(ty, bigint.toConst());805 return pt.intValue_big(ty, bigint.toConst());
806 },806 },
807 .Enum => {807 .@"enum" => {
808 const int_ty = ty.intTagType(zcu);808 const int_ty = ty.intTagType(zcu);
809 const int_val = try Value.readFromPackedMemory(int_ty, pt, buffer, bit_offset, arena);809 const int_val = try Value.readFromPackedMemory(int_ty, pt, buffer, bit_offset, arena);
810 return pt.getCoerced(int_val, ty);810 return pt.getCoerced(int_val, ty);
811 },811 },
812 .Float => return Value.fromInterned(try pt.intern(.{ .float = .{812 .float => return Value.fromInterned(try pt.intern(.{ .float = .{
813 .ty = ty.toIntern(),813 .ty = ty.toIntern(),
814 .storage = switch (ty.floatBits(target)) {814 .storage = switch (ty.floatBits(target)) {
815 16 => .{ .f16 = @bitCast(std.mem.readPackedInt(u16, buffer, bit_offset, endian)) },815 16 => .{ .f16 = @bitCast(std.mem.readPackedInt(u16, buffer, bit_offset, endian)) },
...@@ -820,7 +820,7 @@ pub fn readFromPackedMemory(...@@ -820,7 +820,7 @@ pub fn readFromPackedMemory(
820 else => unreachable,820 else => unreachable,
821 },821 },
822 } })),822 } })),
823 .Vector => {823 .vector => {
824 const elem_ty = ty.childType(zcu);824 const elem_ty = ty.childType(zcu);
825 const elems = try arena.alloc(InternPool.Index, @intCast(ty.arrayLen(zcu)));825 const elems = try arena.alloc(InternPool.Index, @intCast(ty.arrayLen(zcu)));
826826
...@@ -837,7 +837,7 @@ pub fn readFromPackedMemory(...@@ -837,7 +837,7 @@ pub fn readFromPackedMemory(
837 .storage = .{ .elems = elems },837 .storage = .{ .elems = elems },
838 } }));838 } }));
839 },839 },
840 .Struct => {840 .@"struct" => {
841 // Sema is supposed to have emitted a compile error already for Auto layout structs,841 // Sema is supposed to have emitted a compile error already for Auto layout structs,
842 // and Extern is handled by non-packed readFromMemory.842 // and Extern is handled by non-packed readFromMemory.
843 const struct_type = zcu.typeToPackedStruct(ty).?;843 const struct_type = zcu.typeToPackedStruct(ty).?;
...@@ -854,7 +854,7 @@ pub fn readFromPackedMemory(...@@ -854,7 +854,7 @@ pub fn readFromPackedMemory(
854 .storage = .{ .elems = field_vals },854 .storage = .{ .elems = field_vals },
855 } }));855 } }));
856 },856 },
857 .Union => switch (ty.containerLayout(zcu)) {857 .@"union" => switch (ty.containerLayout(zcu)) {
858 .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory858 .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory
859 .@"packed" => {859 .@"packed" => {
860 const backing_ty = try ty.unionBackingType(pt);860 const backing_ty = try ty.unionBackingType(pt);
...@@ -866,7 +866,7 @@ pub fn readFromPackedMemory(...@@ -866,7 +866,7 @@ pub fn readFromPackedMemory(
866 } }));866 } }));
867 },867 },
868 },868 },
869 .Pointer => {869 .pointer => {
870 assert(!ty.isSlice(zcu)); // No well defined layout.870 assert(!ty.isSlice(zcu)); // No well defined layout.
871 const int_val = try readFromPackedMemory(Type.usize, pt, buffer, bit_offset, arena);871 const int_val = try readFromPackedMemory(Type.usize, pt, buffer, bit_offset, arena);
872 return Value.fromInterned(try pt.intern(.{ .ptr = .{872 return Value.fromInterned(try pt.intern(.{ .ptr = .{
...@@ -875,7 +875,7 @@ pub fn readFromPackedMemory(...@@ -875,7 +875,7 @@ pub fn readFromPackedMemory(
875 .byte_offset = int_val.toUnsignedInt(zcu),875 .byte_offset = int_val.toUnsignedInt(zcu),
876 } }));876 } }));
877 },877 },
878 .Optional => {878 .optional => {
879 assert(ty.isPtrLikeOptional(zcu));879 assert(ty.isPtrLikeOptional(zcu));
880 const child_ty = ty.optionalChild(zcu);880 const child_ty = ty.optionalChild(zcu);
881 const child_val = try readFromPackedMemory(child_ty, pt, buffer, bit_offset, arena);881 const child_val = try readFromPackedMemory(child_ty, pt, buffer, bit_offset, arena);
...@@ -1155,7 +1155,7 @@ pub fn compareHeteroAdvanced(...@@ -1155,7 +1155,7 @@ pub fn compareHeteroAdvanced(
1155/// For vectors, returns true if comparison is true for ALL elements.1155/// For vectors, returns true if comparison is true for ALL elements.
1156pub fn compareAll(lhs: Value, op: std.math.CompareOperator, rhs: Value, ty: Type, pt: Zcu.PerThread) !bool {1156pub fn compareAll(lhs: Value, op: std.math.CompareOperator, rhs: Value, ty: Type, pt: Zcu.PerThread) !bool {
1157 const zcu = pt.zcu;1157 const zcu = pt.zcu;
1158 if (ty.zigTypeTag(zcu) == .Vector) {1158 if (ty.zigTypeTag(zcu) == .vector) {
1159 const scalar_ty = ty.scalarType(zcu);1159 const scalar_ty = ty.scalarType(zcu);
1160 for (0..ty.vectorLen(zcu)) |i| {1160 for (0..ty.vectorLen(zcu)) |i| {
1161 const lhs_elem = try lhs.elemValue(pt, i);1161 const lhs_elem = try lhs.elemValue(pt, i);
...@@ -1519,7 +1519,7 @@ pub fn floatFromIntAdvanced(...@@ -1519,7 +1519,7 @@ pub fn floatFromIntAdvanced(
1519 comptime strat: ResolveStrat,1519 comptime strat: ResolveStrat,
1520) !Value {1520) !Value {
1521 const zcu = pt.zcu;1521 const zcu = pt.zcu;
1522 if (int_ty.zigTypeTag(zcu) == .Vector) {1522 if (int_ty.zigTypeTag(zcu) == .vector) {
1523 const result_data = try arena.alloc(InternPool.Index, int_ty.vectorLen(zcu));1523 const result_data = try arena.alloc(InternPool.Index, int_ty.vectorLen(zcu));
1524 const scalar_ty = float_ty.scalarType(zcu);1524 const scalar_ty = float_ty.scalarType(zcu);
1525 for (result_data, 0..) |*scalar, i| {1525 for (result_data, 0..) |*scalar, i| {
...@@ -1573,7 +1573,7 @@ fn calcLimbLenFloat(scalar: anytype) usize {...@@ -1573,7 +1573,7 @@ fn calcLimbLenFloat(scalar: anytype) usize {
1573 }1573 }
15741574
1575 const w_value = @abs(scalar);1575 const w_value = @abs(scalar);
1576 return @divFloor(@as(std.math.big.Limb, @intFromFloat(std.math.log2(w_value))), @typeInfo(std.math.big.Limb).Int.bits) + 1;1576 return @divFloor(@as(std.math.big.Limb, @intFromFloat(std.math.log2(w_value))), @typeInfo(std.math.big.Limb).int.bits) + 1;
1577}1577}
15781578
1579pub const OverflowArithmeticResult = struct {1579pub const OverflowArithmeticResult = struct {
...@@ -1589,7 +1589,7 @@ pub fn intAddSat(...@@ -1589,7 +1589,7 @@ pub fn intAddSat(
1589 arena: Allocator,1589 arena: Allocator,
1590 pt: Zcu.PerThread,1590 pt: Zcu.PerThread,
1591) !Value {1591) !Value {
1592 if (ty.zigTypeTag(pt.zcu) == .Vector) {1592 if (ty.zigTypeTag(pt.zcu) == .vector) {
1593 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));1593 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
1594 const scalar_ty = ty.scalarType(pt.zcu);1594 const scalar_ty = ty.scalarType(pt.zcu);
1595 for (result_data, 0..) |*scalar, i| {1595 for (result_data, 0..) |*scalar, i| {
...@@ -1640,7 +1640,7 @@ pub fn intSubSat(...@@ -1640,7 +1640,7 @@ pub fn intSubSat(
1640 arena: Allocator,1640 arena: Allocator,
1641 pt: Zcu.PerThread,1641 pt: Zcu.PerThread,
1642) !Value {1642) !Value {
1643 if (ty.zigTypeTag(pt.zcu) == .Vector) {1643 if (ty.zigTypeTag(pt.zcu) == .vector) {
1644 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));1644 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
1645 const scalar_ty = ty.scalarType(pt.zcu);1645 const scalar_ty = ty.scalarType(pt.zcu);
1646 for (result_data, 0..) |*scalar, i| {1646 for (result_data, 0..) |*scalar, i| {
...@@ -1692,7 +1692,7 @@ pub fn intMulWithOverflow(...@@ -1692,7 +1692,7 @@ pub fn intMulWithOverflow(
1692 pt: Zcu.PerThread,1692 pt: Zcu.PerThread,
1693) !OverflowArithmeticResult {1693) !OverflowArithmeticResult {
1694 const zcu = pt.zcu;1694 const zcu = pt.zcu;
1695 if (ty.zigTypeTag(zcu) == .Vector) {1695 if (ty.zigTypeTag(zcu) == .vector) {
1696 const vec_len = ty.vectorLen(zcu);1696 const vec_len = ty.vectorLen(zcu);
1697 const overflowed_data = try arena.alloc(InternPool.Index, vec_len);1697 const overflowed_data = try arena.alloc(InternPool.Index, vec_len);
1698 const result_data = try arena.alloc(InternPool.Index, vec_len);1698 const result_data = try arena.alloc(InternPool.Index, vec_len);
...@@ -1770,7 +1770,7 @@ pub fn numberMulWrap(...@@ -1770,7 +1770,7 @@ pub fn numberMulWrap(
1770 pt: Zcu.PerThread,1770 pt: Zcu.PerThread,
1771) !Value {1771) !Value {
1772 const zcu = pt.zcu;1772 const zcu = pt.zcu;
1773 if (ty.zigTypeTag(zcu) == .Vector) {1773 if (ty.zigTypeTag(zcu) == .vector) {
1774 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));1774 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));
1775 const scalar_ty = ty.scalarType(zcu);1775 const scalar_ty = ty.scalarType(zcu);
1776 for (result_data, 0..) |*scalar, i| {1776 for (result_data, 0..) |*scalar, i| {
...@@ -1797,7 +1797,7 @@ pub fn numberMulWrapScalar(...@@ -1797,7 +1797,7 @@ pub fn numberMulWrapScalar(
1797 const zcu = pt.zcu;1797 const zcu = pt.zcu;
1798 if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return Value.undef;1798 if (lhs.isUndef(zcu) or rhs.isUndef(zcu)) return Value.undef;
17991799
1800 if (ty.zigTypeTag(zcu) == .ComptimeInt) {1800 if (ty.zigTypeTag(zcu) == .comptime_int) {
1801 return intMul(lhs, rhs, ty, undefined, arena, pt);1801 return intMul(lhs, rhs, ty, undefined, arena, pt);
1802 }1802 }
18031803
...@@ -1817,7 +1817,7 @@ pub fn intMulSat(...@@ -1817,7 +1817,7 @@ pub fn intMulSat(
1817 arena: Allocator,1817 arena: Allocator,
1818 pt: Zcu.PerThread,1818 pt: Zcu.PerThread,
1819) !Value {1819) !Value {
1820 if (ty.zigTypeTag(pt.zcu) == .Vector) {1820 if (ty.zigTypeTag(pt.zcu) == .vector) {
1821 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));1821 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
1822 const scalar_ty = ty.scalarType(pt.zcu);1822 const scalar_ty = ty.scalarType(pt.zcu);
1823 for (result_data, 0..) |*scalar, i| {1823 for (result_data, 0..) |*scalar, i| {
...@@ -1897,7 +1897,7 @@ pub fn numberMin(lhs: Value, rhs: Value, zcu: *Zcu) Value {...@@ -1897,7 +1897,7 @@ pub fn numberMin(lhs: Value, rhs: Value, zcu: *Zcu) Value {
1897/// operands must be (vectors of) integers; handles undefined scalars.1897/// operands must be (vectors of) integers; handles undefined scalars.
1898pub fn bitwiseNot(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {1898pub fn bitwiseNot(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
1899 const zcu = pt.zcu;1899 const zcu = pt.zcu;
1900 if (ty.zigTypeTag(zcu) == .Vector) {1900 if (ty.zigTypeTag(zcu) == .vector) {
1901 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));1901 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));
1902 const scalar_ty = ty.scalarType(zcu);1902 const scalar_ty = ty.scalarType(zcu);
1903 for (result_data, 0..) |*scalar, i| {1903 for (result_data, 0..) |*scalar, i| {
...@@ -1941,7 +1941,7 @@ pub fn bitwiseNotScalar(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThrea...@@ -1941,7 +1941,7 @@ pub fn bitwiseNotScalar(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThrea
1941/// operands must be (vectors of) integers; handles undefined scalars.1941/// operands must be (vectors of) integers; handles undefined scalars.
1942pub fn bitwiseAnd(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {1942pub fn bitwiseAnd(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
1943 const zcu = pt.zcu;1943 const zcu = pt.zcu;
1944 if (ty.zigTypeTag(zcu) == .Vector) {1944 if (ty.zigTypeTag(zcu) == .vector) {
1945 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));1945 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
1946 const scalar_ty = ty.scalarType(zcu);1946 const scalar_ty = ty.scalarType(zcu);
1947 for (result_data, 0..) |*scalar, i| {1947 for (result_data, 0..) |*scalar, i| {
...@@ -2014,7 +2014,7 @@ fn intValueAa(ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {...@@ -2014,7 +2014,7 @@ fn intValueAa(ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
2014/// operands must be (vectors of) integers; handles undefined scalars.2014/// operands must be (vectors of) integers; handles undefined scalars.
2015pub fn bitwiseNand(lhs: Value, rhs: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {2015pub fn bitwiseNand(lhs: Value, rhs: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
2016 const zcu = pt.zcu;2016 const zcu = pt.zcu;
2017 if (ty.zigTypeTag(zcu) == .Vector) {2017 if (ty.zigTypeTag(zcu) == .vector) {
2018 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));2018 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));
2019 const scalar_ty = ty.scalarType(zcu);2019 const scalar_ty = ty.scalarType(zcu);
2020 for (result_data, 0..) |*scalar, i| {2020 for (result_data, 0..) |*scalar, i| {
...@@ -2044,7 +2044,7 @@ pub fn bitwiseNandScalar(lhs: Value, rhs: Value, ty: Type, arena: Allocator, pt:...@@ -2044,7 +2044,7 @@ pub fn bitwiseNandScalar(lhs: Value, rhs: Value, ty: Type, arena: Allocator, pt:
2044/// operands must be (vectors of) integers; handles undefined scalars.2044/// operands must be (vectors of) integers; handles undefined scalars.
2045pub fn bitwiseOr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {2045pub fn bitwiseOr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
2046 const zcu = pt.zcu;2046 const zcu = pt.zcu;
2047 if (ty.zigTypeTag(zcu) == .Vector) {2047 if (ty.zigTypeTag(zcu) == .vector) {
2048 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));2048 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
2049 const scalar_ty = ty.scalarType(zcu);2049 const scalar_ty = ty.scalarType(zcu);
2050 for (result_data, 0..) |*scalar, i| {2050 for (result_data, 0..) |*scalar, i| {
...@@ -2097,7 +2097,7 @@ pub fn bitwiseOrScalar(orig_lhs: Value, orig_rhs: Value, ty: Type, arena: Alloca...@@ -2097,7 +2097,7 @@ pub fn bitwiseOrScalar(orig_lhs: Value, orig_rhs: Value, ty: Type, arena: Alloca
2097/// operands must be (vectors of) integers; handles undefined scalars.2097/// operands must be (vectors of) integers; handles undefined scalars.
2098pub fn bitwiseXor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {2098pub fn bitwiseXor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
2099 const zcu = pt.zcu;2099 const zcu = pt.zcu;
2100 if (ty.zigTypeTag(zcu) == .Vector) {2100 if (ty.zigTypeTag(zcu) == .vector) {
2101 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));2101 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
2102 const scalar_ty = ty.scalarType(zcu);2102 const scalar_ty = ty.scalarType(zcu);
2103 for (result_data, 0..) |*scalar, i| {2103 for (result_data, 0..) |*scalar, i| {
...@@ -2157,7 +2157,7 @@ pub fn intDiv(lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize, allocator...@@ -2157,7 +2157,7 @@ pub fn intDiv(lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize, allocator
2157}2157}
21582158
2159fn intDivInner(lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize, allocator: Allocator, pt: Zcu.PerThread) !Value {2159fn intDivInner(lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize, allocator: Allocator, pt: Zcu.PerThread) !Value {
2160 if (ty.zigTypeTag(pt.zcu) == .Vector) {2160 if (ty.zigTypeTag(pt.zcu) == .vector) {
2161 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));2161 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
2162 const scalar_ty = ty.scalarType(pt.zcu);2162 const scalar_ty = ty.scalarType(pt.zcu);
2163 for (result_data, 0..) |*scalar, i| {2163 for (result_data, 0..) |*scalar, i| {
...@@ -2213,7 +2213,7 @@ pub fn intDivScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt:...@@ -2213,7 +2213,7 @@ pub fn intDivScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt:
2213}2213}
22142214
2215pub fn intDivFloor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {2215pub fn intDivFloor(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
2216 if (ty.zigTypeTag(pt.zcu) == .Vector) {2216 if (ty.zigTypeTag(pt.zcu) == .vector) {
2217 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));2217 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
2218 const scalar_ty = ty.scalarType(pt.zcu);2218 const scalar_ty = ty.scalarType(pt.zcu);
2219 for (result_data, 0..) |*scalar, i| {2219 for (result_data, 0..) |*scalar, i| {
...@@ -2256,7 +2256,7 @@ pub fn intDivFloorScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator,...@@ -2256,7 +2256,7 @@ pub fn intDivFloorScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator,
2256}2256}
22572257
2258pub fn intMod(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {2258pub fn intMod(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
2259 if (ty.zigTypeTag(pt.zcu) == .Vector) {2259 if (ty.zigTypeTag(pt.zcu) == .vector) {
2260 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));2260 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
2261 const scalar_ty = ty.scalarType(pt.zcu);2261 const scalar_ty = ty.scalarType(pt.zcu);
2262 for (result_data, 0..) |*scalar, i| {2262 for (result_data, 0..) |*scalar, i| {
...@@ -2328,7 +2328,7 @@ pub fn isNegativeInf(val: Value, zcu: *const Zcu) bool {...@@ -2328,7 +2328,7 @@ pub fn isNegativeInf(val: Value, zcu: *const Zcu) bool {
2328}2328}
23292329
2330pub fn floatRem(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {2330pub fn floatRem(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
2331 if (float_type.zigTypeTag(pt.zcu) == .Vector) {2331 if (float_type.zigTypeTag(pt.zcu) == .vector) {
2332 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));2332 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));
2333 const scalar_ty = float_type.scalarType(pt.zcu);2333 const scalar_ty = float_type.scalarType(pt.zcu);
2334 for (result_data, 0..) |*scalar, i| {2334 for (result_data, 0..) |*scalar, i| {
...@@ -2362,7 +2362,7 @@ pub fn floatRemScalar(lhs: Value, rhs: Value, float_type: Type, pt: Zcu.PerThrea...@@ -2362,7 +2362,7 @@ pub fn floatRemScalar(lhs: Value, rhs: Value, float_type: Type, pt: Zcu.PerThrea
2362}2362}
23632363
2364pub fn floatMod(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {2364pub fn floatMod(lhs: Value, rhs: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
2365 if (float_type.zigTypeTag(pt.zcu) == .Vector) {2365 if (float_type.zigTypeTag(pt.zcu) == .vector) {
2366 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));2366 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));
2367 const scalar_ty = float_type.scalarType(pt.zcu);2367 const scalar_ty = float_type.scalarType(pt.zcu);
2368 for (result_data, 0..) |*scalar, i| {2368 for (result_data, 0..) |*scalar, i| {
...@@ -2419,7 +2419,7 @@ pub fn intMul(lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize, allocator...@@ -2419,7 +2419,7 @@ pub fn intMul(lhs: Value, rhs: Value, ty: Type, overflow_idx: *?usize, allocator
24192419
2420fn intMulInner(lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize, allocator: Allocator, pt: Zcu.PerThread) !Value {2420fn intMulInner(lhs: Value, rhs: Value, ty: Type, overflow_idx: *usize, allocator: Allocator, pt: Zcu.PerThread) !Value {
2421 const zcu = pt.zcu;2421 const zcu = pt.zcu;
2422 if (ty.zigTypeTag(zcu) == .Vector) {2422 if (ty.zigTypeTag(zcu) == .vector) {
2423 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));2423 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
2424 const scalar_ty = ty.scalarType(zcu);2424 const scalar_ty = ty.scalarType(zcu);
2425 for (result_data, 0..) |*scalar, i| {2425 for (result_data, 0..) |*scalar, i| {
...@@ -2471,7 +2471,7 @@ pub fn intMulScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt:...@@ -2471,7 +2471,7 @@ pub fn intMulScalar(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt:
24712471
2472pub fn intTrunc(val: Value, ty: Type, allocator: Allocator, signedness: std.builtin.Signedness, bits: u16, pt: Zcu.PerThread) !Value {2472pub fn intTrunc(val: Value, ty: Type, allocator: Allocator, signedness: std.builtin.Signedness, bits: u16, pt: Zcu.PerThread) !Value {
2473 const zcu = pt.zcu;2473 const zcu = pt.zcu;
2474 if (ty.zigTypeTag(zcu) == .Vector) {2474 if (ty.zigTypeTag(zcu) == .vector) {
2475 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));2475 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
2476 const scalar_ty = ty.scalarType(zcu);2476 const scalar_ty = ty.scalarType(zcu);
2477 for (result_data, 0..) |*scalar, i| {2477 for (result_data, 0..) |*scalar, i| {
...@@ -2496,7 +2496,7 @@ pub fn intTruncBitsAsValue(...@@ -2496,7 +2496,7 @@ pub fn intTruncBitsAsValue(
2496 pt: Zcu.PerThread,2496 pt: Zcu.PerThread,
2497) !Value {2497) !Value {
2498 const zcu = pt.zcu;2498 const zcu = pt.zcu;
2499 if (ty.zigTypeTag(zcu) == .Vector) {2499 if (ty.zigTypeTag(zcu) == .vector) {
2500 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));2500 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
2501 const scalar_ty = ty.scalarType(zcu);2501 const scalar_ty = ty.scalarType(zcu);
2502 for (result_data, 0..) |*scalar, i| {2502 for (result_data, 0..) |*scalar, i| {
...@@ -2540,7 +2540,7 @@ pub fn intTruncScalar(...@@ -2540,7 +2540,7 @@ pub fn intTruncScalar(
25402540
2541pub fn shl(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {2541pub fn shl(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
2542 const zcu = pt.zcu;2542 const zcu = pt.zcu;
2543 if (ty.zigTypeTag(zcu) == .Vector) {2543 if (ty.zigTypeTag(zcu) == .vector) {
2544 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));2544 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(zcu));
2545 const scalar_ty = ty.scalarType(zcu);2545 const scalar_ty = ty.scalarType(zcu);
2546 for (result_data, 0..) |*scalar, i| {2546 for (result_data, 0..) |*scalar, i| {
...@@ -2588,7 +2588,7 @@ pub fn shlWithOverflow(...@@ -2588,7 +2588,7 @@ pub fn shlWithOverflow(
2588 allocator: Allocator,2588 allocator: Allocator,
2589 pt: Zcu.PerThread,2589 pt: Zcu.PerThread,
2590) !OverflowArithmeticResult {2590) !OverflowArithmeticResult {
2591 if (ty.zigTypeTag(pt.zcu) == .Vector) {2591 if (ty.zigTypeTag(pt.zcu) == .vector) {
2592 const vec_len = ty.vectorLen(pt.zcu);2592 const vec_len = ty.vectorLen(pt.zcu);
2593 const overflowed_data = try allocator.alloc(InternPool.Index, vec_len);2593 const overflowed_data = try allocator.alloc(InternPool.Index, vec_len);
2594 const result_data = try allocator.alloc(InternPool.Index, vec_len);2594 const result_data = try allocator.alloc(InternPool.Index, vec_len);
...@@ -2653,7 +2653,7 @@ pub fn shlSat(...@@ -2653,7 +2653,7 @@ pub fn shlSat(
2653 arena: Allocator,2653 arena: Allocator,
2654 pt: Zcu.PerThread,2654 pt: Zcu.PerThread,
2655) !Value {2655) !Value {
2656 if (ty.zigTypeTag(pt.zcu) == .Vector) {2656 if (ty.zigTypeTag(pt.zcu) == .vector) {
2657 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));2657 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
2658 const scalar_ty = ty.scalarType(pt.zcu);2658 const scalar_ty = ty.scalarType(pt.zcu);
2659 for (result_data, 0..) |*scalar, i| {2659 for (result_data, 0..) |*scalar, i| {
...@@ -2704,7 +2704,7 @@ pub fn shlTrunc(...@@ -2704,7 +2704,7 @@ pub fn shlTrunc(
2704 arena: Allocator,2704 arena: Allocator,
2705 pt: Zcu.PerThread,2705 pt: Zcu.PerThread,
2706) !Value {2706) !Value {
2707 if (ty.zigTypeTag(pt.zcu) == .Vector) {2707 if (ty.zigTypeTag(pt.zcu) == .vector) {
2708 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));2708 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
2709 const scalar_ty = ty.scalarType(pt.zcu);2709 const scalar_ty = ty.scalarType(pt.zcu);
2710 for (result_data, 0..) |*scalar, i| {2710 for (result_data, 0..) |*scalar, i| {
...@@ -2734,7 +2734,7 @@ pub fn shlTruncScalar(...@@ -2734,7 +2734,7 @@ pub fn shlTruncScalar(
2734}2734}
27352735
2736pub fn shr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {2736pub fn shr(lhs: Value, rhs: Value, ty: Type, allocator: Allocator, pt: Zcu.PerThread) !Value {
2737 if (ty.zigTypeTag(pt.zcu) == .Vector) {2737 if (ty.zigTypeTag(pt.zcu) == .vector) {
2738 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));2738 const result_data = try allocator.alloc(InternPool.Index, ty.vectorLen(pt.zcu));
2739 const scalar_ty = ty.scalarType(pt.zcu);2739 const scalar_ty = ty.scalarType(pt.zcu);
2740 for (result_data, 0..) |*scalar, i| {2740 for (result_data, 0..) |*scalar, i| {
...@@ -2789,7 +2789,7 @@ pub fn floatNeg(...@@ -2789,7 +2789,7 @@ pub fn floatNeg(
2789 pt: Zcu.PerThread,2789 pt: Zcu.PerThread,
2790) !Value {2790) !Value {
2791 const zcu = pt.zcu;2791 const zcu = pt.zcu;
2792 if (float_type.zigTypeTag(zcu) == .Vector) {2792 if (float_type.zigTypeTag(zcu) == .vector) {
2793 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));2793 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
2794 const scalar_ty = float_type.scalarType(zcu);2794 const scalar_ty = float_type.scalarType(zcu);
2795 for (result_data, 0..) |*scalar, i| {2795 for (result_data, 0..) |*scalar, i| {
...@@ -2829,7 +2829,7 @@ pub fn floatAdd(...@@ -2829,7 +2829,7 @@ pub fn floatAdd(
2829 pt: Zcu.PerThread,2829 pt: Zcu.PerThread,
2830) !Value {2830) !Value {
2831 const zcu = pt.zcu;2831 const zcu = pt.zcu;
2832 if (float_type.zigTypeTag(zcu) == .Vector) {2832 if (float_type.zigTypeTag(zcu) == .vector) {
2833 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));2833 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
2834 const scalar_ty = float_type.scalarType(zcu);2834 const scalar_ty = float_type.scalarType(zcu);
2835 for (result_data, 0..) |*scalar, i| {2835 for (result_data, 0..) |*scalar, i| {
...@@ -2875,7 +2875,7 @@ pub fn floatSub(...@@ -2875,7 +2875,7 @@ pub fn floatSub(
2875 pt: Zcu.PerThread,2875 pt: Zcu.PerThread,
2876) !Value {2876) !Value {
2877 const zcu = pt.zcu;2877 const zcu = pt.zcu;
2878 if (float_type.zigTypeTag(zcu) == .Vector) {2878 if (float_type.zigTypeTag(zcu) == .vector) {
2879 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));2879 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
2880 const scalar_ty = float_type.scalarType(zcu);2880 const scalar_ty = float_type.scalarType(zcu);
2881 for (result_data, 0..) |*scalar, i| {2881 for (result_data, 0..) |*scalar, i| {
...@@ -2920,7 +2920,7 @@ pub fn floatDiv(...@@ -2920,7 +2920,7 @@ pub fn floatDiv(
2920 arena: Allocator,2920 arena: Allocator,
2921 pt: Zcu.PerThread,2921 pt: Zcu.PerThread,
2922) !Value {2922) !Value {
2923 if (float_type.zigTypeTag(pt.zcu) == .Vector) {2923 if (float_type.zigTypeTag(pt.zcu) == .vector) {
2924 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));2924 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));
2925 const scalar_ty = float_type.scalarType(pt.zcu);2925 const scalar_ty = float_type.scalarType(pt.zcu);
2926 for (result_data, 0..) |*scalar, i| {2926 for (result_data, 0..) |*scalar, i| {
...@@ -2965,7 +2965,7 @@ pub fn floatDivFloor(...@@ -2965,7 +2965,7 @@ pub fn floatDivFloor(
2965 arena: Allocator,2965 arena: Allocator,
2966 pt: Zcu.PerThread,2966 pt: Zcu.PerThread,
2967) !Value {2967) !Value {
2968 if (float_type.zigTypeTag(pt.zcu) == .Vector) {2968 if (float_type.zigTypeTag(pt.zcu) == .vector) {
2969 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));2969 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));
2970 const scalar_ty = float_type.scalarType(pt.zcu);2970 const scalar_ty = float_type.scalarType(pt.zcu);
2971 for (result_data, 0..) |*scalar, i| {2971 for (result_data, 0..) |*scalar, i| {
...@@ -3010,7 +3010,7 @@ pub fn floatDivTrunc(...@@ -3010,7 +3010,7 @@ pub fn floatDivTrunc(
3010 arena: Allocator,3010 arena: Allocator,
3011 pt: Zcu.PerThread,3011 pt: Zcu.PerThread,
3012) !Value {3012) !Value {
3013 if (float_type.zigTypeTag(pt.zcu) == .Vector) {3013 if (float_type.zigTypeTag(pt.zcu) == .vector) {
3014 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));3014 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));
3015 const scalar_ty = float_type.scalarType(pt.zcu);3015 const scalar_ty = float_type.scalarType(pt.zcu);
3016 for (result_data, 0..) |*scalar, i| {3016 for (result_data, 0..) |*scalar, i| {
...@@ -3056,7 +3056,7 @@ pub fn floatMul(...@@ -3056,7 +3056,7 @@ pub fn floatMul(
3056 pt: Zcu.PerThread,3056 pt: Zcu.PerThread,
3057) !Value {3057) !Value {
3058 const zcu = pt.zcu;3058 const zcu = pt.zcu;
3059 if (float_type.zigTypeTag(zcu) == .Vector) {3059 if (float_type.zigTypeTag(zcu) == .vector) {
3060 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3060 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3061 const scalar_ty = float_type.scalarType(zcu);3061 const scalar_ty = float_type.scalarType(zcu);
3062 for (result_data, 0..) |*scalar, i| {3062 for (result_data, 0..) |*scalar, i| {
...@@ -3095,7 +3095,7 @@ pub fn floatMulScalar(...@@ -3095,7 +3095,7 @@ pub fn floatMulScalar(
3095}3095}
30963096
3097pub fn sqrt(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3097pub fn sqrt(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3098 if (float_type.zigTypeTag(pt.zcu) == .Vector) {3098 if (float_type.zigTypeTag(pt.zcu) == .vector) {
3099 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));3099 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(pt.zcu));
3100 const scalar_ty = float_type.scalarType(pt.zcu);3100 const scalar_ty = float_type.scalarType(pt.zcu);
3101 for (result_data, 0..) |*scalar, i| {3101 for (result_data, 0..) |*scalar, i| {
...@@ -3129,7 +3129,7 @@ pub fn sqrtScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err...@@ -3129,7 +3129,7 @@ pub fn sqrtScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err
31293129
3130pub fn sin(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3130pub fn sin(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3131 const zcu = pt.zcu;3131 const zcu = pt.zcu;
3132 if (float_type.zigTypeTag(zcu) == .Vector) {3132 if (float_type.zigTypeTag(zcu) == .vector) {
3133 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3133 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3134 const scalar_ty = float_type.scalarType(zcu);3134 const scalar_ty = float_type.scalarType(zcu);
3135 for (result_data, 0..) |*scalar, i| {3135 for (result_data, 0..) |*scalar, i| {
...@@ -3163,7 +3163,7 @@ pub fn sinScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro...@@ -3163,7 +3163,7 @@ pub fn sinScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro
31633163
3164pub fn cos(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3164pub fn cos(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3165 const zcu = pt.zcu;3165 const zcu = pt.zcu;
3166 if (float_type.zigTypeTag(zcu) == .Vector) {3166 if (float_type.zigTypeTag(zcu) == .vector) {
3167 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3167 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3168 const scalar_ty = float_type.scalarType(zcu);3168 const scalar_ty = float_type.scalarType(zcu);
3169 for (result_data, 0..) |*scalar, i| {3169 for (result_data, 0..) |*scalar, i| {
...@@ -3197,7 +3197,7 @@ pub fn cosScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro...@@ -3197,7 +3197,7 @@ pub fn cosScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro
31973197
3198pub fn tan(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3198pub fn tan(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3199 const zcu = pt.zcu;3199 const zcu = pt.zcu;
3200 if (float_type.zigTypeTag(zcu) == .Vector) {3200 if (float_type.zigTypeTag(zcu) == .vector) {
3201 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3201 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3202 const scalar_ty = float_type.scalarType(zcu);3202 const scalar_ty = float_type.scalarType(zcu);
3203 for (result_data, 0..) |*scalar, i| {3203 for (result_data, 0..) |*scalar, i| {
...@@ -3231,7 +3231,7 @@ pub fn tanScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro...@@ -3231,7 +3231,7 @@ pub fn tanScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro
32313231
3232pub fn exp(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3232pub fn exp(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3233 const zcu = pt.zcu;3233 const zcu = pt.zcu;
3234 if (float_type.zigTypeTag(zcu) == .Vector) {3234 if (float_type.zigTypeTag(zcu) == .vector) {
3235 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3235 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3236 const scalar_ty = float_type.scalarType(zcu);3236 const scalar_ty = float_type.scalarType(zcu);
3237 for (result_data, 0..) |*scalar, i| {3237 for (result_data, 0..) |*scalar, i| {
...@@ -3265,7 +3265,7 @@ pub fn expScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro...@@ -3265,7 +3265,7 @@ pub fn expScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro
32653265
3266pub fn exp2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3266pub fn exp2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3267 const zcu = pt.zcu;3267 const zcu = pt.zcu;
3268 if (float_type.zigTypeTag(zcu) == .Vector) {3268 if (float_type.zigTypeTag(zcu) == .vector) {
3269 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3269 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3270 const scalar_ty = float_type.scalarType(zcu);3270 const scalar_ty = float_type.scalarType(zcu);
3271 for (result_data, 0..) |*scalar, i| {3271 for (result_data, 0..) |*scalar, i| {
...@@ -3299,7 +3299,7 @@ pub fn exp2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err...@@ -3299,7 +3299,7 @@ pub fn exp2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err
32993299
3300pub fn log(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3300pub fn log(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3301 const zcu = pt.zcu;3301 const zcu = pt.zcu;
3302 if (float_type.zigTypeTag(zcu) == .Vector) {3302 if (float_type.zigTypeTag(zcu) == .vector) {
3303 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3303 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3304 const scalar_ty = float_type.scalarType(zcu);3304 const scalar_ty = float_type.scalarType(zcu);
3305 for (result_data, 0..) |*scalar, i| {3305 for (result_data, 0..) |*scalar, i| {
...@@ -3333,7 +3333,7 @@ pub fn logScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro...@@ -3333,7 +3333,7 @@ pub fn logScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Erro
33333333
3334pub fn log2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3334pub fn log2(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3335 const zcu = pt.zcu;3335 const zcu = pt.zcu;
3336 if (float_type.zigTypeTag(zcu) == .Vector) {3336 if (float_type.zigTypeTag(zcu) == .vector) {
3337 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3337 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3338 const scalar_ty = float_type.scalarType(zcu);3338 const scalar_ty = float_type.scalarType(zcu);
3339 for (result_data, 0..) |*scalar, i| {3339 for (result_data, 0..) |*scalar, i| {
...@@ -3367,7 +3367,7 @@ pub fn log2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err...@@ -3367,7 +3367,7 @@ pub fn log2Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err
33673367
3368pub fn log10(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3368pub fn log10(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3369 const zcu = pt.zcu;3369 const zcu = pt.zcu;
3370 if (float_type.zigTypeTag(zcu) == .Vector) {3370 if (float_type.zigTypeTag(zcu) == .vector) {
3371 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3371 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3372 const scalar_ty = float_type.scalarType(zcu);3372 const scalar_ty = float_type.scalarType(zcu);
3373 for (result_data, 0..) |*scalar, i| {3373 for (result_data, 0..) |*scalar, i| {
...@@ -3401,7 +3401,7 @@ pub fn log10Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er...@@ -3401,7 +3401,7 @@ pub fn log10Scalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er
34013401
3402pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3402pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3403 const zcu = pt.zcu;3403 const zcu = pt.zcu;
3404 if (ty.zigTypeTag(zcu) == .Vector) {3404 if (ty.zigTypeTag(zcu) == .vector) {
3405 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));3405 const result_data = try arena.alloc(InternPool.Index, ty.vectorLen(zcu));
3406 const scalar_ty = ty.scalarType(zcu);3406 const scalar_ty = ty.scalarType(zcu);
3407 for (result_data, 0..) |*scalar, i| {3407 for (result_data, 0..) |*scalar, i| {
...@@ -3419,21 +3419,21 @@ pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {...@@ -3419,21 +3419,21 @@ pub fn abs(val: Value, ty: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3419pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allocator.Error!Value {3419pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allocator.Error!Value {
3420 const zcu = pt.zcu;3420 const zcu = pt.zcu;
3421 switch (ty.zigTypeTag(zcu)) {3421 switch (ty.zigTypeTag(zcu)) {
3422 .Int => {3422 .int => {
3423 var buffer: Value.BigIntSpace = undefined;3423 var buffer: Value.BigIntSpace = undefined;
3424 var operand_bigint = try val.toBigInt(&buffer, zcu).toManaged(arena);3424 var operand_bigint = try val.toBigInt(&buffer, zcu).toManaged(arena);
3425 operand_bigint.abs();3425 operand_bigint.abs();
34263426
3427 return pt.intValue_big(try ty.toUnsigned(pt), operand_bigint.toConst());3427 return pt.intValue_big(try ty.toUnsigned(pt), operand_bigint.toConst());
3428 },3428 },
3429 .ComptimeInt => {3429 .comptime_int => {
3430 var buffer: Value.BigIntSpace = undefined;3430 var buffer: Value.BigIntSpace = undefined;
3431 var operand_bigint = try val.toBigInt(&buffer, zcu).toManaged(arena);3431 var operand_bigint = try val.toBigInt(&buffer, zcu).toManaged(arena);
3432 operand_bigint.abs();3432 operand_bigint.abs();
34333433
3434 return pt.intValue_big(ty, operand_bigint.toConst());3434 return pt.intValue_big(ty, operand_bigint.toConst());
3435 },3435 },
3436 .ComptimeFloat, .Float => {3436 .comptime_float, .float => {
3437 const target = zcu.getTarget();3437 const target = zcu.getTarget();
3438 const storage: InternPool.Key.Float.Storage = switch (ty.floatBits(target)) {3438 const storage: InternPool.Key.Float.Storage = switch (ty.floatBits(target)) {
3439 16 => .{ .f16 = @abs(val.toFloat(f16, zcu)) },3439 16 => .{ .f16 = @abs(val.toFloat(f16, zcu)) },
...@@ -3454,7 +3454,7 @@ pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allo...@@ -3454,7 +3454,7 @@ pub fn absScalar(val: Value, ty: Type, pt: Zcu.PerThread, arena: Allocator) Allo
34543454
3455pub fn floor(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3455pub fn floor(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3456 const zcu = pt.zcu;3456 const zcu = pt.zcu;
3457 if (float_type.zigTypeTag(zcu) == .Vector) {3457 if (float_type.zigTypeTag(zcu) == .vector) {
3458 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3458 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3459 const scalar_ty = float_type.scalarType(zcu);3459 const scalar_ty = float_type.scalarType(zcu);
3460 for (result_data, 0..) |*scalar, i| {3460 for (result_data, 0..) |*scalar, i| {
...@@ -3488,7 +3488,7 @@ pub fn floorScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er...@@ -3488,7 +3488,7 @@ pub fn floorScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er
34883488
3489pub fn ceil(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3489pub fn ceil(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3490 const zcu = pt.zcu;3490 const zcu = pt.zcu;
3491 if (float_type.zigTypeTag(zcu) == .Vector) {3491 if (float_type.zigTypeTag(zcu) == .vector) {
3492 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3492 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3493 const scalar_ty = float_type.scalarType(zcu);3493 const scalar_ty = float_type.scalarType(zcu);
3494 for (result_data, 0..) |*scalar, i| {3494 for (result_data, 0..) |*scalar, i| {
...@@ -3522,7 +3522,7 @@ pub fn ceilScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err...@@ -3522,7 +3522,7 @@ pub fn ceilScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Err
35223522
3523pub fn round(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3523pub fn round(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3524 const zcu = pt.zcu;3524 const zcu = pt.zcu;
3525 if (float_type.zigTypeTag(zcu) == .Vector) {3525 if (float_type.zigTypeTag(zcu) == .vector) {
3526 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3526 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3527 const scalar_ty = float_type.scalarType(zcu);3527 const scalar_ty = float_type.scalarType(zcu);
3528 for (result_data, 0..) |*scalar, i| {3528 for (result_data, 0..) |*scalar, i| {
...@@ -3556,7 +3556,7 @@ pub fn roundScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er...@@ -3556,7 +3556,7 @@ pub fn roundScalar(val: Value, float_type: Type, pt: Zcu.PerThread) Allocator.Er
35563556
3557pub fn trunc(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {3557pub fn trunc(val: Value, float_type: Type, arena: Allocator, pt: Zcu.PerThread) !Value {
3558 const zcu = pt.zcu;3558 const zcu = pt.zcu;
3559 if (float_type.zigTypeTag(zcu) == .Vector) {3559 if (float_type.zigTypeTag(zcu) == .vector) {
3560 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3560 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3561 const scalar_ty = float_type.scalarType(zcu);3561 const scalar_ty = float_type.scalarType(zcu);
3562 for (result_data, 0..) |*scalar, i| {3562 for (result_data, 0..) |*scalar, i| {
...@@ -3597,7 +3597,7 @@ pub fn mulAdd(...@@ -3597,7 +3597,7 @@ pub fn mulAdd(
3597 pt: Zcu.PerThread,3597 pt: Zcu.PerThread,
3598) !Value {3598) !Value {
3599 const zcu = pt.zcu;3599 const zcu = pt.zcu;
3600 if (float_type.zigTypeTag(zcu) == .Vector) {3600 if (float_type.zigTypeTag(zcu) == .vector) {
3601 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));3601 const result_data = try arena.alloc(InternPool.Index, float_type.vectorLen(zcu));
3602 const scalar_ty = float_type.scalarType(zcu);3602 const scalar_ty = float_type.scalarType(zcu);
3603 for (result_data, 0..) |*scalar, i| {3603 for (result_data, 0..) |*scalar, i| {
...@@ -3720,7 +3720,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {...@@ -3720,7 +3720,7 @@ pub fn ptrOptPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
3720 const opt_ty = parent_ptr_ty.childType(zcu);3720 const opt_ty = parent_ptr_ty.childType(zcu);
37213721
3722 assert(parent_ptr_ty.ptrSize(zcu) == .One);3722 assert(parent_ptr_ty.ptrSize(zcu) == .One);
3723 assert(opt_ty.zigTypeTag(zcu) == .Optional);3723 assert(opt_ty.zigTypeTag(zcu) == .optional);
37243724
3725 const result_ty = try pt.ptrTypeSema(info: {3725 const result_ty = try pt.ptrTypeSema(info: {
3726 var new = parent_ptr_ty.ptrInfo(zcu);3726 var new = parent_ptr_ty.ptrInfo(zcu);
...@@ -3754,7 +3754,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {...@@ -3754,7 +3754,7 @@ pub fn ptrEuPayload(parent_ptr: Value, pt: Zcu.PerThread) !Value {
3754 const eu_ty = parent_ptr_ty.childType(zcu);3754 const eu_ty = parent_ptr_ty.childType(zcu);
37553755
3756 assert(parent_ptr_ty.ptrSize(zcu) == .One);3756 assert(parent_ptr_ty.ptrSize(zcu) == .One);
3757 assert(eu_ty.zigTypeTag(zcu) == .ErrorUnion);3757 assert(eu_ty.zigTypeTag(zcu) == .error_union);
37583758
3759 const result_ty = try pt.ptrTypeSema(info: {3759 const result_ty = try pt.ptrTypeSema(info: {
3760 var new = parent_ptr_ty.ptrInfo(zcu);3760 var new = parent_ptr_ty.ptrInfo(zcu);
...@@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {...@@ -3789,7 +3789,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
3789 // Exiting this `switch` indicates that the `field` pointer representation should be used.3789 // Exiting this `switch` indicates that the `field` pointer representation should be used.
3790 // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.3790 // `field_align` may be `.none` to represent the natural alignment of `field_ty`, but is not necessarily.
3791 const field_ty: Type, const field_align: InternPool.Alignment = switch (aggregate_ty.zigTypeTag(zcu)) {3791 const field_ty: Type, const field_align: InternPool.Alignment = switch (aggregate_ty.zigTypeTag(zcu)) {
3792 .Struct => field: {3792 .@"struct" => field: {
3793 const field_ty = aggregate_ty.fieldType(field_idx, zcu);3793 const field_ty = aggregate_ty.fieldType(field_idx, zcu);
3794 switch (aggregate_ty.containerLayout(zcu)) {3794 switch (aggregate_ty.containerLayout(zcu)) {
3795 .auto => break :field .{ field_ty, try aggregate_ty.fieldAlignmentSema(field_idx, pt) },3795 .auto => break :field .{ field_ty, try aggregate_ty.fieldAlignmentSema(field_idx, pt) },
...@@ -3839,7 +3839,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {...@@ -3839,7 +3839,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
3839 },3839 },
3840 }3840 }
3841 },3841 },
3842 .Union => field: {3842 .@"union" => field: {
3843 const union_obj = zcu.typeToUnion(aggregate_ty).?;3843 const union_obj = zcu.typeToUnion(aggregate_ty).?;
3844 const field_ty = Type.fromInterned(union_obj.field_types.get(&zcu.intern_pool)[field_idx]);3844 const field_ty = Type.fromInterned(union_obj.field_types.get(&zcu.intern_pool)[field_idx]);
3845 switch (aggregate_ty.containerLayout(zcu)) {3845 switch (aggregate_ty.containerLayout(zcu)) {
...@@ -3887,7 +3887,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {...@@ -3887,7 +3887,7 @@ pub fn ptrField(parent_ptr: Value, field_idx: u32, pt: Zcu.PerThread) !Value {
3887 },3887 },
3888 }3888 }
3889 },3889 },
3890 .Pointer => field_ty: {3890 .pointer => field_ty: {
3891 assert(aggregate_ty.isSlice(zcu));3891 assert(aggregate_ty.isSlice(zcu));
3892 break :field_ty switch (field_idx) {3892 break :field_ty switch (field_idx) {
3893 Value.slice_ptr_index => .{ aggregate_ty.slicePtrFieldType(zcu), Type.usize.abiAlignment(zcu) },3893 Value.slice_ptr_index => .{ aggregate_ty.slicePtrFieldType(zcu), Type.usize.abiAlignment(zcu) },
...@@ -3944,7 +3944,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value...@@ -3944,7 +3944,7 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
39443944
3945 if (result_ty.ptrInfo(zcu).packed_offset.host_size != 0) {3945 if (result_ty.ptrInfo(zcu).packed_offset.host_size != 0) {
3946 // Since we have a bit-pointer, the pointer address should be unchanged.3946 // Since we have a bit-pointer, the pointer address should be unchanged.
3947 assert(elem_ty.zigTypeTag(zcu) == .Vector);3947 assert(elem_ty.zigTypeTag(zcu) == .vector);
3948 return pt.getCoerced(parent_ptr, result_ty);3948 return pt.getCoerced(parent_ptr, result_ty);
3949 }3949 }
39503950
...@@ -3955,8 +3955,8 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value...@@ -3955,8 +3955,8 @@ pub fn ptrElem(orig_parent_ptr: Value, field_idx: u64, pt: Zcu.PerThread) !Value
39553955
3956 const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {3956 const strat: PtrStrat = switch (parent_ptr_ty.ptrSize(zcu)) {
3957 .One => switch (elem_ty.zigTypeTag(zcu)) {3957 .One => switch (elem_ty.zigTypeTag(zcu)) {
3958 .Vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },3958 .vector => .{ .offset = field_idx * @divExact(try elem_ty.childType(zcu).bitSizeSema(pt), 8) },
3959 .Array => strat: {3959 .array => strat: {
3960 const arr_elem_ty = elem_ty.childType(zcu);3960 const arr_elem_ty = elem_ty.childType(zcu);
3961 if (try arr_elem_ty.comptimeOnlySema(pt)) {3961 if (try arr_elem_ty.comptimeOnlySema(pt)) {
3962 break :strat .{ .elem_ptr = arr_elem_ty };3962 break :strat .{ .elem_ptr = arr_elem_ty };
...@@ -4178,19 +4178,19 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh...@@ -4178,19 +4178,19 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4178 const base_ptr_ty = base_ptr.typeOf(zcu);4178 const base_ptr_ty = base_ptr.typeOf(zcu);
4179 const agg_ty = base_ptr_ty.childType(zcu);4179 const agg_ty = base_ptr_ty.childType(zcu);
4180 const field_ty, const field_align = switch (agg_ty.zigTypeTag(zcu)) {4180 const field_ty, const field_align = switch (agg_ty.zigTypeTag(zcu)) {
4181 .Struct => .{ agg_ty.fieldType(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(4181 .@"struct" => .{ agg_ty.fieldType(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(
4182 @intCast(field.index),4182 @intCast(field.index),
4183 if (have_sema) .sema else .normal,4183 if (have_sema) .sema else .normal,
4184 pt.zcu,4184 pt.zcu,
4185 if (have_sema) pt.tid else {},4185 if (have_sema) pt.tid else {},
4186 ) },4186 ) },
4187 .Union => .{ agg_ty.unionFieldTypeByIndex(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(4187 .@"union" => .{ agg_ty.unionFieldTypeByIndex(@intCast(field.index), zcu), try agg_ty.fieldAlignmentInner(
4188 @intCast(field.index),4188 @intCast(field.index),
4189 if (have_sema) .sema else .normal,4189 if (have_sema) .sema else .normal,
4190 pt.zcu,4190 pt.zcu,
4191 if (have_sema) pt.tid else {},4191 if (have_sema) pt.tid else {},
4192 ) },4192 ) },
4193 .Pointer => .{ switch (field.index) {4193 .pointer => .{ switch (field.index) {
4194 Value.slice_ptr_index => agg_ty.slicePtrFieldType(zcu),4194 Value.slice_ptr_index => agg_ty.slicePtrFieldType(zcu),
4195 Value.slice_len_index => Type.usize,4195 Value.slice_len_index => Type.usize,
4196 else => unreachable,4196 else => unreachable,
...@@ -4268,31 +4268,31 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh...@@ -4268,31 +4268,31 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4268 break;4268 break;
4269 }4269 }
4270 switch (cur_ty.zigTypeTag(zcu)) {4270 switch (cur_ty.zigTypeTag(zcu)) {
4271 .NoReturn,4271 .noreturn,
4272 .Type,4272 .type,
4273 .ComptimeInt,4273 .comptime_int,
4274 .ComptimeFloat,4274 .comptime_float,
4275 .Null,4275 .null,
4276 .Undefined,4276 .undefined,
4277 .EnumLiteral,4277 .enum_literal,
4278 .Opaque,4278 .@"opaque",
4279 .Fn,4279 .@"fn",
4280 .ErrorUnion,4280 .error_union,
4281 .Int,4281 .int,
4282 .Float,4282 .float,
4283 .Bool,4283 .bool,
4284 .Void,4284 .void,
4285 .Pointer,4285 .pointer,
4286 .ErrorSet,4286 .error_set,
4287 .AnyFrame,4287 .@"anyframe",
4288 .Frame,4288 .frame,
4289 .Enum,4289 .@"enum",
4290 .Vector,4290 .vector,
4291 .Optional,4291 .optional,
4292 .Union,4292 .@"union",
4293 => break,4293 => break,
42944294
4295 .Array => {4295 .array => {
4296 const elem_ty = cur_ty.childType(zcu);4296 const elem_ty = cur_ty.childType(zcu);
4297 const elem_size = elem_ty.abiSize(zcu);4297 const elem_size = elem_ty.abiSize(zcu);
4298 const start_idx = cur_offset / elem_size;4298 const start_idx = cur_offset / elem_size;
...@@ -4321,7 +4321,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh...@@ -4321,7 +4321,7 @@ pub fn pointerDerivationAdvanced(ptr_val: Value, arena: Allocator, pt: Zcu.PerTh
4321 break;4321 break;
4322 }4322 }
4323 },4323 },
4324 .Struct => switch (cur_ty.containerLayout(zcu)) {4324 .@"struct" => switch (cur_ty.containerLayout(zcu)) {
4325 .auto, .@"packed" => break,4325 .auto, .@"packed" => break,
4326 .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {4326 .@"extern" => for (0..cur_ty.structFieldCount(zcu)) |field_idx| {
4327 const field_ty = cur_ty.fieldType(field_idx, zcu);4327 const field_ty = cur_ty.fieldType(field_idx, zcu);
src/Zcu.zig+4-4
...@@ -43,9 +43,9 @@ const dev = @import("dev.zig");...@@ -43,9 +43,9 @@ const dev = @import("dev.zig");
43comptime {43comptime {
44 @setEvalBranchQuota(4000);44 @setEvalBranchQuota(4000);
45 for (45 for (
46 @typeInfo(Zir.Inst.Ref).Enum.fields,46 @typeInfo(Zir.Inst.Ref).@"enum".fields,
47 @typeInfo(Air.Inst.Ref).Enum.fields,47 @typeInfo(Air.Inst.Ref).@"enum".fields,
48 @typeInfo(InternPool.Index).Enum.fields,48 @typeInfo(InternPool.Index).@"enum".fields,
49 ) |zir_field, air_field, ip_field| {49 ) |zir_field, air_field, ip_field| {
50 assert(mem.eql(u8, zir_field.name, ip_field.name));50 assert(mem.eql(u8, zir_field.name, ip_field.name));
51 assert(mem.eql(u8, air_field.name, ip_field.name));51 assert(mem.eql(u8, air_field.name, ip_field.name));
...@@ -246,7 +246,7 @@ pub const PanicId = enum {...@@ -246,7 +246,7 @@ pub const PanicId = enum {
246 memcpy_alias,246 memcpy_alias,
247 noreturn_returned,247 noreturn_returned,
248248
249 pub const len = @typeInfo(PanicId).Enum.fields.len;249 pub const len = @typeInfo(PanicId).@"enum".fields.len;
250};250};
251251
252pub const GlobalErrorSet = std.AutoArrayHashMapUnmanaged(InternPool.NullTerminatedString, void);252pub const GlobalErrorSet = std.AutoArrayHashMapUnmanaged(InternPool.NullTerminatedString, void);
src/Zcu/PerThread.zig+7-7
...@@ -921,7 +921,7 @@ fn createFileRootStruct(...@@ -921,7 +921,7 @@ fn createFileRootStruct(
921 assert(!small.has_captures_len);921 assert(!small.has_captures_len);
922 assert(!small.has_backing_int);922 assert(!small.has_backing_int);
923 assert(small.layout == .auto);923 assert(small.layout == .auto);
924 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;924 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len;
925 const fields_len = if (small.has_fields_len) blk: {925 const fields_len = if (small.has_fields_len) blk: {
926 const fields_len = file.zir.extra[extra_index];926 const fields_len = file.zir.extra[extra_index];
927 extra_index += 1;927 extra_index += 1;
...@@ -1005,7 +1005,7 @@ fn updateFileNamespace(pt: Zcu.PerThread, file_index: Zcu.File.Index) Allocator....@@ -1005,7 +1005,7 @@ fn updateFileNamespace(pt: Zcu.PerThread, file_index: Zcu.File.Index) Allocator.
1005 const extended = file.zir.instructions.items(.data)[@intFromEnum(Zir.Inst.Index.main_struct_inst)].extended;1005 const extended = file.zir.instructions.items(.data)[@intFromEnum(Zir.Inst.Index.main_struct_inst)].extended;
1006 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);1006 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
10071007
1008 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;1008 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).@"struct".fields.len;
1009 extra_index += @intFromBool(small.has_fields_len);1009 extra_index += @intFromBool(small.has_fields_len);
1010 const decls_len = if (small.has_decls_len) blk: {1010 const decls_len = if (small.has_decls_len) blk: {
1011 const decls_len = file.zir.extra[extra_index];1011 const decls_len = file.zir.extra[extra_index];
...@@ -2080,7 +2080,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!...@@ -2080,7 +2080,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!
2080 func.setCallsOrAwaitsErrorableFn(ip, false);2080 func.setCallsOrAwaitsErrorableFn(ip, false);
20812081
2082 // First few indexes of extra are reserved and set at the end.2082 // First few indexes of extra are reserved and set at the end.
2083 const reserved_count = @typeInfo(Air.ExtraIndex).Enum.fields.len;2083 const reserved_count = @typeInfo(Air.ExtraIndex).@"enum".fields.len;
2084 try sema.air_extra.ensureTotalCapacity(gpa, reserved_count);2084 try sema.air_extra.ensureTotalCapacity(gpa, reserved_count);
2085 sema.air_extra.items.len += reserved_count;2085 sema.air_extra.items.len += reserved_count;
20862086
...@@ -2204,7 +2204,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!...@@ -2204,7 +2204,7 @@ fn analyzeFnBody(pt: Zcu.PerThread, func_index: InternPool.Index) Zcu.SemaError!
2204 }2204 }
22052205
2206 // Copy the block into place and mark that as the main block.2206 // Copy the block into place and mark that as the main block.
2207 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).Struct.fields.len +2207 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.Block).@"struct".fields.len +
2208 inner_block.instructions.items.len);2208 inner_block.instructions.items.len);
2209 const main_block_index = sema.addExtraAssumeCapacity(Air.Block{2209 const main_block_index = sema.addExtraAssumeCapacity(Air.Block{
2210 .body_len = @intCast(inner_block.instructions.items.len),2210 .body_len = @intCast(inner_block.instructions.items.len),
...@@ -2405,7 +2405,7 @@ fn processExportsInner(...@@ -2405,7 +2405,7 @@ fn processExportsInner(
2405 .resolved => |r| Value.fromInterned(r.val),2405 .resolved => |r| Value.fromInterned(r.val),
2406 };2406 };
2407 // If the value is a function, we also need to check if that function succeeded analysis.2407 // If the value is a function, we also need to check if that function succeeded analysis.
2408 if (val.typeOf(zcu).zigTypeTag(zcu) == .Fn) {2408 if (val.typeOf(zcu).zigTypeTag(zcu) == .@"fn") {
2409 const func_unit = AnalUnit.wrap(.{ .func = val.toIntern() });2409 const func_unit = AnalUnit.wrap(.{ .func = val.toIntern() });
2410 if (zcu.failed_analysis.contains(func_unit)) break :failed true;2410 if (zcu.failed_analysis.contains(func_unit)) break :failed true;
2411 if (zcu.transitive_failed_analysis.contains(func_unit)) break :failed true;2411 if (zcu.transitive_failed_analysis.contains(func_unit)) break :failed true;
...@@ -2869,7 +2869,7 @@ pub fn errorSetFromUnsortedNames(...@@ -2869,7 +2869,7 @@ pub fn errorSetFromUnsortedNames(
2869/// Supports only pointers, not pointer-like optionals.2869/// Supports only pointers, not pointer-like optionals.
2870pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value {2870pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value {
2871 const zcu = pt.zcu;2871 const zcu = pt.zcu;
2872 assert(ty.zigTypeTag(zcu) == .Pointer and !ty.isSlice(zcu));2872 assert(ty.zigTypeTag(zcu) == .pointer and !ty.isSlice(zcu));
2873 assert(x != 0 or ty.isAllowzeroPtr(zcu));2873 assert(x != 0 or ty.isAllowzeroPtr(zcu));
2874 return Value.fromInterned(try pt.intern(.{ .ptr = .{2874 return Value.fromInterned(try pt.intern(.{ .ptr = .{
2875 .ty = ty.toIntern(),2875 .ty = ty.toIntern(),
...@@ -2882,7 +2882,7 @@ pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value {...@@ -2882,7 +2882,7 @@ pub fn ptrIntValue(pt: Zcu.PerThread, ty: Type, x: u64) Allocator.Error!Value {
2882pub fn enumValue(pt: Zcu.PerThread, ty: Type, tag_int: InternPool.Index) Allocator.Error!Value {2882pub fn enumValue(pt: Zcu.PerThread, ty: Type, tag_int: InternPool.Index) Allocator.Error!Value {
2883 if (std.debug.runtime_safety) {2883 if (std.debug.runtime_safety) {
2884 const tag = ty.zigTypeTag(pt.zcu);2884 const tag = ty.zigTypeTag(pt.zcu);
2885 assert(tag == .Enum);2885 assert(tag == .@"enum");
2886 }2886 }
2887 return Value.fromInterned(try pt.intern(.{ .enum_tag = .{2887 return Value.fromInterned(try pt.intern(.{ .enum_tag = .{
2888 .ty = ty.toIntern(),2888 .ty = ty.toIntern(),
src/arch/aarch64/CodeGen.zig+56-56
...@@ -1324,7 +1324,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {...@@ -1324,7 +1324,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
1324 .compare_flags => |cond| break :result MCValue{ .compare_flags = cond.negate() },1324 .compare_flags => |cond| break :result MCValue{ .compare_flags = cond.negate() },
1325 else => {1325 else => {
1326 switch (operand_ty.zigTypeTag(zcu)) {1326 switch (operand_ty.zigTypeTag(zcu)) {
1327 .Bool => {1327 .bool => {
1328 // TODO convert this to mvn + and1328 // TODO convert this to mvn + and
1329 const op_reg = switch (operand) {1329 const op_reg = switch (operand) {
1330 .register => |r| r,1330 .register => |r| r,
...@@ -1355,8 +1355,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {...@@ -1355,8 +1355,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
13551355
1356 break :result MCValue{ .register = dest_reg };1356 break :result MCValue{ .register = dest_reg };
1357 },1357 },
1358 .Vector => return self.fail("TODO bitwise not for vectors", .{}),1358 .vector => return self.fail("TODO bitwise not for vectors", .{}),
1359 .Int => {1359 .int => {
1360 const int_info = operand_ty.intInfo(zcu);1360 const int_info = operand_ty.intInfo(zcu);
1361 if (int_info.bits <= 64) {1361 if (int_info.bits <= 64) {
1362 const op_reg = switch (operand) {1362 const op_reg = switch (operand) {
...@@ -1412,9 +1412,9 @@ fn minMax(...@@ -1412,9 +1412,9 @@ fn minMax(
1412 const pt = self.pt;1412 const pt = self.pt;
1413 const zcu = pt.zcu;1413 const zcu = pt.zcu;
1414 switch (lhs_ty.zigTypeTag(zcu)) {1414 switch (lhs_ty.zigTypeTag(zcu)) {
1415 .Float => return self.fail("TODO ARM min/max on floats", .{}),1415 .float => return self.fail("TODO ARM min/max on floats", .{}),
1416 .Vector => return self.fail("TODO ARM min/max on vectors", .{}),1416 .vector => return self.fail("TODO ARM min/max on vectors", .{}),
1417 .Int => {1417 .int => {
1418 assert(lhs_ty.eql(rhs_ty, zcu));1418 assert(lhs_ty.eql(rhs_ty, zcu));
1419 const int_info = lhs_ty.intInfo(zcu);1419 const int_info = lhs_ty.intInfo(zcu);
1420 if (int_info.bits <= 64) {1420 if (int_info.bits <= 64) {
...@@ -1903,9 +1903,9 @@ fn addSub(...@@ -1903,9 +1903,9 @@ fn addSub(
1903 const pt = self.pt;1903 const pt = self.pt;
1904 const zcu = pt.zcu;1904 const zcu = pt.zcu;
1905 switch (lhs_ty.zigTypeTag(zcu)) {1905 switch (lhs_ty.zigTypeTag(zcu)) {
1906 .Float => return self.fail("TODO binary operations on floats", .{}),1906 .float => return self.fail("TODO binary operations on floats", .{}),
1907 .Vector => return self.fail("TODO binary operations on vectors", .{}),1907 .vector => return self.fail("TODO binary operations on vectors", .{}),
1908 .Int => {1908 .int => {
1909 assert(lhs_ty.eql(rhs_ty, zcu));1909 assert(lhs_ty.eql(rhs_ty, zcu));
1910 const int_info = lhs_ty.intInfo(zcu);1910 const int_info = lhs_ty.intInfo(zcu);
1911 if (int_info.bits <= 64) {1911 if (int_info.bits <= 64) {
...@@ -1965,8 +1965,8 @@ fn mul(...@@ -1965,8 +1965,8 @@ fn mul(
1965 const pt = self.pt;1965 const pt = self.pt;
1966 const zcu = pt.zcu;1966 const zcu = pt.zcu;
1967 switch (lhs_ty.zigTypeTag(zcu)) {1967 switch (lhs_ty.zigTypeTag(zcu)) {
1968 .Vector => return self.fail("TODO binary operations on vectors", .{}),1968 .vector => return self.fail("TODO binary operations on vectors", .{}),
1969 .Int => {1969 .int => {
1970 assert(lhs_ty.eql(rhs_ty, zcu));1970 assert(lhs_ty.eql(rhs_ty, zcu));
1971 const int_info = lhs_ty.intInfo(zcu);1971 const int_info = lhs_ty.intInfo(zcu);
1972 if (int_info.bits <= 64) {1972 if (int_info.bits <= 64) {
...@@ -1998,8 +1998,8 @@ fn divFloat(...@@ -1998,8 +1998,8 @@ fn divFloat(
1998 const pt = self.pt;1998 const pt = self.pt;
1999 const zcu = pt.zcu;1999 const zcu = pt.zcu;
2000 switch (lhs_ty.zigTypeTag(zcu)) {2000 switch (lhs_ty.zigTypeTag(zcu)) {
2001 .Float => return self.fail("TODO div_float", .{}),2001 .float => return self.fail("TODO div_float", .{}),
2002 .Vector => return self.fail("TODO div_float on vectors", .{}),2002 .vector => return self.fail("TODO div_float on vectors", .{}),
2003 else => unreachable,2003 else => unreachable,
2004 }2004 }
2005}2005}
...@@ -2015,9 +2015,9 @@ fn divTrunc(...@@ -2015,9 +2015,9 @@ fn divTrunc(
2015 const pt = self.pt;2015 const pt = self.pt;
2016 const zcu = pt.zcu;2016 const zcu = pt.zcu;
2017 switch (lhs_ty.zigTypeTag(zcu)) {2017 switch (lhs_ty.zigTypeTag(zcu)) {
2018 .Float => return self.fail("TODO div on floats", .{}),2018 .float => return self.fail("TODO div on floats", .{}),
2019 .Vector => return self.fail("TODO div on vectors", .{}),2019 .vector => return self.fail("TODO div on vectors", .{}),
2020 .Int => {2020 .int => {
2021 assert(lhs_ty.eql(rhs_ty, zcu));2021 assert(lhs_ty.eql(rhs_ty, zcu));
2022 const int_info = lhs_ty.intInfo(zcu);2022 const int_info = lhs_ty.intInfo(zcu);
2023 if (int_info.bits <= 64) {2023 if (int_info.bits <= 64) {
...@@ -2050,9 +2050,9 @@ fn divFloor(...@@ -2050,9 +2050,9 @@ fn divFloor(
2050 const pt = self.pt;2050 const pt = self.pt;
2051 const zcu = pt.zcu;2051 const zcu = pt.zcu;
2052 switch (lhs_ty.zigTypeTag(zcu)) {2052 switch (lhs_ty.zigTypeTag(zcu)) {
2053 .Float => return self.fail("TODO div on floats", .{}),2053 .float => return self.fail("TODO div on floats", .{}),
2054 .Vector => return self.fail("TODO div on vectors", .{}),2054 .vector => return self.fail("TODO div on vectors", .{}),
2055 .Int => {2055 .int => {
2056 assert(lhs_ty.eql(rhs_ty, zcu));2056 assert(lhs_ty.eql(rhs_ty, zcu));
2057 const int_info = lhs_ty.intInfo(zcu);2057 const int_info = lhs_ty.intInfo(zcu);
2058 if (int_info.bits <= 64) {2058 if (int_info.bits <= 64) {
...@@ -2084,9 +2084,9 @@ fn divExact(...@@ -2084,9 +2084,9 @@ fn divExact(
2084 const pt = self.pt;2084 const pt = self.pt;
2085 const zcu = pt.zcu;2085 const zcu = pt.zcu;
2086 switch (lhs_ty.zigTypeTag(zcu)) {2086 switch (lhs_ty.zigTypeTag(zcu)) {
2087 .Float => return self.fail("TODO div on floats", .{}),2087 .float => return self.fail("TODO div on floats", .{}),
2088 .Vector => return self.fail("TODO div on vectors", .{}),2088 .vector => return self.fail("TODO div on vectors", .{}),
2089 .Int => {2089 .int => {
2090 assert(lhs_ty.eql(rhs_ty, zcu));2090 assert(lhs_ty.eql(rhs_ty, zcu));
2091 const int_info = lhs_ty.intInfo(zcu);2091 const int_info = lhs_ty.intInfo(zcu);
2092 if (int_info.bits <= 64) {2092 if (int_info.bits <= 64) {
...@@ -2121,9 +2121,9 @@ fn rem(...@@ -2121,9 +2121,9 @@ fn rem(
2121 const pt = self.pt;2121 const pt = self.pt;
2122 const zcu = pt.zcu;2122 const zcu = pt.zcu;
2123 switch (lhs_ty.zigTypeTag(zcu)) {2123 switch (lhs_ty.zigTypeTag(zcu)) {
2124 .Float => return self.fail("TODO rem/zcu on floats", .{}),2124 .float => return self.fail("TODO rem/zcu on floats", .{}),
2125 .Vector => return self.fail("TODO rem/zcu on vectors", .{}),2125 .vector => return self.fail("TODO rem/zcu on vectors", .{}),
2126 .Int => {2126 .int => {
2127 assert(lhs_ty.eql(rhs_ty, zcu));2127 assert(lhs_ty.eql(rhs_ty, zcu));
2128 const int_info = lhs_ty.intInfo(zcu);2128 const int_info = lhs_ty.intInfo(zcu);
2129 if (int_info.bits <= 64) {2129 if (int_info.bits <= 64) {
...@@ -2193,9 +2193,9 @@ fn modulo(...@@ -2193,9 +2193,9 @@ fn modulo(
2193 const pt = self.pt;2193 const pt = self.pt;
2194 const zcu = pt.zcu;2194 const zcu = pt.zcu;
2195 switch (lhs_ty.zigTypeTag(zcu)) {2195 switch (lhs_ty.zigTypeTag(zcu)) {
2196 .Float => return self.fail("TODO zcu on floats", .{}),2196 .float => return self.fail("TODO zcu on floats", .{}),
2197 .Vector => return self.fail("TODO zcu on vectors", .{}),2197 .vector => return self.fail("TODO zcu on vectors", .{}),
2198 .Int => return self.fail("TODO zcu on ints", .{}),2198 .int => return self.fail("TODO zcu on ints", .{}),
2199 else => unreachable,2199 else => unreachable,
2200 }2200 }
2201}2201}
...@@ -2212,8 +2212,8 @@ fn wrappingArithmetic(...@@ -2212,8 +2212,8 @@ fn wrappingArithmetic(
2212 const pt = self.pt;2212 const pt = self.pt;
2213 const zcu = pt.zcu;2213 const zcu = pt.zcu;
2214 switch (lhs_ty.zigTypeTag(zcu)) {2214 switch (lhs_ty.zigTypeTag(zcu)) {
2215 .Vector => return self.fail("TODO binary operations on vectors", .{}),2215 .vector => return self.fail("TODO binary operations on vectors", .{}),
2216 .Int => {2216 .int => {
2217 const int_info = lhs_ty.intInfo(zcu);2217 const int_info = lhs_ty.intInfo(zcu);
2218 if (int_info.bits <= 64) {2218 if (int_info.bits <= 64) {
2219 // Generate an add/sub/mul2219 // Generate an add/sub/mul
...@@ -2248,8 +2248,8 @@ fn bitwise(...@@ -2248,8 +2248,8 @@ fn bitwise(
2248 const pt = self.pt;2248 const pt = self.pt;
2249 const zcu = pt.zcu;2249 const zcu = pt.zcu;
2250 switch (lhs_ty.zigTypeTag(zcu)) {2250 switch (lhs_ty.zigTypeTag(zcu)) {
2251 .Vector => return self.fail("TODO binary operations on vectors", .{}),2251 .vector => return self.fail("TODO binary operations on vectors", .{}),
2252 .Int => {2252 .int => {
2253 assert(lhs_ty.eql(rhs_ty, zcu));2253 assert(lhs_ty.eql(rhs_ty, zcu));
2254 const int_info = lhs_ty.intInfo(zcu);2254 const int_info = lhs_ty.intInfo(zcu);
2255 if (int_info.bits <= 64) {2255 if (int_info.bits <= 64) {
...@@ -2284,8 +2284,8 @@ fn shiftExact(...@@ -2284,8 +2284,8 @@ fn shiftExact(
2284 const pt = self.pt;2284 const pt = self.pt;
2285 const zcu = pt.zcu;2285 const zcu = pt.zcu;
2286 switch (lhs_ty.zigTypeTag(zcu)) {2286 switch (lhs_ty.zigTypeTag(zcu)) {
2287 .Vector => return self.fail("TODO binary operations on vectors", .{}),2287 .vector => return self.fail("TODO binary operations on vectors", .{}),
2288 .Int => {2288 .int => {
2289 const int_info = lhs_ty.intInfo(zcu);2289 const int_info = lhs_ty.intInfo(zcu);
2290 if (int_info.bits <= 64) {2290 if (int_info.bits <= 64) {
2291 const rhs_immediate = try rhs_bind.resolveToImmediate(self);2291 const rhs_immediate = try rhs_bind.resolveToImmediate(self);
...@@ -2335,8 +2335,8 @@ fn shiftNormal(...@@ -2335,8 +2335,8 @@ fn shiftNormal(
2335 const pt = self.pt;2335 const pt = self.pt;
2336 const zcu = pt.zcu;2336 const zcu = pt.zcu;
2337 switch (lhs_ty.zigTypeTag(zcu)) {2337 switch (lhs_ty.zigTypeTag(zcu)) {
2338 .Vector => return self.fail("TODO binary operations on vectors", .{}),2338 .vector => return self.fail("TODO binary operations on vectors", .{}),
2339 .Int => {2339 .int => {
2340 const int_info = lhs_ty.intInfo(zcu);2340 const int_info = lhs_ty.intInfo(zcu);
2341 if (int_info.bits <= 64) {2341 if (int_info.bits <= 64) {
2342 // Generate a shl_exact/shr_exact2342 // Generate a shl_exact/shr_exact
...@@ -2376,7 +2376,7 @@ fn booleanOp(...@@ -2376,7 +2376,7 @@ fn booleanOp(
2376 const pt = self.pt;2376 const pt = self.pt;
2377 const zcu = pt.zcu;2377 const zcu = pt.zcu;
2378 switch (lhs_ty.zigTypeTag(zcu)) {2378 switch (lhs_ty.zigTypeTag(zcu)) {
2379 .Bool => {2379 .bool => {
2380 assert((try lhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema2380 assert((try lhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema
2381 assert((try rhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema2381 assert((try rhs_bind.resolveToImmediate(self)) == null); // should have been handled by Sema
23822382
...@@ -2404,7 +2404,7 @@ fn ptrArithmetic(...@@ -2404,7 +2404,7 @@ fn ptrArithmetic(
2404 const pt = self.pt;2404 const pt = self.pt;
2405 const zcu = pt.zcu;2405 const zcu = pt.zcu;
2406 switch (lhs_ty.zigTypeTag(zcu)) {2406 switch (lhs_ty.zigTypeTag(zcu)) {
2407 .Pointer => {2407 .pointer => {
2408 assert(rhs_ty.eql(Type.usize, zcu));2408 assert(rhs_ty.eql(Type.usize, zcu));
24092409
2410 const ptr_ty = lhs_ty;2410 const ptr_ty = lhs_ty;
...@@ -2539,8 +2539,8 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2539,8 +2539,8 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {
2539 const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu)));2539 const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu)));
25402540
2541 switch (lhs_ty.zigTypeTag(zcu)) {2541 switch (lhs_ty.zigTypeTag(zcu)) {
2542 .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}),2542 .vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}),
2543 .Int => {2543 .int => {
2544 assert(lhs_ty.eql(rhs_ty, zcu));2544 assert(lhs_ty.eql(rhs_ty, zcu));
2545 const int_info = lhs_ty.intInfo(zcu);2545 const int_info = lhs_ty.intInfo(zcu);
2546 switch (int_info.bits) {2546 switch (int_info.bits) {
...@@ -2667,8 +2667,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2667,8 +2667,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2667 const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu)));2667 const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu)));
26682668
2669 switch (lhs_ty.zigTypeTag(zcu)) {2669 switch (lhs_ty.zigTypeTag(zcu)) {
2670 .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),2670 .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),
2671 .Int => {2671 .int => {
2672 assert(lhs_ty.eql(rhs_ty, zcu));2672 assert(lhs_ty.eql(rhs_ty, zcu));
2673 const int_info = lhs_ty.intInfo(zcu);2673 const int_info = lhs_ty.intInfo(zcu);
2674 if (int_info.bits <= 32) {2674 if (int_info.bits <= 32) {
...@@ -2892,8 +2892,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2892,8 +2892,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2892 const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu)));2892 const overflow_bit_offset = @as(u32, @intCast(tuple_ty.structFieldOffset(1, zcu)));
28932893
2894 switch (lhs_ty.zigTypeTag(zcu)) {2894 switch (lhs_ty.zigTypeTag(zcu)) {
2895 .Vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}),2895 .vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}),
2896 .Int => {2896 .int => {
2897 const int_info = lhs_ty.intInfo(zcu);2897 const int_info = lhs_ty.intInfo(zcu);
2898 if (int_info.bits <= 64) {2898 if (int_info.bits <= 64) {
2899 const stack_offset = try self.allocMem(tuple_size, tuple_align, inst);2899 const stack_offset = try self.allocMem(tuple_size, tuple_align, inst);
...@@ -4279,8 +4279,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4279,8 +4279,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4279 const ip = &zcu.intern_pool;4279 const ip = &zcu.intern_pool;
42804280
4281 const fn_ty = switch (ty.zigTypeTag(zcu)) {4281 const fn_ty = switch (ty.zigTypeTag(zcu)) {
4282 .Fn => ty,4282 .@"fn" => ty,
4283 .Pointer => ty.childType(zcu),4283 .pointer => ty.childType(zcu),
4284 else => unreachable,4284 else => unreachable,
4285 };4285 };
42864286
...@@ -4388,7 +4388,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4388,7 +4388,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4388 },4388 },
4389 else => return self.fail("TODO implement calling bitcasted functions", .{}),4389 else => return self.fail("TODO implement calling bitcasted functions", .{}),
4390 } else {4390 } else {
4391 assert(ty.zigTypeTag(zcu) == .Pointer);4391 assert(ty.zigTypeTag(zcu) == .pointer);
4392 const mcv = try self.resolveInst(callee);4392 const mcv = try self.resolveInst(callee);
4393 try self.genSetReg(ty, .x30, mcv);4393 try self.genSetReg(ty, .x30, mcv);
43944394
...@@ -4523,7 +4523,7 @@ fn cmp(...@@ -4523,7 +4523,7 @@ fn cmp(
4523 const pt = self.pt;4523 const pt = self.pt;
4524 const zcu = pt.zcu;4524 const zcu = pt.zcu;
4525 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {4525 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {
4526 .Optional => blk: {4526 .optional => blk: {
4527 const payload_ty = lhs_ty.optionalChild(zcu);4527 const payload_ty = lhs_ty.optionalChild(zcu);
4528 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {4528 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
4529 break :blk Type.u1;4529 break :blk Type.u1;
...@@ -4533,12 +4533,12 @@ fn cmp(...@@ -4533,12 +4533,12 @@ fn cmp(
4533 return self.fail("TODO ARM cmp non-pointer optionals", .{});4533 return self.fail("TODO ARM cmp non-pointer optionals", .{});
4534 }4534 }
4535 },4535 },
4536 .Float => return self.fail("TODO ARM cmp floats", .{}),4536 .float => return self.fail("TODO ARM cmp floats", .{}),
4537 .Enum => lhs_ty.intTagType(zcu),4537 .@"enum" => lhs_ty.intTagType(zcu),
4538 .Int => lhs_ty,4538 .int => lhs_ty,
4539 .Bool => Type.u1,4539 .bool => Type.u1,
4540 .Pointer => Type.usize,4540 .pointer => Type.usize,
4541 .ErrorSet => Type.u16,4541 .error_set => Type.u16,
4542 else => unreachable,4542 else => unreachable,
4543 };4543 };
45444544
...@@ -6243,7 +6243,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6243,7 +6243,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6243 var ncrn: usize = 0; // Next Core Register Number6243 var ncrn: usize = 0; // Next Core Register Number
6244 var nsaa: u32 = 0; // Next stacked argument address6244 var nsaa: u32 = 0; // Next stacked argument address
62456245
6246 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {6246 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
6247 result.return_value = .{ .unreach = {} };6247 result.return_value = .{ .unreach = {} };
6248 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) {6248 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) {
6249 result.return_value = .{ .none = {} };6249 result.return_value = .{ .none = {} };
...@@ -6301,7 +6301,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6301,7 +6301,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6301 result.stack_align = 16;6301 result.stack_align = 16;
6302 },6302 },
6303 .Unspecified => {6303 .Unspecified => {
6304 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {6304 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
6305 result.return_value = .{ .unreach = {} };6305 result.return_value = .{ .unreach = {} };
6306 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) {6306 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) {
6307 result.return_value = .{ .none = {} };6307 result.return_value = .{ .none = {} };
src/arch/aarch64/abi.zig+27-27
...@@ -20,7 +20,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {...@@ -20,7 +20,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {
2020
21 var maybe_float_bits: ?u16 = null;21 var maybe_float_bits: ?u16 = null;
22 switch (ty.zigTypeTag(zcu)) {22 switch (ty.zigTypeTag(zcu)) {
23 .Struct => {23 .@"struct" => {
24 if (ty.containerLayout(zcu) == .@"packed") return .byval;24 if (ty.containerLayout(zcu) == .@"packed") return .byval;
25 const float_count = countFloats(ty, zcu, &maybe_float_bits);25 const float_count = countFloats(ty, zcu, &maybe_float_bits);
26 if (float_count <= sret_float_count) return .{ .float_array = float_count };26 if (float_count <= sret_float_count) return .{ .float_array = float_count };
...@@ -30,7 +30,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {...@@ -30,7 +30,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {
30 if (bit_size > 64) return .double_integer;30 if (bit_size > 64) return .double_integer;
31 return .integer;31 return .integer;
32 },32 },
33 .Union => {33 .@"union" => {
34 if (ty.containerLayout(zcu) == .@"packed") return .byval;34 if (ty.containerLayout(zcu) == .@"packed") return .byval;
35 const float_count = countFloats(ty, zcu, &maybe_float_bits);35 const float_count = countFloats(ty, zcu, &maybe_float_bits);
36 if (float_count <= sret_float_count) return .{ .float_array = float_count };36 if (float_count <= sret_float_count) return .{ .float_array = float_count };
...@@ -40,35 +40,35 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {...@@ -40,35 +40,35 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {
40 if (bit_size > 64) return .double_integer;40 if (bit_size > 64) return .double_integer;
41 return .integer;41 return .integer;
42 },42 },
43 .Int, .Enum, .ErrorSet, .Float, .Bool => return .byval,43 .int, .@"enum", .error_set, .float, .bool => return .byval,
44 .Vector => {44 .vector => {
45 const bit_size = ty.bitSize(zcu);45 const bit_size = ty.bitSize(zcu);
46 // TODO is this controlled by a cpu feature?46 // TODO is this controlled by a cpu feature?
47 if (bit_size > 128) return .memory;47 if (bit_size > 128) return .memory;
48 return .byval;48 return .byval;
49 },49 },
50 .Optional => {50 .optional => {
51 std.debug.assert(ty.isPtrLikeOptional(zcu));51 std.debug.assert(ty.isPtrLikeOptional(zcu));
52 return .byval;52 return .byval;
53 },53 },
54 .Pointer => {54 .pointer => {
55 std.debug.assert(!ty.isSlice(zcu));55 std.debug.assert(!ty.isSlice(zcu));
56 return .byval;56 return .byval;
57 },57 },
58 .ErrorUnion,58 .error_union,
59 .Frame,59 .frame,
60 .AnyFrame,60 .@"anyframe",
61 .NoReturn,61 .noreturn,
62 .Void,62 .void,
63 .Type,63 .type,
64 .ComptimeFloat,64 .comptime_float,
65 .ComptimeInt,65 .comptime_int,
66 .Undefined,66 .undefined,
67 .Null,67 .null,
68 .Fn,68 .@"fn",
69 .Opaque,69 .@"opaque",
70 .EnumLiteral,70 .enum_literal,
71 .Array,71 .array,
72 => unreachable,72 => unreachable,
73 }73 }
74}74}
...@@ -79,7 +79,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {...@@ -79,7 +79,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {
79 const target = zcu.getTarget();79 const target = zcu.getTarget();
80 const invalid = std.math.maxInt(u8);80 const invalid = std.math.maxInt(u8);
81 switch (ty.zigTypeTag(zcu)) {81 switch (ty.zigTypeTag(zcu)) {
82 .Union => {82 .@"union" => {
83 const union_obj = zcu.typeToUnion(ty).?;83 const union_obj = zcu.typeToUnion(ty).?;
84 var max_count: u8 = 0;84 var max_count: u8 = 0;
85 for (union_obj.field_types.get(ip)) |field_ty| {85 for (union_obj.field_types.get(ip)) |field_ty| {
...@@ -90,7 +90,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {...@@ -90,7 +90,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {
90 }90 }
91 return max_count;91 return max_count;
92 },92 },
93 .Struct => {93 .@"struct" => {
94 const fields_len = ty.structFieldCount(zcu);94 const fields_len = ty.structFieldCount(zcu);
95 var count: u8 = 0;95 var count: u8 = 0;
96 var i: u32 = 0;96 var i: u32 = 0;
...@@ -103,7 +103,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {...@@ -103,7 +103,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {
103 }103 }
104 return count;104 return count;
105 },105 },
106 .Float => {106 .float => {
107 const float_bits = maybe_float_bits.* orelse {107 const float_bits = maybe_float_bits.* orelse {
108 maybe_float_bits.* = ty.floatBits(target);108 maybe_float_bits.* = ty.floatBits(target);
109 return 1;109 return 1;
...@@ -111,7 +111,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {...@@ -111,7 +111,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {
111 if (ty.floatBits(target) == float_bits) return 1;111 if (ty.floatBits(target) == float_bits) return 1;
112 return invalid;112 return invalid;
113 },113 },
114 .Void => return 0,114 .void => return 0,
115 else => return invalid,115 else => return invalid,
116 }116 }
117}117}
...@@ -119,14 +119,14 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {...@@ -119,14 +119,14 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u8 {
119pub fn getFloatArrayType(ty: Type, zcu: *Zcu) ?Type {119pub fn getFloatArrayType(ty: Type, zcu: *Zcu) ?Type {
120 const ip = &zcu.intern_pool;120 const ip = &zcu.intern_pool;
121 switch (ty.zigTypeTag(zcu)) {121 switch (ty.zigTypeTag(zcu)) {
122 .Union => {122 .@"union" => {
123 const union_obj = zcu.typeToUnion(ty).?;123 const union_obj = zcu.typeToUnion(ty).?;
124 for (union_obj.field_types.get(ip)) |field_ty| {124 for (union_obj.field_types.get(ip)) |field_ty| {
125 if (getFloatArrayType(Type.fromInterned(field_ty), zcu)) |some| return some;125 if (getFloatArrayType(Type.fromInterned(field_ty), zcu)) |some| return some;
126 }126 }
127 return null;127 return null;
128 },128 },
129 .Struct => {129 .@"struct" => {
130 const fields_len = ty.structFieldCount(zcu);130 const fields_len = ty.structFieldCount(zcu);
131 var i: u32 = 0;131 var i: u32 = 0;
132 while (i < fields_len) : (i += 1) {132 while (i < fields_len) : (i += 1) {
...@@ -135,7 +135,7 @@ pub fn getFloatArrayType(ty: Type, zcu: *Zcu) ?Type {...@@ -135,7 +135,7 @@ pub fn getFloatArrayType(ty: Type, zcu: *Zcu) ?Type {
135 }135 }
136 return null;136 return null;
137 },137 },
138 .Float => return ty,138 .float => return ty,
139 else => return null,139 else => return null,
140 }140 }
141}141}
src/arch/arm/CodeGen.zig+58-58
...@@ -1286,7 +1286,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {...@@ -1286,7 +1286,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
1286 .cpsr_flags => |cond| break :result MCValue{ .cpsr_flags = cond.negate() },1286 .cpsr_flags => |cond| break :result MCValue{ .cpsr_flags = cond.negate() },
1287 else => {1287 else => {
1288 switch (operand_ty.zigTypeTag(zcu)) {1288 switch (operand_ty.zigTypeTag(zcu)) {
1289 .Bool => {1289 .bool => {
1290 var op_reg: Register = undefined;1290 var op_reg: Register = undefined;
1291 var dest_reg: Register = undefined;1291 var dest_reg: Register = undefined;
12921292
...@@ -1316,8 +1316,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {...@@ -1316,8 +1316,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
13161316
1317 break :result MCValue{ .register = dest_reg };1317 break :result MCValue{ .register = dest_reg };
1318 },1318 },
1319 .Vector => return self.fail("TODO bitwise not for vectors", .{}),1319 .vector => return self.fail("TODO bitwise not for vectors", .{}),
1320 .Int => {1320 .int => {
1321 const int_info = operand_ty.intInfo(zcu);1321 const int_info = operand_ty.intInfo(zcu);
1322 if (int_info.bits <= 32) {1322 if (int_info.bits <= 32) {
1323 var op_reg: Register = undefined;1323 var op_reg: Register = undefined;
...@@ -1375,9 +1375,9 @@ fn minMax(...@@ -1375,9 +1375,9 @@ fn minMax(
1375 const pt = self.pt;1375 const pt = self.pt;
1376 const zcu = pt.zcu;1376 const zcu = pt.zcu;
1377 switch (lhs_ty.zigTypeTag(zcu)) {1377 switch (lhs_ty.zigTypeTag(zcu)) {
1378 .Float => return self.fail("TODO ARM min/max on floats", .{}),1378 .float => return self.fail("TODO ARM min/max on floats", .{}),
1379 .Vector => return self.fail("TODO ARM min/max on vectors", .{}),1379 .vector => return self.fail("TODO ARM min/max on vectors", .{}),
1380 .Int => {1380 .int => {
1381 assert(lhs_ty.eql(rhs_ty, zcu));1381 assert(lhs_ty.eql(rhs_ty, zcu));
1382 const int_info = lhs_ty.intInfo(zcu);1382 const int_info = lhs_ty.intInfo(zcu);
1383 if (int_info.bits <= 32) {1383 if (int_info.bits <= 32) {
...@@ -1596,8 +1596,8 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -1596,8 +1596,8 @@ fn airOverflow(self: *Self, inst: Air.Inst.Index) !void {
1596 const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu));1596 const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu));
15971597
1598 switch (lhs_ty.zigTypeTag(zcu)) {1598 switch (lhs_ty.zigTypeTag(zcu)) {
1599 .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}),1599 .vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}),
1600 .Int => {1600 .int => {
1601 assert(lhs_ty.eql(rhs_ty, zcu));1601 assert(lhs_ty.eql(rhs_ty, zcu));
1602 const int_info = lhs_ty.intInfo(zcu);1602 const int_info = lhs_ty.intInfo(zcu);
1603 if (int_info.bits < 32) {1603 if (int_info.bits < 32) {
...@@ -1710,8 +1710,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -1710,8 +1710,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
1710 const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu));1710 const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu));
17111711
1712 switch (lhs_ty.zigTypeTag(zcu)) {1712 switch (lhs_ty.zigTypeTag(zcu)) {
1713 .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),1713 .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),
1714 .Int => {1714 .int => {
1715 assert(lhs_ty.eql(rhs_ty, zcu));1715 assert(lhs_ty.eql(rhs_ty, zcu));
1716 const int_info = lhs_ty.intInfo(zcu);1716 const int_info = lhs_ty.intInfo(zcu);
1717 if (int_info.bits <= 16) {1717 if (int_info.bits <= 16) {
...@@ -1873,8 +1873,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -1873,8 +1873,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
1873 const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu));1873 const overflow_bit_offset: u32 = @intCast(tuple_ty.structFieldOffset(1, zcu));
18741874
1875 switch (lhs_ty.zigTypeTag(zcu)) {1875 switch (lhs_ty.zigTypeTag(zcu)) {
1876 .Vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}),1876 .vector => return self.fail("TODO implement shl_with_overflow for vectors", .{}),
1877 .Int => {1877 .int => {
1878 const int_info = lhs_ty.intInfo(zcu);1878 const int_info = lhs_ty.intInfo(zcu);
1879 if (int_info.bits <= 32) {1879 if (int_info.bits <= 32) {
1880 const stack_offset = try self.allocMem(tuple_size, tuple_align, inst);1880 const stack_offset = try self.allocMem(tuple_size, tuple_align, inst);
...@@ -3021,7 +3021,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {...@@ -3021,7 +3021,7 @@ fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void {
3021 const field_ptr = try self.resolveInst(extra.field_ptr);3021 const field_ptr = try self.resolveInst(extra.field_ptr);
3022 const struct_ty = ty_pl.ty.toType().childType(zcu);3022 const struct_ty = ty_pl.ty.toType().childType(zcu);
30233023
3024 if (struct_ty.zigTypeTag(zcu) == .Union) {3024 if (struct_ty.zigTypeTag(zcu) == .@"union") {
3025 return self.fail("TODO implement @fieldParentPtr codegen for unions", .{});3025 return self.fail("TODO implement @fieldParentPtr codegen for unions", .{});
3026 }3026 }
30273027
...@@ -3411,9 +3411,9 @@ fn addSub(...@@ -3411,9 +3411,9 @@ fn addSub(
3411 const pt = self.pt;3411 const pt = self.pt;
3412 const zcu = pt.zcu;3412 const zcu = pt.zcu;
3413 switch (lhs_ty.zigTypeTag(zcu)) {3413 switch (lhs_ty.zigTypeTag(zcu)) {
3414 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3414 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3415 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3415 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3416 .Int => {3416 .int => {
3417 assert(lhs_ty.eql(rhs_ty, zcu));3417 assert(lhs_ty.eql(rhs_ty, zcu));
3418 const int_info = lhs_ty.intInfo(zcu);3418 const int_info = lhs_ty.intInfo(zcu);
3419 if (int_info.bits <= 32) {3419 if (int_info.bits <= 32) {
...@@ -3468,9 +3468,9 @@ fn mul(...@@ -3468,9 +3468,9 @@ fn mul(
3468 const pt = self.pt;3468 const pt = self.pt;
3469 const zcu = pt.zcu;3469 const zcu = pt.zcu;
3470 switch (lhs_ty.zigTypeTag(zcu)) {3470 switch (lhs_ty.zigTypeTag(zcu)) {
3471 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3471 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3472 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3472 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3473 .Int => {3473 .int => {
3474 assert(lhs_ty.eql(rhs_ty, zcu));3474 assert(lhs_ty.eql(rhs_ty, zcu));
3475 const int_info = lhs_ty.intInfo(zcu);3475 const int_info = lhs_ty.intInfo(zcu);
3476 if (int_info.bits <= 32) {3476 if (int_info.bits <= 32) {
...@@ -3502,8 +3502,8 @@ fn divFloat(...@@ -3502,8 +3502,8 @@ fn divFloat(
3502 const pt = self.pt;3502 const pt = self.pt;
3503 const zcu = pt.zcu;3503 const zcu = pt.zcu;
3504 switch (lhs_ty.zigTypeTag(zcu)) {3504 switch (lhs_ty.zigTypeTag(zcu)) {
3505 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3505 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3506 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3506 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3507 else => unreachable,3507 else => unreachable,
3508 }3508 }
3509}3509}
...@@ -3519,9 +3519,9 @@ fn divTrunc(...@@ -3519,9 +3519,9 @@ fn divTrunc(
3519 const pt = self.pt;3519 const pt = self.pt;
3520 const zcu = pt.zcu;3520 const zcu = pt.zcu;
3521 switch (lhs_ty.zigTypeTag(zcu)) {3521 switch (lhs_ty.zigTypeTag(zcu)) {
3522 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3522 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3523 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3523 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3524 .Int => {3524 .int => {
3525 assert(lhs_ty.eql(rhs_ty, zcu));3525 assert(lhs_ty.eql(rhs_ty, zcu));
3526 const int_info = lhs_ty.intInfo(zcu);3526 const int_info = lhs_ty.intInfo(zcu);
3527 if (int_info.bits <= 32) {3527 if (int_info.bits <= 32) {
...@@ -3563,9 +3563,9 @@ fn divFloor(...@@ -3563,9 +3563,9 @@ fn divFloor(
3563 const pt = self.pt;3563 const pt = self.pt;
3564 const zcu = pt.zcu;3564 const zcu = pt.zcu;
3565 switch (lhs_ty.zigTypeTag(zcu)) {3565 switch (lhs_ty.zigTypeTag(zcu)) {
3566 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3566 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3567 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3567 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3568 .Int => {3568 .int => {
3569 assert(lhs_ty.eql(rhs_ty, zcu));3569 assert(lhs_ty.eql(rhs_ty, zcu));
3570 const int_info = lhs_ty.intInfo(zcu);3570 const int_info = lhs_ty.intInfo(zcu);
3571 if (int_info.bits <= 32) {3571 if (int_info.bits <= 32) {
...@@ -3612,9 +3612,9 @@ fn divExact(...@@ -3612,9 +3612,9 @@ fn divExact(
3612 const pt = self.pt;3612 const pt = self.pt;
3613 const zcu = pt.zcu;3613 const zcu = pt.zcu;
3614 switch (lhs_ty.zigTypeTag(zcu)) {3614 switch (lhs_ty.zigTypeTag(zcu)) {
3615 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3615 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3616 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3616 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3617 .Int => return self.fail("TODO ARM div_exact", .{}),3617 .int => return self.fail("TODO ARM div_exact", .{}),
3618 else => unreachable,3618 else => unreachable,
3619 }3619 }
3620}3620}
...@@ -3630,9 +3630,9 @@ fn rem(...@@ -3630,9 +3630,9 @@ fn rem(
3630 const pt = self.pt;3630 const pt = self.pt;
3631 const zcu = pt.zcu;3631 const zcu = pt.zcu;
3632 switch (lhs_ty.zigTypeTag(zcu)) {3632 switch (lhs_ty.zigTypeTag(zcu)) {
3633 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3633 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3634 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3634 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3635 .Int => {3635 .int => {
3636 assert(lhs_ty.eql(rhs_ty, zcu));3636 assert(lhs_ty.eql(rhs_ty, zcu));
3637 const int_info = lhs_ty.intInfo(zcu);3637 const int_info = lhs_ty.intInfo(zcu);
3638 if (int_info.bits <= 32) {3638 if (int_info.bits <= 32) {
...@@ -3700,9 +3700,9 @@ fn modulo(...@@ -3700,9 +3700,9 @@ fn modulo(
3700 const pt = self.pt;3700 const pt = self.pt;
3701 const zcu = pt.zcu;3701 const zcu = pt.zcu;
3702 switch (lhs_ty.zigTypeTag(zcu)) {3702 switch (lhs_ty.zigTypeTag(zcu)) {
3703 .Float => return self.fail("TODO ARM binary operations on floats", .{}),3703 .float => return self.fail("TODO ARM binary operations on floats", .{}),
3704 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3704 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3705 .Int => return self.fail("TODO ARM zcu", .{}),3705 .int => return self.fail("TODO ARM zcu", .{}),
3706 else => unreachable,3706 else => unreachable,
3707 }3707 }
3708}3708}
...@@ -3719,8 +3719,8 @@ fn wrappingArithmetic(...@@ -3719,8 +3719,8 @@ fn wrappingArithmetic(
3719 const pt = self.pt;3719 const pt = self.pt;
3720 const zcu = pt.zcu;3720 const zcu = pt.zcu;
3721 switch (lhs_ty.zigTypeTag(zcu)) {3721 switch (lhs_ty.zigTypeTag(zcu)) {
3722 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3722 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3723 .Int => {3723 .int => {
3724 const int_info = lhs_ty.intInfo(zcu);3724 const int_info = lhs_ty.intInfo(zcu);
3725 if (int_info.bits <= 32) {3725 if (int_info.bits <= 32) {
3726 // Generate an add/sub/mul3726 // Generate an add/sub/mul
...@@ -3758,8 +3758,8 @@ fn bitwise(...@@ -3758,8 +3758,8 @@ fn bitwise(
3758 const pt = self.pt;3758 const pt = self.pt;
3759 const zcu = pt.zcu;3759 const zcu = pt.zcu;
3760 switch (lhs_ty.zigTypeTag(zcu)) {3760 switch (lhs_ty.zigTypeTag(zcu)) {
3761 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3761 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3762 .Int => {3762 .int => {
3763 assert(lhs_ty.eql(rhs_ty, zcu));3763 assert(lhs_ty.eql(rhs_ty, zcu));
3764 const int_info = lhs_ty.intInfo(zcu);3764 const int_info = lhs_ty.intInfo(zcu);
3765 if (int_info.bits <= 32) {3765 if (int_info.bits <= 32) {
...@@ -3804,8 +3804,8 @@ fn shiftExact(...@@ -3804,8 +3804,8 @@ fn shiftExact(
3804 const pt = self.pt;3804 const pt = self.pt;
3805 const zcu = pt.zcu;3805 const zcu = pt.zcu;
3806 switch (lhs_ty.zigTypeTag(zcu)) {3806 switch (lhs_ty.zigTypeTag(zcu)) {
3807 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3807 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3808 .Int => {3808 .int => {
3809 const int_info = lhs_ty.intInfo(zcu);3809 const int_info = lhs_ty.intInfo(zcu);
3810 if (int_info.bits <= 32) {3810 if (int_info.bits <= 32) {
3811 const rhs_immediate = try rhs_bind.resolveToImmediate(self);3811 const rhs_immediate = try rhs_bind.resolveToImmediate(self);
...@@ -3844,8 +3844,8 @@ fn shiftNormal(...@@ -3844,8 +3844,8 @@ fn shiftNormal(
3844 const pt = self.pt;3844 const pt = self.pt;
3845 const zcu = pt.zcu;3845 const zcu = pt.zcu;
3846 switch (lhs_ty.zigTypeTag(zcu)) {3846 switch (lhs_ty.zigTypeTag(zcu)) {
3847 .Vector => return self.fail("TODO ARM binary operations on vectors", .{}),3847 .vector => return self.fail("TODO ARM binary operations on vectors", .{}),
3848 .Int => {3848 .int => {
3849 const int_info = lhs_ty.intInfo(zcu);3849 const int_info = lhs_ty.intInfo(zcu);
3850 if (int_info.bits <= 32) {3850 if (int_info.bits <= 32) {
3851 // Generate a shl_exact/shr_exact3851 // Generate a shl_exact/shr_exact
...@@ -3888,7 +3888,7 @@ fn booleanOp(...@@ -3888,7 +3888,7 @@ fn booleanOp(
3888 const pt = self.pt;3888 const pt = self.pt;
3889 const zcu = pt.zcu;3889 const zcu = pt.zcu;
3890 switch (lhs_ty.zigTypeTag(zcu)) {3890 switch (lhs_ty.zigTypeTag(zcu)) {
3891 .Bool => {3891 .bool => {
3892 const lhs_immediate = try lhs_bind.resolveToImmediate(self);3892 const lhs_immediate = try lhs_bind.resolveToImmediate(self);
3893 const rhs_immediate = try rhs_bind.resolveToImmediate(self);3893 const rhs_immediate = try rhs_bind.resolveToImmediate(self);
38943894
...@@ -3923,7 +3923,7 @@ fn ptrArithmetic(...@@ -3923,7 +3923,7 @@ fn ptrArithmetic(
3923 const pt = self.pt;3923 const pt = self.pt;
3924 const zcu = pt.zcu;3924 const zcu = pt.zcu;
3925 switch (lhs_ty.zigTypeTag(zcu)) {3925 switch (lhs_ty.zigTypeTag(zcu)) {
3926 .Pointer => {3926 .pointer => {
3927 assert(rhs_ty.eql(Type.usize, zcu));3927 assert(rhs_ty.eql(Type.usize, zcu));
39283928
3929 const ptr_ty = lhs_ty;3929 const ptr_ty = lhs_ty;
...@@ -4259,8 +4259,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4259,8 +4259,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4259 const ip = &zcu.intern_pool;4259 const ip = &zcu.intern_pool;
42604260
4261 const fn_ty = switch (ty.zigTypeTag(zcu)) {4261 const fn_ty = switch (ty.zigTypeTag(zcu)) {
4262 .Fn => ty,4262 .@"fn" => ty,
4263 .Pointer => ty.childType(zcu),4263 .pointer => ty.childType(zcu),
4264 else => unreachable,4264 else => unreachable,
4265 };4265 };
42664266
...@@ -4337,7 +4337,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -4337,7 +4337,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
4337 return self.fail("TODO implement calling bitcasted functions", .{});4337 return self.fail("TODO implement calling bitcasted functions", .{});
4338 },4338 },
4339 } else {4339 } else {
4340 assert(ty.zigTypeTag(zcu) == .Pointer);4340 assert(ty.zigTypeTag(zcu) == .pointer);
4341 const mcv = try self.resolveInst(callee);4341 const mcv = try self.resolveInst(callee);
43424342
4343 try self.genSetReg(Type.usize, .lr, mcv);4343 try self.genSetReg(Type.usize, .lr, mcv);
...@@ -4494,7 +4494,7 @@ fn cmp(...@@ -4494,7 +4494,7 @@ fn cmp(
4494 const pt = self.pt;4494 const pt = self.pt;
4495 const zcu = pt.zcu;4495 const zcu = pt.zcu;
4496 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {4496 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {
4497 .Optional => blk: {4497 .optional => blk: {
4498 const payload_ty = lhs_ty.optionalChild(zcu);4498 const payload_ty = lhs_ty.optionalChild(zcu);
4499 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {4499 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
4500 break :blk Type.u1;4500 break :blk Type.u1;
...@@ -4504,12 +4504,12 @@ fn cmp(...@@ -4504,12 +4504,12 @@ fn cmp(
4504 return self.fail("TODO ARM cmp non-pointer optionals", .{});4504 return self.fail("TODO ARM cmp non-pointer optionals", .{});
4505 }4505 }
4506 },4506 },
4507 .Float => return self.fail("TODO ARM cmp floats", .{}),4507 .float => return self.fail("TODO ARM cmp floats", .{}),
4508 .Enum => lhs_ty.intTagType(zcu),4508 .@"enum" => lhs_ty.intTagType(zcu),
4509 .Int => lhs_ty,4509 .int => lhs_ty,
4510 .Bool => Type.u1,4510 .bool => Type.u1,
4511 .Pointer => Type.usize,4511 .pointer => Type.usize,
4512 .ErrorSet => Type.u16,4512 .error_set => Type.u16,
4513 else => unreachable,4513 else => unreachable,
4514 };4514 };
45154515
...@@ -6211,7 +6211,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6211,7 +6211,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6211 var ncrn: usize = 0; // Next Core Register Number6211 var ncrn: usize = 0; // Next Core Register Number
6212 var nsaa: u32 = 0; // Next stacked argument address6212 var nsaa: u32 = 0; // Next stacked argument address
62136213
6214 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {6214 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
6215 result.return_value = .{ .unreach = {} };6215 result.return_value = .{ .unreach = {} };
6216 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {6216 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
6217 result.return_value = .{ .none = {} };6217 result.return_value = .{ .none = {} };
...@@ -6258,7 +6258,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {...@@ -6258,7 +6258,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type) !CallMCValues {
6258 result.stack_align = 8;6258 result.stack_align = 8;
6259 },6259 },
6260 .Unspecified => {6260 .Unspecified => {
6261 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {6261 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
6262 result.return_value = .{ .unreach = {} };6262 result.return_value = .{ .unreach = {} };
6263 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) {6263 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu) and !ret_ty.isError(zcu)) {
6264 result.return_value = .{ .none = {} };6264 result.return_value = .{ .none = {} };
src/arch/arm/abi.zig+26-26
...@@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class {...@@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class {
31 const max_byval_size = 512;31 const max_byval_size = 512;
32 const ip = &zcu.intern_pool;32 const ip = &zcu.intern_pool;
33 switch (ty.zigTypeTag(zcu)) {33 switch (ty.zigTypeTag(zcu)) {
34 .Struct => {34 .@"struct" => {
35 const bit_size = ty.bitSize(zcu);35 const bit_size = ty.bitSize(zcu);
36 if (ty.containerLayout(zcu) == .@"packed") {36 if (ty.containerLayout(zcu) == .@"packed") {
37 if (bit_size > 64) return .memory;37 if (bit_size > 64) return .memory;
...@@ -53,7 +53,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class {...@@ -53,7 +53,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class {
53 }53 }
54 return Class.arrSize(bit_size, 32);54 return Class.arrSize(bit_size, 32);
55 },55 },
56 .Union => {56 .@"union" => {
57 const bit_size = ty.bitSize(zcu);57 const bit_size = ty.bitSize(zcu);
58 const union_obj = zcu.typeToUnion(ty).?;58 const union_obj = zcu.typeToUnion(ty).?;
59 if (union_obj.flagsUnordered(ip).layout == .@"packed") {59 if (union_obj.flagsUnordered(ip).layout == .@"packed") {
...@@ -73,48 +73,48 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class {...@@ -73,48 +73,48 @@ pub fn classifyType(ty: Type, zcu: *Zcu, ctx: Context) Class {
73 }73 }
74 return Class.arrSize(bit_size, 32);74 return Class.arrSize(bit_size, 32);
75 },75 },
76 .Bool, .Float => return .byval,76 .bool, .float => return .byval,
77 .Int => {77 .int => {
78 // TODO this is incorrect for _BitInt(128) but implementing78 // TODO this is incorrect for _BitInt(128) but implementing
79 // this correctly makes implementing compiler-rt impossible.79 // this correctly makes implementing compiler-rt impossible.
80 // const bit_size = ty.bitSize(zcu);80 // const bit_size = ty.bitSize(zcu);
81 // if (bit_size > 64) return .memory;81 // if (bit_size > 64) return .memory;
82 return .byval;82 return .byval;
83 },83 },
84 .Enum, .ErrorSet => {84 .@"enum", .error_set => {
85 const bit_size = ty.bitSize(zcu);85 const bit_size = ty.bitSize(zcu);
86 if (bit_size > 64) return .memory;86 if (bit_size > 64) return .memory;
87 return .byval;87 return .byval;
88 },88 },
89 .Vector => {89 .vector => {
90 const bit_size = ty.bitSize(zcu);90 const bit_size = ty.bitSize(zcu);
91 // TODO is this controlled by a cpu feature?91 // TODO is this controlled by a cpu feature?
92 if (ctx == .ret and bit_size > 128) return .memory;92 if (ctx == .ret and bit_size > 128) return .memory;
93 if (bit_size > 512) return .memory;93 if (bit_size > 512) return .memory;
94 return .byval;94 return .byval;
95 },95 },
96 .Optional => {96 .optional => {
97 assert(ty.isPtrLikeOptional(zcu));97 assert(ty.isPtrLikeOptional(zcu));
98 return .byval;98 return .byval;
99 },99 },
100 .Pointer => {100 .pointer => {
101 assert(!ty.isSlice(zcu));101 assert(!ty.isSlice(zcu));
102 return .byval;102 return .byval;
103 },103 },
104 .ErrorUnion,104 .error_union,
105 .Frame,105 .frame,
106 .AnyFrame,106 .@"anyframe",
107 .NoReturn,107 .noreturn,
108 .Void,108 .void,
109 .Type,109 .type,
110 .ComptimeFloat,110 .comptime_float,
111 .ComptimeInt,111 .comptime_int,
112 .Undefined,112 .undefined,
113 .Null,113 .null,
114 .Fn,114 .@"fn",
115 .Opaque,115 .@"opaque",
116 .EnumLiteral,116 .enum_literal,
117 .Array,117 .array,
118 => unreachable,118 => unreachable,
119 }119 }
120}120}
...@@ -125,7 +125,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {...@@ -125,7 +125,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {
125 const target = zcu.getTarget();125 const target = zcu.getTarget();
126 const invalid = std.math.maxInt(u32);126 const invalid = std.math.maxInt(u32);
127 switch (ty.zigTypeTag(zcu)) {127 switch (ty.zigTypeTag(zcu)) {
128 .Union => {128 .@"union" => {
129 const union_obj = zcu.typeToUnion(ty).?;129 const union_obj = zcu.typeToUnion(ty).?;
130 var max_count: u32 = 0;130 var max_count: u32 = 0;
131 for (union_obj.field_types.get(ip)) |field_ty| {131 for (union_obj.field_types.get(ip)) |field_ty| {
...@@ -136,7 +136,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {...@@ -136,7 +136,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {
136 }136 }
137 return max_count;137 return max_count;
138 },138 },
139 .Struct => {139 .@"struct" => {
140 const fields_len = ty.structFieldCount(zcu);140 const fields_len = ty.structFieldCount(zcu);
141 var count: u32 = 0;141 var count: u32 = 0;
142 var i: u32 = 0;142 var i: u32 = 0;
...@@ -149,7 +149,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {...@@ -149,7 +149,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {
149 }149 }
150 return count;150 return count;
151 },151 },
152 .Float => {152 .float => {
153 const float_bits = maybe_float_bits.* orelse {153 const float_bits = maybe_float_bits.* orelse {
154 const float_bits = ty.floatBits(target);154 const float_bits = ty.floatBits(target);
155 if (float_bits != 32 and float_bits != 64) return invalid;155 if (float_bits != 32 and float_bits != 64) return invalid;
...@@ -159,7 +159,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {...@@ -159,7 +159,7 @@ fn countFloats(ty: Type, zcu: *Zcu, maybe_float_bits: *?u16) u32 {
159 if (ty.floatBits(target) == float_bits) return 1;159 if (ty.floatBits(target) == float_bits) return 1;
160 return invalid;160 return invalid;
161 },161 },
162 .Void => return 0,162 .void => return 0,
163 else => return invalid,163 else => return invalid,
164 }164 }
165}165}
src/arch/arm/bits.zig+2-2
...@@ -1299,7 +1299,7 @@ pub const Instruction = union(enum) {...@@ -1299,7 +1299,7 @@ pub const Instruction = union(enum) {
1299 }1299 }
13001300
1301 pub fn pop(cond: Condition, args: anytype) Instruction {1301 pub fn pop(cond: Condition, args: anytype) Instruction {
1302 if (@typeInfo(@TypeOf(args)) != .Struct) {1302 if (@typeInfo(@TypeOf(args)) != .@"struct") {
1303 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));1303 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
1304 }1304 }
13051305
...@@ -1323,7 +1323,7 @@ pub const Instruction = union(enum) {...@@ -1323,7 +1323,7 @@ pub const Instruction = union(enum) {
1323 }1323 }
13241324
1325 pub fn push(cond: Condition, args: anytype) Instruction {1325 pub fn push(cond: Condition, args: anytype) Instruction {
1326 if (@typeInfo(@TypeOf(args)) != .Struct) {1326 if (@typeInfo(@TypeOf(args)) != .@"struct") {
1327 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));1327 @compileError("Expected tuple or struct argument, found " ++ @typeName(@TypeOf(args)));
1328 }1328 }
13291329
src/arch/riscv64/CodeGen.zig+55-55
...@@ -675,14 +675,14 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt...@@ -675,14 +675,14 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt
675 ) |inst, *tracking| tracking.resurrect(inst, state.scope_generation);675 ) |inst, *tracking| tracking.resurrect(inst, state.scope_generation);
676 for (deaths) |death| try func.processDeath(death);676 for (deaths) |death| try func.processDeath(death);
677677
678 const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).Array.len]RegisterLock;678 const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
679 var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =679 var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
680 if (opts.update_tracking)680 if (opts.update_tracking)
681 {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);681 {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
682682
683 var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(683 var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
684 stack.get(),684 stack.get(),
685 @typeInfo(ExpectedContents).Array.len,685 @typeInfo(ExpectedContents).array.len,
686 );686 );
687 defer if (!opts.update_tracking) {687 defer if (!opts.update_tracking) {
688 for (reg_locks.items) |lock| func.register_manager.unlockReg(lock);688 for (reg_locks.items) |lock| func.register_manager.unlockReg(lock);
...@@ -1382,7 +1382,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void {...@@ -1382,7 +1382,7 @@ fn genLazy(func: *Func, lazy_sym: link.File.LazySymbol) InnerError!void {
1382 const zcu = pt.zcu;1382 const zcu = pt.zcu;
1383 const ip = &zcu.intern_pool;1383 const ip = &zcu.intern_pool;
1384 switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) {1384 switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) {
1385 .Enum => {1385 .@"enum" => {
1386 const enum_ty = Type.fromInterned(lazy_sym.ty);1386 const enum_ty = Type.fromInterned(lazy_sym.ty);
1387 wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)});1387 wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)});
13881388
...@@ -1945,7 +1945,7 @@ fn memSize(func: *Func, ty: Type) Memory.Size {...@@ -1945,7 +1945,7 @@ fn memSize(func: *Func, ty: Type) Memory.Size {
1945 const pt = func.pt;1945 const pt = func.pt;
1946 const zcu = pt.zcu;1946 const zcu = pt.zcu;
1947 return switch (ty.zigTypeTag(zcu)) {1947 return switch (ty.zigTypeTag(zcu)) {
1948 .Float => Memory.Size.fromBitSize(ty.floatBits(func.target.*)),1948 .float => Memory.Size.fromBitSize(ty.floatBits(func.target.*)),
1949 else => Memory.Size.fromByteSize(ty.abiSize(zcu)),1949 else => Memory.Size.fromByteSize(ty.abiSize(zcu)),
1950 };1950 };
1951}1951}
...@@ -2094,24 +2094,24 @@ fn typeRegClass(func: *Func, ty: Type) abi.RegisterClass {...@@ -2094,24 +2094,24 @@ fn typeRegClass(func: *Func, ty: Type) abi.RegisterClass {
2094 const pt = func.pt;2094 const pt = func.pt;
2095 const zcu = pt.zcu;2095 const zcu = pt.zcu;
2096 return switch (ty.zigTypeTag(zcu)) {2096 return switch (ty.zigTypeTag(zcu)) {
2097 .Float => .float,2097 .float => .float,
2098 .Vector => .vector,2098 .vector => .vector,
2099 else => .int,2099 else => .int,
2100 };2100 };
2101}2101}
21022102
2103fn regGeneralClassForType(func: *Func, ty: Type) RegisterManager.RegisterBitSet {2103fn regGeneralClassForType(func: *Func, ty: Type) RegisterManager.RegisterBitSet {
2104 return switch (ty.zigTypeTag(func.pt.zcu)) {2104 return switch (ty.zigTypeTag(func.pt.zcu)) {
2105 .Float => abi.Registers.Float.general_purpose,2105 .float => abi.Registers.Float.general_purpose,
2106 .Vector => abi.Registers.Vector.general_purpose,2106 .vector => abi.Registers.Vector.general_purpose,
2107 else => abi.Registers.Integer.general_purpose,2107 else => abi.Registers.Integer.general_purpose,
2108 };2108 };
2109}2109}
21102110
2111fn regTempClassForType(func: *Func, ty: Type) RegisterManager.RegisterBitSet {2111fn regTempClassForType(func: *Func, ty: Type) RegisterManager.RegisterBitSet {
2112 return switch (ty.zigTypeTag(func.pt.zcu)) {2112 return switch (ty.zigTypeTag(func.pt.zcu)) {
2113 .Float => abi.Registers.Float.temporary,2113 .float => abi.Registers.Float.temporary,
2114 .Vector => abi.Registers.Vector.general_purpose, // there are no temporary vector registers2114 .vector => abi.Registers.Vector.general_purpose, // there are no temporary vector registers
2115 else => abi.Registers.Integer.temporary,2115 else => abi.Registers.Integer.temporary,
2116 };2116 };
2117}2117}
...@@ -2122,8 +2122,8 @@ fn allocRegOrMem(func: *Func, elem_ty: Type, inst: ?Air.Inst.Index, reg_ok: bool...@@ -2122,8 +2122,8 @@ fn allocRegOrMem(func: *Func, elem_ty: Type, inst: ?Air.Inst.Index, reg_ok: bool
21222122
2123 const bit_size = elem_ty.bitSize(zcu);2123 const bit_size = elem_ty.bitSize(zcu);
2124 const min_size: u64 = switch (elem_ty.zigTypeTag(zcu)) {2124 const min_size: u64 = switch (elem_ty.zigTypeTag(zcu)) {
2125 .Float => if (func.hasFeature(.d)) 64 else 32,2125 .float => if (func.hasFeature(.d)) 64 else 32,
2126 .Vector => 256, // TODO: calculate it from avl * vsew2126 .vector => 256, // TODO: calculate it from avl * vsew
2127 else => 64,2127 else => 64,
2128 };2128 };
21292129
...@@ -2131,7 +2131,7 @@ fn allocRegOrMem(func: *Func, elem_ty: Type, inst: ?Air.Inst.Index, reg_ok: bool...@@ -2131,7 +2131,7 @@ fn allocRegOrMem(func: *Func, elem_ty: Type, inst: ?Air.Inst.Index, reg_ok: bool
2131 if (func.register_manager.tryAllocReg(inst, func.regGeneralClassForType(elem_ty))) |reg| {2131 if (func.register_manager.tryAllocReg(inst, func.regGeneralClassForType(elem_ty))) |reg| {
2132 return .{ .register = reg };2132 return .{ .register = reg };
2133 }2133 }
2134 } else if (reg_ok and elem_ty.zigTypeTag(zcu) == .Vector) {2134 } else if (reg_ok and elem_ty.zigTypeTag(zcu) == .vector) {
2135 return func.fail("did you forget to extend vector registers before allocating", .{});2135 return func.fail("did you forget to extend vector registers before allocating", .{});
2136 }2136 }
21372137
...@@ -2358,7 +2358,7 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {...@@ -2358,7 +2358,7 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {
2358 (try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;2358 (try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
23592359
2360 switch (ty.zigTypeTag(zcu)) {2360 switch (ty.zigTypeTag(zcu)) {
2361 .Bool => {2361 .bool => {
2362 _ = try func.addInst(.{2362 _ = try func.addInst(.{
2363 .tag = .pseudo_not,2363 .tag = .pseudo_not,
2364 .data = .{2364 .data = .{
...@@ -2369,7 +2369,7 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {...@@ -2369,7 +2369,7 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {
2369 },2369 },
2370 });2370 });
2371 },2371 },
2372 .Int => {2372 .int => {
2373 const size = ty.bitSize(zcu);2373 const size = ty.bitSize(zcu);
2374 if (!math.isPowerOfTwo(size))2374 if (!math.isPowerOfTwo(size))
2375 return func.fail("TODO: airNot non-pow 2 int size", .{});2375 return func.fail("TODO: airNot non-pow 2 int size", .{});
...@@ -2485,7 +2485,7 @@ fn binOp(...@@ -2485,7 +2485,7 @@ fn binOp(
24852485
2486 // don't have support for certain sizes of addition2486 // don't have support for certain sizes of addition
2487 switch (lhs_ty.zigTypeTag(zcu)) {2487 switch (lhs_ty.zigTypeTag(zcu)) {
2488 .Vector => {}, // works differently and fails in a different place2488 .vector => {}, // works differently and fails in a different place
2489 else => if (lhs_ty.bitSize(zcu) > 64) return func.fail("TODO: binOp >= 64 bits", .{}),2489 else => if (lhs_ty.bitSize(zcu) > 64) return func.fail("TODO: binOp >= 64 bits", .{}),
2490 }2490 }
24912491
...@@ -2578,7 +2578,7 @@ fn genBinOp(...@@ -2578,7 +2578,7 @@ fn genBinOp(
2578 }2578 }
25792579
2580 switch (lhs_ty.zigTypeTag(zcu)) {2580 switch (lhs_ty.zigTypeTag(zcu)) {
2581 .Int => {2581 .int => {
2582 const mnem: Mnemonic = switch (tag) {2582 const mnem: Mnemonic = switch (tag) {
2583 .add, .add_wrap => switch (bit_size) {2583 .add, .add_wrap => switch (bit_size) {
2584 8, 16, 64 => .add,2584 8, 16, 64 => .add,
...@@ -2617,7 +2617,7 @@ fn genBinOp(...@@ -2617,7 +2617,7 @@ fn genBinOp(
2617 },2617 },
2618 });2618 });
2619 },2619 },
2620 .Float => {2620 .float => {
2621 const mir_tag: Mnemonic = switch (tag) {2621 const mir_tag: Mnemonic = switch (tag) {
2622 .add => switch (bit_size) {2622 .add => switch (bit_size) {
2623 32 => .fadds,2623 32 => .fadds,
...@@ -2648,7 +2648,7 @@ fn genBinOp(...@@ -2648,7 +2648,7 @@ fn genBinOp(
2648 },2648 },
2649 });2649 });
2650 },2650 },
2651 .Vector => {2651 .vector => {
2652 const num_elem = lhs_ty.vectorLen(zcu);2652 const num_elem = lhs_ty.vectorLen(zcu);
2653 const elem_size = lhs_ty.childType(zcu).bitSize(zcu);2653 const elem_size = lhs_ty.childType(zcu).bitSize(zcu);
26542654
...@@ -2656,18 +2656,18 @@ fn genBinOp(...@@ -2656,18 +2656,18 @@ fn genBinOp(
26562656
2657 const mir_tag: Mnemonic = switch (tag) {2657 const mir_tag: Mnemonic = switch (tag) {
2658 .add => switch (child_ty.zigTypeTag(zcu)) {2658 .add => switch (child_ty.zigTypeTag(zcu)) {
2659 .Int => .vaddvv,2659 .int => .vaddvv,
2660 .Float => .vfaddvv,2660 .float => .vfaddvv,
2661 else => unreachable,2661 else => unreachable,
2662 },2662 },
2663 .sub => switch (child_ty.zigTypeTag(zcu)) {2663 .sub => switch (child_ty.zigTypeTag(zcu)) {
2664 .Int => .vsubvv,2664 .int => .vsubvv,
2665 .Float => .vfsubvv,2665 .float => .vfsubvv,
2666 else => unreachable,2666 else => unreachable,
2667 },2667 },
2668 .mul => switch (child_ty.zigTypeTag(zcu)) {2668 .mul => switch (child_ty.zigTypeTag(zcu)) {
2669 .Int => .vmulvv,2669 .int => .vmulvv,
2670 .Float => .vfmulvv,2670 .float => .vfmulvv,
2671 else => unreachable,2671 else => unreachable,
2672 },2672 },
2673 else => return func.fail("TODO: genBinOp {s} Vector", .{@tagName(tag)}),2673 else => return func.fail("TODO: genBinOp {s} Vector", .{@tagName(tag)}),
...@@ -2905,7 +2905,7 @@ fn genBinOp(...@@ -2905,7 +2905,7 @@ fn genBinOp(
2905 // s0 was 0, leaving a2 unchanged as a0.2905 // s0 was 0, leaving a2 unchanged as a0.
2906 .min, .max => {2906 .min, .max => {
2907 switch (lhs_ty.zigTypeTag(zcu)) {2907 switch (lhs_ty.zigTypeTag(zcu)) {
2908 .Int => {2908 .int => {
2909 const int_info = lhs_ty.intInfo(zcu);2909 const int_info = lhs_ty.intInfo(zcu);
29102910
2911 const mask_reg, const mask_lock = try func.allocReg(.int);2911 const mask_reg, const mask_lock = try func.allocReg(.int);
...@@ -2981,8 +2981,8 @@ fn airAddWithOverflow(func: *Func, inst: Air.Inst.Index) !void {...@@ -2981,8 +2981,8 @@ fn airAddWithOverflow(func: *Func, inst: Air.Inst.Index) !void {
29812981
2982 const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else result: {2982 const result: MCValue = if (func.liveness.isUnused(inst)) .unreach else result: {
2983 switch (lhs_ty.zigTypeTag(zcu)) {2983 switch (lhs_ty.zigTypeTag(zcu)) {
2984 .Vector => return func.fail("TODO implement add with overflow for Vector type", .{}),2984 .vector => return func.fail("TODO implement add with overflow for Vector type", .{}),
2985 .Int => {2985 .int => {
2986 const int_info = lhs_ty.intInfo(zcu);2986 const int_info = lhs_ty.intInfo(zcu);
29872987
2988 const tuple_ty = func.typeOfIndex(inst);2988 const tuple_ty = func.typeOfIndex(inst);
...@@ -3263,7 +3263,7 @@ fn airMulWithOverflow(func: *Func, inst: Air.Inst.Index) !void {...@@ -3263,7 +3263,7 @@ fn airMulWithOverflow(func: *Func, inst: Air.Inst.Index) !void {
32633263
3264 switch (lhs_ty.zigTypeTag(zcu)) {3264 switch (lhs_ty.zigTypeTag(zcu)) {
3265 else => |x| return func.fail("TODO: airMulWithOverflow {s}", .{@tagName(x)}),3265 else => |x| return func.fail("TODO: airMulWithOverflow {s}", .{@tagName(x)}),
3266 .Int => {3266 .int => {
3267 if (std.debug.runtime_safety) assert(lhs_ty.eql(rhs_ty, zcu));3267 if (std.debug.runtime_safety) assert(lhs_ty.eql(rhs_ty, zcu));
32683268
3269 const trunc_reg = try func.copyToTmpRegister(lhs_ty, .{ .register = dest_reg });3269 const trunc_reg = try func.copyToTmpRegister(lhs_ty, .{ .register = dest_reg });
...@@ -4129,7 +4129,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void {...@@ -4129,7 +4129,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void {
4129 const operand = try func.resolveInst(ty_op.operand);4129 const operand = try func.resolveInst(ty_op.operand);
41304130
4131 switch (scalar_ty.zigTypeTag(zcu)) {4131 switch (scalar_ty.zigTypeTag(zcu)) {
4132 .Int => if (ty.zigTypeTag(zcu) == .Vector) {4132 .int => if (ty.zigTypeTag(zcu) == .vector) {
4133 return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});4133 return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});
4134 } else {4134 } else {
4135 const int_info = scalar_ty.intInfo(zcu);4135 const int_info = scalar_ty.intInfo(zcu);
...@@ -4182,7 +4182,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void {...@@ -4182,7 +4182,7 @@ fn airAbs(func: *Func, inst: Air.Inst.Index) !void {
41824182
4183 break :result return_mcv;4183 break :result return_mcv;
4184 },4184 },
4185 .Float => {4185 .float => {
4186 const float_bits = scalar_ty.floatBits(zcu.getTarget());4186 const float_bits = scalar_ty.floatBits(zcu.getTarget());
4187 const mnem: Mnemonic = switch (float_bits) {4187 const mnem: Mnemonic = switch (float_bits) {
4188 16 => return func.fail("TODO: airAbs 16-bit float", .{}),4188 16 => return func.fail("TODO: airAbs 16-bit float", .{}),
...@@ -4228,7 +4228,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void {...@@ -4228,7 +4228,7 @@ fn airByteSwap(func: *Func, inst: Air.Inst.Index) !void {
4228 const operand = try func.resolveInst(ty_op.operand);4228 const operand = try func.resolveInst(ty_op.operand);
42294229
4230 switch (ty.zigTypeTag(zcu)) {4230 switch (ty.zigTypeTag(zcu)) {
4231 .Int => {4231 .int => {
4232 const int_bits = ty.intInfo(zcu).bits;4232 const int_bits = ty.intInfo(zcu).bits;
42334233
4234 // bytes are no-op4234 // bytes are no-op
...@@ -4308,7 +4308,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {...@@ -4308,7 +4308,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
4308 defer func.register_manager.unlockReg(dst_lock);4308 defer func.register_manager.unlockReg(dst_lock);
43094309
4310 switch (ty.zigTypeTag(zcu)) {4310 switch (ty.zigTypeTag(zcu)) {
4311 .Float => {4311 .float => {
4312 assert(dst_class == .float);4312 assert(dst_class == .float);
43134313
4314 switch (operand_bit_size) {4314 switch (operand_bit_size) {
...@@ -4334,7 +4334,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {...@@ -4334,7 +4334,7 @@ fn airUnaryMath(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
4334 else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}),4334 else => return func.fail("TODO: airUnaryMath Float {s}", .{@tagName(tag)}),
4335 }4335 }
4336 },4336 },
4337 .Int => {4337 .int => {
4338 assert(dst_class == .int);4338 assert(dst_class == .int);
43394339
4340 switch (tag) {4340 switch (tag) {
...@@ -4824,8 +4824,8 @@ fn genCall(...@@ -4824,8 +4824,8 @@ fn genCall(
4824 .air => |callee| fn_info: {4824 .air => |callee| fn_info: {
4825 const callee_ty = func.typeOf(callee);4825 const callee_ty = func.typeOf(callee);
4826 break :fn_info switch (callee_ty.zigTypeTag(zcu)) {4826 break :fn_info switch (callee_ty.zigTypeTag(zcu)) {
4827 .Fn => callee_ty,4827 .@"fn" => callee_ty,
4828 .Pointer => callee_ty.childType(zcu),4828 .pointer => callee_ty.childType(zcu),
4829 else => unreachable,4829 else => unreachable,
4830 };4830 };
4831 },4831 },
...@@ -4977,7 +4977,7 @@ fn genCall(...@@ -4977,7 +4977,7 @@ fn genCall(
4977 else => return func.fail("TODO implement calling bitcasted functions", .{}),4977 else => return func.fail("TODO implement calling bitcasted functions", .{}),
4978 }4978 }
4979 } else {4979 } else {
4980 assert(func.typeOf(callee).zigTypeTag(zcu) == .Pointer);4980 assert(func.typeOf(callee).zigTypeTag(zcu) == .pointer);
4981 const addr_reg, const addr_lock = try func.allocReg(.int);4981 const addr_reg, const addr_lock = try func.allocReg(.int);
4982 defer func.register_manager.unlockReg(addr_lock);4982 defer func.register_manager.unlockReg(addr_lock);
4983 try func.genSetReg(Type.u64, addr_reg, .{ .air_ref = callee });4983 try func.genSetReg(Type.u64, addr_reg, .{ .air_ref = callee });
...@@ -5105,20 +5105,20 @@ fn airCmp(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {...@@ -5105,20 +5105,20 @@ fn airCmp(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
5105 const lhs_ty = func.typeOf(bin_op.lhs);5105 const lhs_ty = func.typeOf(bin_op.lhs);
51065106
5107 switch (lhs_ty.zigTypeTag(zcu)) {5107 switch (lhs_ty.zigTypeTag(zcu)) {
5108 .Int,5108 .int,
5109 .Enum,5109 .@"enum",
5110 .Bool,5110 .bool,
5111 .Pointer,5111 .pointer,
5112 .ErrorSet,5112 .error_set,
5113 .Optional,5113 .optional,
5114 => {5114 => {
5115 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {5115 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {
5116 .Enum => lhs_ty.intTagType(zcu),5116 .@"enum" => lhs_ty.intTagType(zcu),
5117 .Int => lhs_ty,5117 .int => lhs_ty,
5118 .Bool => Type.u1,5118 .bool => Type.u1,
5119 .Pointer => Type.u64,5119 .pointer => Type.u64,
5120 .ErrorSet => Type.anyerror,5120 .error_set => Type.anyerror,
5121 .Optional => blk: {5121 .optional => blk: {
5122 const payload_ty = lhs_ty.optionalChild(zcu);5122 const payload_ty = lhs_ty.optionalChild(zcu);
5123 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {5123 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
5124 break :blk Type.u1;5124 break :blk Type.u1;
...@@ -5138,7 +5138,7 @@ fn airCmp(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {...@@ -5138,7 +5138,7 @@ fn airCmp(func: *Func, inst: Air.Inst.Index, tag: Air.Inst.Tag) !void {
5138 return func.fail("TODO riscv cmp for ints > 64 bits", .{});5138 return func.fail("TODO riscv cmp for ints > 64 bits", .{});
5139 }5139 }
5140 },5140 },
5141 .Float => {5141 .float => {
5142 const float_bits = lhs_ty.floatBits(func.target.*);5142 const float_bits = lhs_ty.floatBits(func.target.*);
5143 const float_reg_size: u32 = if (func.hasFeature(.d)) 64 else 32;5143 const float_reg_size: u32 = if (func.hasFeature(.d)) 64 else 32;
5144 if (float_bits > float_reg_size) {5144 if (float_bits > float_reg_size) {
...@@ -7456,8 +7456,8 @@ fn airAtomicRmw(func: *Func, inst: Air.Inst.Index) !void {...@@ -7456,8 +7456,8 @@ fn airAtomicRmw(func: *Func, inst: Air.Inst.Index) !void {
7456 return func.fail("TODO: airAtomicRmw non-pow 2", .{});7456 return func.fail("TODO: airAtomicRmw non-pow 2", .{});
74577457
7458 switch (val_ty.zigTypeTag(pt.zcu)) {7458 switch (val_ty.zigTypeTag(pt.zcu)) {
7459 .Enum, .Int => {},7459 .@"enum", .int => {},
7460 inline .Bool, .Float, .Pointer => |ty| return func.fail("TODO: airAtomicRmw {s}", .{@tagName(ty)}),7460 inline .bool, .float, .pointer => |ty| return func.fail("TODO: airAtomicRmw {s}", .{@tagName(ty)}),
7461 else => unreachable,7461 else => unreachable,
7462 }7462 }
74637463
...@@ -7861,7 +7861,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void {...@@ -7861,7 +7861,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void {
78617861
7862 const result: MCValue = result: {7862 const result: MCValue = result: {
7863 switch (result_ty.zigTypeTag(zcu)) {7863 switch (result_ty.zigTypeTag(zcu)) {
7864 .Struct => {7864 .@"struct" => {
7865 const frame_index = try func.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));7865 const frame_index = try func.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));
7866 if (result_ty.containerLayout(zcu) == .@"packed") {7866 if (result_ty.containerLayout(zcu) == .@"packed") {
7867 const struct_obj = zcu.typeToStruct(result_ty).?;7867 const struct_obj = zcu.typeToStruct(result_ty).?;
...@@ -7916,7 +7916,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void {...@@ -7916,7 +7916,7 @@ fn airAggregateInit(func: *Func, inst: Air.Inst.Index) !void {
7916 }7916 }
7917 break :result .{ .load_frame = .{ .index = frame_index } };7917 break :result .{ .load_frame = .{ .index = frame_index } };
7918 },7918 },
7919 .Array => {7919 .array => {
7920 const elem_ty = result_ty.childType(zcu);7920 const elem_ty = result_ty.childType(zcu);
7921 const frame_index = try func.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));7921 const frame_index = try func.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));
7922 const elem_size: u32 = @intCast(elem_ty.abiSize(zcu));7922 const elem_size: u32 = @intCast(elem_ty.abiSize(zcu));
...@@ -8099,7 +8099,7 @@ fn resolveCallingConventionValues(...@@ -8099,7 +8099,7 @@ fn resolveCallingConventionValues(
8099 result.stack_align = .@"16";8099 result.stack_align = .@"16";
81008100
8101 // Return values8101 // Return values
8102 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {8102 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
8103 result.return_value = InstTracking.init(.unreach);8103 result.return_value = InstTracking.init(.unreach);
8104 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {8104 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
8105 result.return_value = InstTracking.init(.none);8105 result.return_value = InstTracking.init(.none);
src/arch/riscv64/abi.zig+31-31
...@@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {...@@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {
1515
16 const max_byval_size = target.ptrBitWidth() * 2;16 const max_byval_size = target.ptrBitWidth() * 2;
17 switch (ty.zigTypeTag(zcu)) {17 switch (ty.zigTypeTag(zcu)) {
18 .Struct => {18 .@"struct" => {
19 const bit_size = ty.bitSize(zcu);19 const bit_size = ty.bitSize(zcu);
20 if (ty.containerLayout(zcu) == .@"packed") {20 if (ty.containerLayout(zcu) == .@"packed") {
21 if (bit_size > max_byval_size) return .memory;21 if (bit_size > max_byval_size) return .memory;
...@@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {...@@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {
44 if (bit_size > max_byval_size / 2) return .double_integer;44 if (bit_size > max_byval_size / 2) return .double_integer;
45 return .integer;45 return .integer;
46 },46 },
47 .Union => {47 .@"union" => {
48 const bit_size = ty.bitSize(zcu);48 const bit_size = ty.bitSize(zcu);
49 if (ty.containerLayout(zcu) == .@"packed") {49 if (ty.containerLayout(zcu) == .@"packed") {
50 if (bit_size > max_byval_size) return .memory;50 if (bit_size > max_byval_size) return .memory;
...@@ -55,40 +55,40 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {...@@ -55,40 +55,40 @@ pub fn classifyType(ty: Type, zcu: *Zcu) Class {
55 if (bit_size > max_byval_size / 2) return .double_integer;55 if (bit_size > max_byval_size / 2) return .double_integer;
56 return .integer;56 return .integer;
57 },57 },
58 .Bool => return .integer,58 .bool => return .integer,
59 .Float => return .byval,59 .float => return .byval,
60 .Int, .Enum, .ErrorSet => {60 .int, .@"enum", .error_set => {
61 const bit_size = ty.bitSize(zcu);61 const bit_size = ty.bitSize(zcu);
62 if (bit_size > max_byval_size) return .memory;62 if (bit_size > max_byval_size) return .memory;
63 return .byval;63 return .byval;
64 },64 },
65 .Vector => {65 .vector => {
66 const bit_size = ty.bitSize(zcu);66 const bit_size = ty.bitSize(zcu);
67 if (bit_size > max_byval_size) return .memory;67 if (bit_size > max_byval_size) return .memory;
68 return .integer;68 return .integer;
69 },69 },
70 .Optional => {70 .optional => {
71 std.debug.assert(ty.isPtrLikeOptional(zcu));71 std.debug.assert(ty.isPtrLikeOptional(zcu));
72 return .byval;72 return .byval;
73 },73 },
74 .Pointer => {74 .pointer => {
75 std.debug.assert(!ty.isSlice(zcu));75 std.debug.assert(!ty.isSlice(zcu));
76 return .byval;76 return .byval;
77 },77 },
78 .ErrorUnion,78 .error_union,
79 .Frame,79 .frame,
80 .AnyFrame,80 .@"anyframe",
81 .NoReturn,81 .noreturn,
82 .Void,82 .void,
83 .Type,83 .type,
84 .ComptimeFloat,84 .comptime_float,
85 .ComptimeInt,85 .comptime_int,
86 .Undefined,86 .undefined,
87 .Null,87 .null,
88 .Fn,88 .@"fn",
89 .Opaque,89 .@"opaque",
90 .EnumLiteral,90 .enum_literal,
91 .Array,91 .array,
92 => unreachable,92 => unreachable,
93 }93 }
94}94}
...@@ -104,11 +104,11 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -104,11 +104,11 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
104 .none, .none, .none, .none,104 .none, .none, .none, .none,
105 };105 };
106 switch (ty.zigTypeTag(zcu)) {106 switch (ty.zigTypeTag(zcu)) {
107 .Bool, .Void, .NoReturn => {107 .bool, .void, .noreturn => {
108 result[0] = .integer;108 result[0] = .integer;
109 return result;109 return result;
110 },110 },
111 .Pointer => switch (ty.ptrSize(zcu)) {111 .pointer => switch (ty.ptrSize(zcu)) {
112 .Slice => {112 .Slice => {
113 result[0] = .integer;113 result[0] = .integer;
114 result[1] = .integer;114 result[1] = .integer;
...@@ -119,14 +119,14 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -119,14 +119,14 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
119 return result;119 return result;
120 },120 },
121 },121 },
122 .Optional => {122 .optional => {
123 if (ty.isPtrLikeOptional(zcu)) {123 if (ty.isPtrLikeOptional(zcu)) {
124 result[0] = .integer;124 result[0] = .integer;
125 return result;125 return result;
126 }126 }
127 return memory_class;127 return memory_class;
128 },128 },
129 .Int, .Enum, .ErrorSet => {129 .int, .@"enum", .error_set => {
130 const int_bits = ty.intInfo(zcu).bits;130 const int_bits = ty.intInfo(zcu).bits;
131 if (int_bits <= 64) {131 if (int_bits <= 64) {
132 result[0] = .integer;132 result[0] = .integer;
...@@ -139,7 +139,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -139,7 +139,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
139 }139 }
140 unreachable; // support > 128 bit int arguments140 unreachable; // support > 128 bit int arguments
141 },141 },
142 .Float => {142 .float => {
143 const target = zcu.getTarget();143 const target = zcu.getTarget();
144 const features = target.cpu.features;144 const features = target.cpu.features;
145145
...@@ -151,7 +151,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -151,7 +151,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
151 }151 }
152 unreachable; // support split float args152 unreachable; // support split float args
153 },153 },
154 .ErrorUnion => {154 .error_union => {
155 const payload_ty = ty.errorUnionPayload(zcu);155 const payload_ty = ty.errorUnionPayload(zcu);
156 const payload_bits = payload_ty.bitSize(zcu);156 const payload_bits = payload_ty.bitSize(zcu);
157157
...@@ -163,7 +163,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -163,7 +163,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
163163
164 return memory_class;164 return memory_class;
165 },165 },
166 .Struct, .Union => {166 .@"struct", .@"union" => {
167 const layout = ty.containerLayout(zcu);167 const layout = ty.containerLayout(zcu);
168 const ty_size = ty.abiSize(zcu);168 const ty_size = ty.abiSize(zcu);
169169
...@@ -176,7 +176,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -176,7 +176,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
176176
177 return memory_class;177 return memory_class;
178 },178 },
179 .Array => {179 .array => {
180 const ty_size = ty.abiSize(zcu);180 const ty_size = ty.abiSize(zcu);
181 if (ty_size <= 8) {181 if (ty_size <= 8) {
182 result[0] = .integer;182 result[0] = .integer;
...@@ -189,7 +189,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {...@@ -189,7 +189,7 @@ pub fn classifySystem(ty: Type, zcu: *Zcu) [8]SystemClass {
189 }189 }
190 return memory_class;190 return memory_class;
191 },191 },
192 .Vector => {192 .vector => {
193 // we pass vectors through integer registers if they are small enough to fit.193 // we pass vectors through integer registers if they are small enough to fit.
194 const vec_bits = ty.totalVectorBits(zcu);194 const vec_bits = ty.totalVectorBits(zcu);
195 if (vec_bits <= 64) {195 if (vec_bits <= 64) {
src/arch/riscv64/bits.zig+3-3
...@@ -115,7 +115,7 @@ pub const Immediate = union(enum) {...@@ -115,7 +115,7 @@ pub const Immediate = union(enum) {
115 }115 }
116116
117 pub fn asBits(imm: Immediate, comptime T: type) T {117 pub fn asBits(imm: Immediate, comptime T: type) T {
118 const int_info = @typeInfo(T).Int;118 const int_info = @typeInfo(T).int;
119 if (int_info.signedness != .unsigned) @compileError("Immediate.asBits needs unsigned T");119 if (int_info.signedness != .unsigned) @compileError("Immediate.asBits needs unsigned T");
120 return switch (imm) {120 return switch (imm) {
121 .signed => |x| @bitCast(@as(std.meta.Int(.signed, int_info.bits), @intCast(x))),121 .signed => |x| @bitCast(@as(std.meta.Int(.signed, int_info.bits), @intCast(x))),
...@@ -189,7 +189,7 @@ pub const Register = enum(u8) {...@@ -189,7 +189,7 @@ pub const Register = enum(u8) {
189 /// The goal of this function is to return the same ID for `zero` and `x0` but two189 /// The goal of this function is to return the same ID for `zero` and `x0` but two
190 /// seperate IDs for `x0` and `f0`. We will assume that each register set has 32 registers190 /// seperate IDs for `x0` and `f0`. We will assume that each register set has 32 registers
191 /// and is repeated twice, once for the named version, once for the number version.191 /// and is repeated twice, once for the named version, once for the number version.
192 pub fn id(reg: Register) std.math.IntFittingRange(0, @typeInfo(Register).Enum.fields.len) {192 pub fn id(reg: Register) std.math.IntFittingRange(0, @typeInfo(Register).@"enum".fields.len) {
193 const base = switch (@intFromEnum(reg)) {193 const base = switch (@intFromEnum(reg)) {
194 // zig fmt: off194 // zig fmt: off
195 @intFromEnum(Register.zero) ... @intFromEnum(Register.x31) => @intFromEnum(Register.zero),195 @intFromEnum(Register.zero) ... @intFromEnum(Register.x31) => @intFromEnum(Register.zero),
...@@ -252,7 +252,7 @@ pub const FrameIndex = enum(u32) {...@@ -252,7 +252,7 @@ pub const FrameIndex = enum(u32) {
252 /// Other indices are used for local variable stack slots252 /// Other indices are used for local variable stack slots
253 _,253 _,
254254
255 pub const named_count = @typeInfo(FrameIndex).Enum.fields.len;255 pub const named_count = @typeInfo(FrameIndex).@"enum".fields.len;
256256
257 pub fn isNamed(fi: FrameIndex) bool {257 pub fn isNamed(fi: FrameIndex) bool {
258 return @intFromEnum(fi) < named_count;258 return @intFromEnum(fi) < named_count;
src/arch/sparc64/CodeGen.zig+39-39
...@@ -770,8 +770,8 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -770,8 +770,8 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
770 const rhs_ty = self.typeOf(extra.rhs);770 const rhs_ty = self.typeOf(extra.rhs);
771771
772 switch (lhs_ty.zigTypeTag(zcu)) {772 switch (lhs_ty.zigTypeTag(zcu)) {
773 .Vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}),773 .vector => return self.fail("TODO implement add_with_overflow/sub_with_overflow for vectors", .{}),
774 .Int => {774 .int => {
775 assert(lhs_ty.eql(rhs_ty, zcu));775 assert(lhs_ty.eql(rhs_ty, zcu));
776 const int_info = lhs_ty.intInfo(zcu);776 const int_info = lhs_ty.intInfo(zcu);
777 switch (int_info.bits) {777 switch (int_info.bits) {
...@@ -1231,8 +1231,8 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {...@@ -1231,8 +1231,8 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) !void {
1231 const operand = try self.resolveInst(ty_op.operand);1231 const operand = try self.resolveInst(ty_op.operand);
1232 const operand_ty = self.typeOf(ty_op.operand);1232 const operand_ty = self.typeOf(ty_op.operand);
1233 switch (operand_ty.zigTypeTag(zcu)) {1233 switch (operand_ty.zigTypeTag(zcu)) {
1234 .Vector => return self.fail("TODO byteswap for vectors", .{}),1234 .vector => return self.fail("TODO byteswap for vectors", .{}),
1235 .Int => {1235 .int => {
1236 const int_info = operand_ty.intInfo(zcu);1236 const int_info = operand_ty.intInfo(zcu);
1237 if (int_info.bits == 8) break :result operand;1237 if (int_info.bits == 8) break :result operand;
12381238
...@@ -1310,8 +1310,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -1310,8 +1310,8 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
1310 const zcu = pt.zcu;1310 const zcu = pt.zcu;
1311 const ip = &zcu.intern_pool;1311 const ip = &zcu.intern_pool;
1312 const fn_ty = switch (ty.zigTypeTag(zcu)) {1312 const fn_ty = switch (ty.zigTypeTag(zcu)) {
1313 .Fn => ty,1313 .@"fn" => ty,
1314 .Pointer => ty.childType(zcu),1314 .pointer => ty.childType(zcu),
1315 else => unreachable,1315 else => unreachable,
1316 };1316 };
13171317
...@@ -1363,7 +1363,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier...@@ -1363,7 +1363,7 @@ fn airCall(self: *Self, inst: Air.Inst.Index, modifier: std.builtin.CallModifier
1363 return self.fail("TODO implement calling bitcasted functions", .{});1363 return self.fail("TODO implement calling bitcasted functions", .{});
1364 },1364 },
1365 } else {1365 } else {
1366 assert(ty.zigTypeTag(zcu) == .Pointer);1366 assert(ty.zigTypeTag(zcu) == .pointer);
1367 const mcv = try self.resolveInst(callee);1367 const mcv = try self.resolveInst(callee);
1368 try self.genSetReg(ty, .o7, mcv);1368 try self.genSetReg(ty, .o7, mcv);
13691369
...@@ -1419,13 +1419,13 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -1419,13 +1419,13 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
1419 const lhs_ty = self.typeOf(bin_op.lhs);1419 const lhs_ty = self.typeOf(bin_op.lhs);
14201420
1421 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {1421 const int_ty = switch (lhs_ty.zigTypeTag(zcu)) {
1422 .Vector => unreachable, // Handled by cmp_vector.1422 .vector => unreachable, // Handled by cmp_vector.
1423 .Enum => lhs_ty.intTagType(zcu),1423 .@"enum" => lhs_ty.intTagType(zcu),
1424 .Int => lhs_ty,1424 .int => lhs_ty,
1425 .Bool => Type.u1,1425 .bool => Type.u1,
1426 .Pointer => Type.usize,1426 .pointer => Type.usize,
1427 .ErrorSet => Type.u16,1427 .error_set => Type.u16,
1428 .Optional => blk: {1428 .optional => blk: {
1429 const payload_ty = lhs_ty.optionalChild(zcu);1429 const payload_ty = lhs_ty.optionalChild(zcu);
1430 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {1430 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
1431 break :blk Type.u1;1431 break :blk Type.u1;
...@@ -1435,7 +1435,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -1435,7 +1435,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
1435 return self.fail("TODO SPARCv9 cmp non-pointer optionals", .{});1435 return self.fail("TODO SPARCv9 cmp non-pointer optionals", .{});
1436 }1436 }
1437 },1437 },
1438 .Float => return self.fail("TODO SPARCv9 cmp floats", .{}),1438 .float => return self.fail("TODO SPARCv9 cmp floats", .{}),
1439 else => unreachable,1439 else => unreachable,
1440 };1440 };
14411441
...@@ -2031,8 +2031,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2031,8 +2031,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2031 const rhs_ty = self.typeOf(extra.rhs);2031 const rhs_ty = self.typeOf(extra.rhs);
20322032
2033 switch (lhs_ty.zigTypeTag(zcu)) {2033 switch (lhs_ty.zigTypeTag(zcu)) {
2034 .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),2034 .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),
2035 .Int => {2035 .int => {
2036 assert(lhs_ty.eql(rhs_ty, zcu));2036 assert(lhs_ty.eql(rhs_ty, zcu));
2037 const int_info = lhs_ty.intInfo(zcu);2037 const int_info = lhs_ty.intInfo(zcu);
2038 switch (int_info.bits) {2038 switch (int_info.bits) {
...@@ -2105,7 +2105,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {...@@ -2105,7 +2105,7 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
2105 },2105 },
2106 else => {2106 else => {
2107 switch (operand_ty.zigTypeTag(zcu)) {2107 switch (operand_ty.zigTypeTag(zcu)) {
2108 .Bool => {2108 .bool => {
2109 const op_reg = switch (operand) {2109 const op_reg = switch (operand) {
2110 .register => |r| r,2110 .register => |r| r,
2111 else => try self.copyToTmpRegister(operand_ty, operand),2111 else => try self.copyToTmpRegister(operand_ty, operand),
...@@ -2136,8 +2136,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {...@@ -2136,8 +2136,8 @@ fn airNot(self: *Self, inst: Air.Inst.Index) !void {
21362136
2137 break :result MCValue{ .register = dest_reg };2137 break :result MCValue{ .register = dest_reg };
2138 },2138 },
2139 .Vector => return self.fail("TODO bitwise not for vectors", .{}),2139 .vector => return self.fail("TODO bitwise not for vectors", .{}),
2140 .Int => {2140 .int => {
2141 const int_info = operand_ty.intInfo(zcu);2141 const int_info = operand_ty.intInfo(zcu);
2142 if (int_info.bits <= 64) {2142 if (int_info.bits <= 64) {
2143 const op_reg = switch (operand) {2143 const op_reg = switch (operand) {
...@@ -2329,8 +2329,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -2329,8 +2329,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
2329 const rhs_ty = self.typeOf(extra.rhs);2329 const rhs_ty = self.typeOf(extra.rhs);
23302330
2331 switch (lhs_ty.zigTypeTag(zcu)) {2331 switch (lhs_ty.zigTypeTag(zcu)) {
2332 .Vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),2332 .vector => return self.fail("TODO implement mul_with_overflow for vectors", .{}),
2333 .Int => {2333 .int => {
2334 const int_info = lhs_ty.intInfo(zcu);2334 const int_info = lhs_ty.intInfo(zcu);
2335 if (int_info.bits <= 64) {2335 if (int_info.bits <= 64) {
2336 try self.spillConditionFlagsIfOccupied();2336 try self.spillConditionFlagsIfOccupied();
...@@ -2858,9 +2858,9 @@ fn binOp(...@@ -2858,9 +2858,9 @@ fn binOp(
2858 .cmp_eq,2858 .cmp_eq,
2859 => {2859 => {
2860 switch (lhs_ty.zigTypeTag(zcu)) {2860 switch (lhs_ty.zigTypeTag(zcu)) {
2861 .Float => return self.fail("TODO binary operations on floats", .{}),2861 .float => return self.fail("TODO binary operations on floats", .{}),
2862 .Vector => return self.fail("TODO binary operations on vectors", .{}),2862 .vector => return self.fail("TODO binary operations on vectors", .{}),
2863 .Int => {2863 .int => {
2864 assert(lhs_ty.eql(rhs_ty, zcu));2864 assert(lhs_ty.eql(rhs_ty, zcu));
2865 const int_info = lhs_ty.intInfo(zcu);2865 const int_info = lhs_ty.intInfo(zcu);
2866 if (int_info.bits <= 64) {2866 if (int_info.bits <= 64) {
...@@ -2932,8 +2932,8 @@ fn binOp(...@@ -2932,8 +2932,8 @@ fn binOp(
29322932
2933 // Truncate if necessary2933 // Truncate if necessary
2934 switch (lhs_ty.zigTypeTag(zcu)) {2934 switch (lhs_ty.zigTypeTag(zcu)) {
2935 .Vector => return self.fail("TODO binary operations on vectors", .{}),2935 .vector => return self.fail("TODO binary operations on vectors", .{}),
2936 .Int => {2936 .int => {
2937 const int_info = lhs_ty.intInfo(zcu);2937 const int_info = lhs_ty.intInfo(zcu);
2938 if (int_info.bits <= 64) {2938 if (int_info.bits <= 64) {
2939 const result_reg = result.register;2939 const result_reg = result.register;
...@@ -2949,8 +2949,8 @@ fn binOp(...@@ -2949,8 +2949,8 @@ fn binOp(
29492949
2950 .div_trunc => {2950 .div_trunc => {
2951 switch (lhs_ty.zigTypeTag(zcu)) {2951 switch (lhs_ty.zigTypeTag(zcu)) {
2952 .Vector => return self.fail("TODO binary operations on vectors", .{}),2952 .vector => return self.fail("TODO binary operations on vectors", .{}),
2953 .Int => {2953 .int => {
2954 assert(lhs_ty.eql(rhs_ty, zcu));2954 assert(lhs_ty.eql(rhs_ty, zcu));
2955 const int_info = lhs_ty.intInfo(zcu);2955 const int_info = lhs_ty.intInfo(zcu);
2956 if (int_info.bits <= 64) {2956 if (int_info.bits <= 64) {
...@@ -2982,7 +2982,7 @@ fn binOp(...@@ -2982,7 +2982,7 @@ fn binOp(
29822982
2983 .ptr_add => {2983 .ptr_add => {
2984 switch (lhs_ty.zigTypeTag(zcu)) {2984 switch (lhs_ty.zigTypeTag(zcu)) {
2985 .Pointer => {2985 .pointer => {
2986 const ptr_ty = lhs_ty;2986 const ptr_ty = lhs_ty;
2987 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {2987 const elem_ty = switch (ptr_ty.ptrSize(zcu)) {
2988 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type2988 .One => ptr_ty.childType(zcu).childType(zcu), // ptr to array, so get array element type
...@@ -3014,7 +3014,7 @@ fn binOp(...@@ -3014,7 +3014,7 @@ fn binOp(
3014 .bool_or,3014 .bool_or,
3015 => {3015 => {
3016 switch (lhs_ty.zigTypeTag(zcu)) {3016 switch (lhs_ty.zigTypeTag(zcu)) {
3017 .Bool => {3017 .bool => {
3018 assert(lhs != .immediate); // should have been handled by Sema3018 assert(lhs != .immediate); // should have been handled by Sema
3019 assert(rhs != .immediate); // should have been handled by Sema3019 assert(rhs != .immediate); // should have been handled by Sema
30203020
...@@ -3044,8 +3044,8 @@ fn binOp(...@@ -3044,8 +3044,8 @@ fn binOp(
30443044
3045 // Truncate if necessary3045 // Truncate if necessary
3046 switch (lhs_ty.zigTypeTag(zcu)) {3046 switch (lhs_ty.zigTypeTag(zcu)) {
3047 .Vector => return self.fail("TODO binary operations on vectors", .{}),3047 .vector => return self.fail("TODO binary operations on vectors", .{}),
3048 .Int => {3048 .int => {
3049 const int_info = lhs_ty.intInfo(zcu);3049 const int_info = lhs_ty.intInfo(zcu);
3050 if (int_info.bits <= 64) {3050 if (int_info.bits <= 64) {
3051 // 32 and 64 bit operands doesn't need truncating3051 // 32 and 64 bit operands doesn't need truncating
...@@ -3066,8 +3066,8 @@ fn binOp(...@@ -3066,8 +3066,8 @@ fn binOp(
3066 .shr_exact,3066 .shr_exact,
3067 => {3067 => {
3068 switch (lhs_ty.zigTypeTag(zcu)) {3068 switch (lhs_ty.zigTypeTag(zcu)) {
3069 .Vector => return self.fail("TODO binary operations on vectors", .{}),3069 .vector => return self.fail("TODO binary operations on vectors", .{}),
3070 .Int => {3070 .int => {
3071 const int_info = lhs_ty.intInfo(zcu);3071 const int_info = lhs_ty.intInfo(zcu);
3072 if (int_info.bits <= 64) {3072 if (int_info.bits <= 64) {
3073 const rhs_immediate_ok = rhs == .immediate;3073 const rhs_immediate_ok = rhs == .immediate;
...@@ -4329,9 +4329,9 @@ fn minMax(...@@ -4329,9 +4329,9 @@ fn minMax(
4329 const zcu = pt.zcu;4329 const zcu = pt.zcu;
4330 assert(lhs_ty.eql(rhs_ty, zcu));4330 assert(lhs_ty.eql(rhs_ty, zcu));
4331 switch (lhs_ty.zigTypeTag(zcu)) {4331 switch (lhs_ty.zigTypeTag(zcu)) {
4332 .Float => return self.fail("TODO min/max on floats", .{}),4332 .float => return self.fail("TODO min/max on floats", .{}),
4333 .Vector => return self.fail("TODO min/max on vectors", .{}),4333 .vector => return self.fail("TODO min/max on vectors", .{}),
4334 .Int => {4334 .int => {
4335 const int_info = lhs_ty.intInfo(zcu);4335 const int_info = lhs_ty.intInfo(zcu);
4336 if (int_info.bits <= 64) {4336 if (int_info.bits <= 64) {
4337 // TODO skip register setting when one of the operands4337 // TODO skip register setting when one of the operands
...@@ -4515,7 +4515,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)...@@ -4515,7 +4515,7 @@ fn resolveCallingConventionValues(self: *Self, fn_ty: Type, role: RegisterView)
4515 result.stack_byte_count = next_stack_offset;4515 result.stack_byte_count = next_stack_offset;
4516 result.stack_align = .@"16";4516 result.stack_align = .@"16";
45174517
4518 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {4518 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
4519 result.return_value = .{ .unreach = {} };4519 result.return_value = .{ .unreach = {} };
4520 } else if (!ret_ty.hasRuntimeBits(zcu)) {4520 } else if (!ret_ty.hasRuntimeBits(zcu)) {
4521 result.return_value = .{ .none = {} };4521 result.return_value = .{ .none = {} };
src/arch/wasm/CodeGen.zig+92-92
...@@ -1004,19 +1004,19 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread, target: std.Target) wasm.Valtype {...@@ -1004,19 +1004,19 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread, target: std.Target) wasm.Valtype {
1004 const zcu = pt.zcu;1004 const zcu = pt.zcu;
1005 const ip = &zcu.intern_pool;1005 const ip = &zcu.intern_pool;
1006 return switch (ty.zigTypeTag(zcu)) {1006 return switch (ty.zigTypeTag(zcu)) {
1007 .Float => switch (ty.floatBits(target)) {1007 .float => switch (ty.floatBits(target)) {
1008 16 => .i32, // stored/loaded as u161008 16 => .i32, // stored/loaded as u16
1009 32 => .f32,1009 32 => .f32,
1010 64 => .f64,1010 64 => .f64,
1011 80, 128 => .i32,1011 80, 128 => .i32,
1012 else => unreachable,1012 else => unreachable,
1013 },1013 },
1014 .Int, .Enum => switch (ty.intInfo(zcu).bits) {1014 .int, .@"enum" => switch (ty.intInfo(zcu).bits) {
1015 0...32 => .i32,1015 0...32 => .i32,
1016 33...64 => .i64,1016 33...64 => .i64,
1017 else => .i32,1017 else => .i32,
1018 },1018 },
1019 .Struct => blk: {1019 .@"struct" => blk: {
1020 if (zcu.typeToPackedStruct(ty)) |packed_struct| {1020 if (zcu.typeToPackedStruct(ty)) |packed_struct| {
1021 const backing_int_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip));1021 const backing_int_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip));
1022 break :blk typeToValtype(backing_int_ty, pt, target);1022 break :blk typeToValtype(backing_int_ty, pt, target);
...@@ -1024,11 +1024,11 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread, target: std.Target) wasm.Valtype {...@@ -1024,11 +1024,11 @@ fn typeToValtype(ty: Type, pt: Zcu.PerThread, target: std.Target) wasm.Valtype {
1024 break :blk .i32;1024 break :blk .i32;
1025 }1025 }
1026 },1026 },
1027 .Vector => switch (determineSimdStoreStrategy(ty, zcu, target)) {1027 .vector => switch (determineSimdStoreStrategy(ty, zcu, target)) {
1028 .direct => .v128,1028 .direct => .v128,
1029 .unrolled => .i32,1029 .unrolled => .i32,
1030 },1030 },
1031 .Union => switch (ty.containerLayout(zcu)) {1031 .@"union" => switch (ty.containerLayout(zcu)) {
1032 .@"packed" => blk: {1032 .@"packed" => blk: {
1033 const int_ty = pt.intType(.unsigned, @as(u16, @intCast(ty.bitSize(zcu)))) catch @panic("out of memory");1033 const int_ty = pt.intType(.unsigned, @as(u16, @intCast(ty.bitSize(zcu)))) catch @panic("out of memory");
1034 break :blk typeToValtype(int_ty, pt, target);1034 break :blk typeToValtype(int_ty, pt, target);
...@@ -1430,7 +1430,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value:...@@ -1430,7 +1430,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value:
1430 const ty_classes = abi.classifyType(ty, zcu);1430 const ty_classes = abi.classifyType(ty, zcu);
1431 assert(ty_classes[0] != .none);1431 assert(ty_classes[0] != .none);
1432 switch (ty.zigTypeTag(zcu)) {1432 switch (ty.zigTypeTag(zcu)) {
1433 .Struct, .Union => {1433 .@"struct", .@"union" => {
1434 if (ty_classes[0] == .indirect) {1434 if (ty_classes[0] == .indirect) {
1435 return func.lowerToStack(value);1435 return func.lowerToStack(value);
1436 }1436 }
...@@ -1445,7 +1445,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value:...@@ -1445,7 +1445,7 @@ fn lowerArg(func: *CodeGen, cc: std.builtin.CallingConvention, ty: Type, value:
1445 else => try func.emitWValue(value),1445 else => try func.emitWValue(value),
1446 }1446 }
1447 },1447 },
1448 .Int, .Float => {1448 .int, .float => {
1449 if (ty_classes[1] == .none) {1449 if (ty_classes[1] == .none) {
1450 return func.lowerToStack(value);1450 return func.lowerToStack(value);
1451 }1451 }
...@@ -1719,27 +1719,27 @@ fn isByRef(ty: Type, pt: Zcu.PerThread, target: std.Target) bool {...@@ -1719,27 +1719,27 @@ fn isByRef(ty: Type, pt: Zcu.PerThread, target: std.Target) bool {
1719 const zcu = pt.zcu;1719 const zcu = pt.zcu;
1720 const ip = &zcu.intern_pool;1720 const ip = &zcu.intern_pool;
1721 switch (ty.zigTypeTag(zcu)) {1721 switch (ty.zigTypeTag(zcu)) {
1722 .Type,1722 .type,
1723 .ComptimeInt,1723 .comptime_int,
1724 .ComptimeFloat,1724 .comptime_float,
1725 .EnumLiteral,1725 .enum_literal,
1726 .Undefined,1726 .undefined,
1727 .Null,1727 .null,
1728 .Opaque,1728 .@"opaque",
1729 => unreachable,1729 => unreachable,
17301730
1731 .NoReturn,1731 .noreturn,
1732 .Void,1732 .void,
1733 .Bool,1733 .bool,
1734 .ErrorSet,1734 .error_set,
1735 .Fn,1735 .@"fn",
1736 .AnyFrame,1736 .@"anyframe",
1737 => return false,1737 => return false,
17381738
1739 .Array,1739 .array,
1740 .Frame,1740 .frame,
1741 => return ty.hasRuntimeBitsIgnoreComptime(zcu),1741 => return ty.hasRuntimeBitsIgnoreComptime(zcu),
1742 .Union => {1742 .@"union" => {
1743 if (zcu.typeToUnion(ty)) |union_obj| {1743 if (zcu.typeToUnion(ty)) |union_obj| {
1744 if (union_obj.flagsUnordered(ip).layout == .@"packed") {1744 if (union_obj.flagsUnordered(ip).layout == .@"packed") {
1745 return ty.abiSize(zcu) > 8;1745 return ty.abiSize(zcu) > 8;
...@@ -1747,30 +1747,30 @@ fn isByRef(ty: Type, pt: Zcu.PerThread, target: std.Target) bool {...@@ -1747,30 +1747,30 @@ fn isByRef(ty: Type, pt: Zcu.PerThread, target: std.Target) bool {
1747 }1747 }
1748 return ty.hasRuntimeBitsIgnoreComptime(zcu);1748 return ty.hasRuntimeBitsIgnoreComptime(zcu);
1749 },1749 },
1750 .Struct => {1750 .@"struct" => {
1751 if (zcu.typeToPackedStruct(ty)) |packed_struct| {1751 if (zcu.typeToPackedStruct(ty)) |packed_struct| {
1752 return isByRef(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), pt, target);1752 return isByRef(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), pt, target);
1753 }1753 }
1754 return ty.hasRuntimeBitsIgnoreComptime(zcu);1754 return ty.hasRuntimeBitsIgnoreComptime(zcu);
1755 },1755 },
1756 .Vector => return determineSimdStoreStrategy(ty, zcu, target) == .unrolled,1756 .vector => return determineSimdStoreStrategy(ty, zcu, target) == .unrolled,
1757 .Int => return ty.intInfo(zcu).bits > 64,1757 .int => return ty.intInfo(zcu).bits > 64,
1758 .Enum => return ty.intInfo(zcu).bits > 64,1758 .@"enum" => return ty.intInfo(zcu).bits > 64,
1759 .Float => return ty.floatBits(target) > 64,1759 .float => return ty.floatBits(target) > 64,
1760 .ErrorUnion => {1760 .error_union => {
1761 const pl_ty = ty.errorUnionPayload(zcu);1761 const pl_ty = ty.errorUnionPayload(zcu);
1762 if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) {1762 if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
1763 return false;1763 return false;
1764 }1764 }
1765 return true;1765 return true;
1766 },1766 },
1767 .Optional => {1767 .optional => {
1768 if (ty.isPtrLikeOptional(zcu)) return false;1768 if (ty.isPtrLikeOptional(zcu)) return false;
1769 const pl_type = ty.optionalChild(zcu);1769 const pl_type = ty.optionalChild(zcu);
1770 if (pl_type.zigTypeTag(zcu) == .ErrorSet) return false;1770 if (pl_type.zigTypeTag(zcu) == .error_set) return false;
1771 return pl_type.hasRuntimeBitsIgnoreComptime(zcu);1771 return pl_type.hasRuntimeBitsIgnoreComptime(zcu);
1772 },1772 },
1773 .Pointer => {1773 .pointer => {
1774 // Slices act like struct and will be passed by reference1774 // Slices act like struct and will be passed by reference
1775 if (ty.isSlice(zcu)) return true;1775 if (ty.isSlice(zcu)) return true;
1776 return false;1776 return false;
...@@ -1788,7 +1788,7 @@ const SimdStoreStrategy = enum {...@@ -1788,7 +1788,7 @@ const SimdStoreStrategy = enum {
1788/// features are enabled, the function will return `.direct`. This would allow to store1788/// features are enabled, the function will return `.direct`. This would allow to store
1789/// it using a instruction, rather than an unrolled version.1789/// it using a instruction, rather than an unrolled version.
1790fn determineSimdStoreStrategy(ty: Type, zcu: *Zcu, target: std.Target) SimdStoreStrategy {1790fn determineSimdStoreStrategy(ty: Type, zcu: *Zcu, target: std.Target) SimdStoreStrategy {
1791 std.debug.assert(ty.zigTypeTag(zcu) == .Vector);1791 std.debug.assert(ty.zigTypeTag(zcu) == .vector);
1792 if (ty.bitSize(zcu) != 128) return .unrolled;1792 if (ty.bitSize(zcu) != 128) return .unrolled;
1793 const hasFeature = std.Target.wasm.featureSetHas;1793 const hasFeature = std.Target.wasm.featureSetHas;
1794 const features = target.cpu.features;1794 const features = target.cpu.features;
...@@ -2106,7 +2106,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2106,7 +2106,7 @@ fn airRet(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2106 } else if (fn_info.cc == .C and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {2106 } else if (fn_info.cc == .C and ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
2107 switch (ret_ty.zigTypeTag(zcu)) {2107 switch (ret_ty.zigTypeTag(zcu)) {
2108 // Aggregate types can be lowered as a singular value2108 // Aggregate types can be lowered as a singular value
2109 .Struct, .Union => {2109 .@"struct", .@"union" => {
2110 const scalar_type = abi.scalarType(ret_ty, zcu);2110 const scalar_type = abi.scalarType(ret_ty, zcu);
2111 try func.emitWValue(operand);2111 try func.emitWValue(operand);
2112 const opcode = buildOpcode(.{2112 const opcode = buildOpcode(.{
...@@ -2189,8 +2189,8 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif...@@ -2189,8 +2189,8 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
2189 const zcu = pt.zcu;2189 const zcu = pt.zcu;
2190 const ip = &zcu.intern_pool;2190 const ip = &zcu.intern_pool;
2191 const fn_ty = switch (ty.zigTypeTag(zcu)) {2191 const fn_ty = switch (ty.zigTypeTag(zcu)) {
2192 .Fn => ty,2192 .@"fn" => ty,
2193 .Pointer => ty.childType(zcu),2193 .pointer => ty.childType(zcu),
2194 else => unreachable,2194 else => unreachable,
2195 };2195 };
2196 const ret_ty = fn_ty.fnReturnType(zcu);2196 const ret_ty = fn_ty.fnReturnType(zcu);
...@@ -2261,7 +2261,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif...@@ -2261,7 +2261,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
2261 } else {2261 } else {
2262 // in this case we call a function pointer2262 // in this case we call a function pointer
2263 // so load its value onto the stack2263 // so load its value onto the stack
2264 std.debug.assert(ty.zigTypeTag(zcu) == .Pointer);2264 std.debug.assert(ty.zigTypeTag(zcu) == .pointer);
2265 const operand = try func.resolveInst(pl_op.operand);2265 const operand = try func.resolveInst(pl_op.operand);
2266 try func.emitWValue(operand);2266 try func.emitWValue(operand);
22672267
...@@ -2281,7 +2281,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif...@@ -2281,7 +2281,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif
2281 } else if (first_param_sret) {2281 } else if (first_param_sret) {
2282 break :result_value sret;2282 break :result_value sret;
2283 // TODO: Make this less fragile and optimize2283 // TODO: Make this less fragile and optimize
2284 } else if (zcu.typeToFunc(fn_ty).?.cc == .C and ret_ty.zigTypeTag(zcu) == .Struct or ret_ty.zigTypeTag(zcu) == .Union) {2284 } else if (zcu.typeToFunc(fn_ty).?.cc == .C and ret_ty.zigTypeTag(zcu) == .@"struct" or ret_ty.zigTypeTag(zcu) == .@"union") {
2285 const result_local = try func.allocLocal(ret_ty);2285 const result_local = try func.allocLocal(ret_ty);
2286 try func.addLabel(.local_set, result_local.local.value);2286 try func.addLabel(.local_set, result_local.local.value);
2287 const scalar_type = abi.scalarType(ret_ty, zcu);2287 const scalar_type = abi.scalarType(ret_ty, zcu);
...@@ -2371,7 +2371,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2371,7 +2371,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2371 const zcu = pt.zcu;2371 const zcu = pt.zcu;
2372 const abi_size = ty.abiSize(zcu);2372 const abi_size = ty.abiSize(zcu);
2373 switch (ty.zigTypeTag(zcu)) {2373 switch (ty.zigTypeTag(zcu)) {
2374 .ErrorUnion => {2374 .error_union => {
2375 const pl_ty = ty.errorUnionPayload(zcu);2375 const pl_ty = ty.errorUnionPayload(zcu);
2376 if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) {2376 if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
2377 return func.store(lhs, rhs, Type.anyerror, 0);2377 return func.store(lhs, rhs, Type.anyerror, 0);
...@@ -2380,7 +2380,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2380,7 +2380,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2380 const len = @as(u32, @intCast(abi_size));2380 const len = @as(u32, @intCast(abi_size));
2381 return func.memcpy(lhs, rhs, .{ .imm32 = len });2381 return func.memcpy(lhs, rhs, .{ .imm32 = len });
2382 },2382 },
2383 .Optional => {2383 .optional => {
2384 if (ty.isPtrLikeOptional(zcu)) {2384 if (ty.isPtrLikeOptional(zcu)) {
2385 return func.store(lhs, rhs, Type.usize, 0);2385 return func.store(lhs, rhs, Type.usize, 0);
2386 }2386 }
...@@ -2388,18 +2388,18 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2388,18 +2388,18 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2388 if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) {2388 if (!pl_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
2389 return func.store(lhs, rhs, Type.u8, 0);2389 return func.store(lhs, rhs, Type.u8, 0);
2390 }2390 }
2391 if (pl_ty.zigTypeTag(zcu) == .ErrorSet) {2391 if (pl_ty.zigTypeTag(zcu) == .error_set) {
2392 return func.store(lhs, rhs, Type.anyerror, 0);2392 return func.store(lhs, rhs, Type.anyerror, 0);
2393 }2393 }
23942394
2395 const len = @as(u32, @intCast(abi_size));2395 const len = @as(u32, @intCast(abi_size));
2396 return func.memcpy(lhs, rhs, .{ .imm32 = len });2396 return func.memcpy(lhs, rhs, .{ .imm32 = len });
2397 },2397 },
2398 .Struct, .Array, .Union => if (isByRef(ty, pt, func.target.*)) {2398 .@"struct", .array, .@"union" => if (isByRef(ty, pt, func.target.*)) {
2399 const len = @as(u32, @intCast(abi_size));2399 const len = @as(u32, @intCast(abi_size));
2400 return func.memcpy(lhs, rhs, .{ .imm32 = len });2400 return func.memcpy(lhs, rhs, .{ .imm32 = len });
2401 },2401 },
2402 .Vector => switch (determineSimdStoreStrategy(ty, zcu, func.target.*)) {2402 .vector => switch (determineSimdStoreStrategy(ty, zcu, func.target.*)) {
2403 .unrolled => {2403 .unrolled => {
2404 const len: u32 = @intCast(abi_size);2404 const len: u32 = @intCast(abi_size);
2405 return func.memcpy(lhs, rhs, .{ .imm32 = len });2405 return func.memcpy(lhs, rhs, .{ .imm32 = len });
...@@ -2418,7 +2418,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2418,7 +2418,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2418 return func.addInst(.{ .tag = .simd_prefix, .data = .{ .payload = extra_index } });2418 return func.addInst(.{ .tag = .simd_prefix, .data = .{ .payload = extra_index } });
2419 },2419 },
2420 },2420 },
2421 .Pointer => {2421 .pointer => {
2422 if (ty.isSlice(zcu)) {2422 if (ty.isSlice(zcu)) {
2423 // store pointer first2423 // store pointer first
2424 // lower it to the stack so we do not have to store rhs into a local first2424 // lower it to the stack so we do not have to store rhs into a local first
...@@ -2433,7 +2433,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE...@@ -2433,7 +2433,7 @@ fn store(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, offset: u32) InnerE
2433 return;2433 return;
2434 }2434 }
2435 },2435 },
2436 .Int, .Enum, .Float => if (abi_size > 8 and abi_size <= 16) {2436 .int, .@"enum", .float => if (abi_size > 8 and abi_size <= 16) {
2437 try func.emitWValue(lhs);2437 try func.emitWValue(lhs);
2438 const lsb = try func.load(rhs, Type.u64, 0);2438 const lsb = try func.load(rhs, Type.u64, 0);
2439 try func.store(.stack, lsb, Type.u64, 0 + lhs.offset());2439 try func.store(.stack, lsb, Type.u64, 0 + lhs.offset());
...@@ -2521,7 +2521,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu...@@ -2521,7 +2521,7 @@ fn load(func: *CodeGen, operand: WValue, ty: Type, offset: u32) InnerError!WValu
2521 // load local's value from memory by its stack position2521 // load local's value from memory by its stack position
2522 try func.emitWValue(operand);2522 try func.emitWValue(operand);
25232523
2524 if (ty.zigTypeTag(zcu) == .Vector) {2524 if (ty.zigTypeTag(zcu) == .vector) {
2525 // TODO: Add helper functions for simd opcodes2525 // TODO: Add helper functions for simd opcodes
2526 const extra_index = @as(u32, @intCast(func.mir_extra.items.len));2526 const extra_index = @as(u32, @intCast(func.mir_extra.items.len));
2527 // stores as := opcode, offset, alignment (opcode::memarg)2527 // stores as := opcode, offset, alignment (opcode::memarg)
...@@ -2571,7 +2571,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2571,7 +2571,7 @@ fn airArg(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2571 // When we have an argument that's passed using more than a single parameter,2571 // When we have an argument that's passed using more than a single parameter,
2572 // we combine them into a single stack value2572 // we combine them into a single stack value
2573 if (arg_classes[0] == .direct and arg_classes[1] == .direct) {2573 if (arg_classes[0] == .direct and arg_classes[1] == .direct) {
2574 if (arg_ty.zigTypeTag(zcu) != .Int and arg_ty.zigTypeTag(zcu) != .Float) {2574 if (arg_ty.zigTypeTag(zcu) != .int and arg_ty.zigTypeTag(zcu) != .float) {
2575 return func.fail(2575 return func.fail(
2576 "TODO: Implement C-ABI argument for type '{}'",2576 "TODO: Implement C-ABI argument for type '{}'",
2577 .{arg_ty.fmt(pt)},2577 .{arg_ty.fmt(pt)},
...@@ -2647,7 +2647,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!...@@ -2647,7 +2647,7 @@ fn binOp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) InnerError!
2647 }2647 }
26482648
2649 if (isByRef(ty, pt, func.target.*)) {2649 if (isByRef(ty, pt, func.target.*)) {
2650 if (ty.zigTypeTag(zcu) == .Int) {2650 if (ty.zigTypeTag(zcu) == .int) {
2651 return func.binOpBigInt(lhs, rhs, ty, op);2651 return func.binOpBigInt(lhs, rhs, ty, op);
2652 } else {2652 } else {
2653 return func.fail(2653 return func.fail(
...@@ -2822,7 +2822,7 @@ fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2822,7 +2822,7 @@ fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2822 const scalar_ty = ty.scalarType(zcu);2822 const scalar_ty = ty.scalarType(zcu);
28232823
2824 switch (scalar_ty.zigTypeTag(zcu)) {2824 switch (scalar_ty.zigTypeTag(zcu)) {
2825 .Int => if (ty.zigTypeTag(zcu) == .Vector) {2825 .int => if (ty.zigTypeTag(zcu) == .vector) {
2826 return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});2826 return func.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});
2827 } else {2827 } else {
2828 const int_bits = ty.intInfo(zcu).bits;2828 const int_bits = ty.intInfo(zcu).bits;
...@@ -2887,7 +2887,7 @@ fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -2887,7 +2887,7 @@ fn airAbs(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
2887 else => unreachable,2887 else => unreachable,
2888 }2888 }
2889 },2889 },
2890 .Float => {2890 .float => {
2891 const result = try func.floatOp(.fabs, ty, &.{operand});2891 const result = try func.floatOp(.fabs, ty, &.{operand});
2892 return func.finishAir(inst, result, &.{ty_op.operand});2892 return func.finishAir(inst, result, &.{ty_op.operand});
2893 },2893 },
...@@ -2907,7 +2907,7 @@ fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError...@@ -2907,7 +2907,7 @@ fn airUnaryFloatOp(func: *CodeGen, inst: Air.Inst.Index, op: FloatOp) InnerError
2907fn floatOp(func: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue {2907fn floatOp(func: *CodeGen, float_op: FloatOp, ty: Type, args: []const WValue) InnerError!WValue {
2908 const pt = func.pt;2908 const pt = func.pt;
2909 const zcu = pt.zcu;2909 const zcu = pt.zcu;
2910 if (ty.zigTypeTag(zcu) == .Vector) {2910 if (ty.zigTypeTag(zcu) == .vector) {
2911 return func.fail("TODO: Implement floatOps for vectors", .{});2911 return func.fail("TODO: Implement floatOps for vectors", .{});
2912 }2912 }
29132913
...@@ -3021,7 +3021,7 @@ fn airWrapBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -3021,7 +3021,7 @@ fn airWrapBinOp(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
3021 const lhs_ty = func.typeOf(bin_op.lhs);3021 const lhs_ty = func.typeOf(bin_op.lhs);
3022 const rhs_ty = func.typeOf(bin_op.rhs);3022 const rhs_ty = func.typeOf(bin_op.rhs);
30233023
3024 if (lhs_ty.zigTypeTag(zcu) == .Vector or rhs_ty.zigTypeTag(zcu) == .Vector) {3024 if (lhs_ty.zigTypeTag(zcu) == .vector or rhs_ty.zigTypeTag(zcu) == .vector) {
3025 return func.fail("TODO: Implement wrapping arithmetic for vectors", .{});3025 return func.fail("TODO: Implement wrapping arithmetic for vectors", .{});
3026 }3026 }
30273027
...@@ -3139,7 +3139,7 @@ fn lowerPtr(func: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerEr...@@ -3139,7 +3139,7 @@ fn lowerPtr(func: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerEr
3139 const base_ptr = Value.fromInterned(field.base);3139 const base_ptr = Value.fromInterned(field.base);
3140 const base_ty = base_ptr.typeOf(zcu).childType(zcu);3140 const base_ty = base_ptr.typeOf(zcu).childType(zcu);
3141 const field_off: u64 = switch (base_ty.zigTypeTag(zcu)) {3141 const field_off: u64 = switch (base_ty.zigTypeTag(zcu)) {
3142 .Pointer => off: {3142 .pointer => off: {
3143 assert(base_ty.isSlice(zcu));3143 assert(base_ty.isSlice(zcu));
3144 break :off switch (field.index) {3144 break :off switch (field.index) {
3145 Value.slice_ptr_index => 0,3145 Value.slice_ptr_index => 0,
...@@ -3147,11 +3147,11 @@ fn lowerPtr(func: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerEr...@@ -3147,11 +3147,11 @@ fn lowerPtr(func: *CodeGen, ptr_val: InternPool.Index, prev_offset: u64) InnerEr
3147 else => unreachable,3147 else => unreachable,
3148 };3148 };
3149 },3149 },
3150 .Struct => switch (base_ty.containerLayout(zcu)) {3150 .@"struct" => switch (base_ty.containerLayout(zcu)) {
3151 .auto => base_ty.structFieldOffset(@intCast(field.index), zcu),3151 .auto => base_ty.structFieldOffset(@intCast(field.index), zcu),
3152 .@"extern", .@"packed" => unreachable,3152 .@"extern", .@"packed" => unreachable,
3153 },3153 },
3154 .Union => switch (base_ty.containerLayout(zcu)) {3154 .@"union" => switch (base_ty.containerLayout(zcu)) {
3155 .auto => off: {3155 .auto => off: {
3156 // Keep in sync with the `un` case of `generateSymbol`.3156 // Keep in sync with the `un` case of `generateSymbol`.
3157 const layout = base_ty.unionGetLayout(zcu);3157 const layout = base_ty.unionGetLayout(zcu);
...@@ -3184,7 +3184,7 @@ fn lowerUavRef(...@@ -3184,7 +3184,7 @@ fn lowerUavRef(
3184 const zcu = pt.zcu;3184 const zcu = pt.zcu;
3185 const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav.val));3185 const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav.val));
31863186
3187 const is_fn_body = ty.zigTypeTag(zcu) == .Fn;3187 const is_fn_body = ty.zigTypeTag(zcu) == .@"fn";
3188 if (!is_fn_body and !ty.hasRuntimeBitsIgnoreComptime(zcu)) {3188 if (!is_fn_body and !ty.hasRuntimeBitsIgnoreComptime(zcu)) {
3189 return .{ .imm32 = 0xaaaaaaaa };3189 return .{ .imm32 = 0xaaaaaaaa };
3190 }3190 }
...@@ -3404,34 +3404,34 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {...@@ -3404,34 +3404,34 @@ fn emitUndefined(func: *CodeGen, ty: Type) InnerError!WValue {
3404 const zcu = pt.zcu;3404 const zcu = pt.zcu;
3405 const ip = &zcu.intern_pool;3405 const ip = &zcu.intern_pool;
3406 switch (ty.zigTypeTag(zcu)) {3406 switch (ty.zigTypeTag(zcu)) {
3407 .Bool, .ErrorSet => return .{ .imm32 = 0xaaaaaaaa },3407 .bool, .error_set => return .{ .imm32 = 0xaaaaaaaa },
3408 .Int, .Enum => switch (ty.intInfo(zcu).bits) {3408 .int, .@"enum" => switch (ty.intInfo(zcu).bits) {
3409 0...32 => return .{ .imm32 = 0xaaaaaaaa },3409 0...32 => return .{ .imm32 = 0xaaaaaaaa },
3410 33...64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa },3410 33...64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa },
3411 else => unreachable,3411 else => unreachable,
3412 },3412 },
3413 .Float => switch (ty.floatBits(func.target.*)) {3413 .float => switch (ty.floatBits(func.target.*)) {
3414 16 => return .{ .imm32 = 0xaaaaaaaa },3414 16 => return .{ .imm32 = 0xaaaaaaaa },
3415 32 => return .{ .float32 = @as(f32, @bitCast(@as(u32, 0xaaaaaaaa))) },3415 32 => return .{ .float32 = @as(f32, @bitCast(@as(u32, 0xaaaaaaaa))) },
3416 64 => return .{ .float64 = @as(f64, @bitCast(@as(u64, 0xaaaaaaaaaaaaaaaa))) },3416 64 => return .{ .float64 = @as(f64, @bitCast(@as(u64, 0xaaaaaaaaaaaaaaaa))) },
3417 else => unreachable,3417 else => unreachable,
3418 },3418 },
3419 .Pointer => switch (func.arch()) {3419 .pointer => switch (func.arch()) {
3420 .wasm32 => return .{ .imm32 = 0xaaaaaaaa },3420 .wasm32 => return .{ .imm32 = 0xaaaaaaaa },
3421 .wasm64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa },3421 .wasm64 => return .{ .imm64 = 0xaaaaaaaaaaaaaaaa },
3422 else => unreachable,3422 else => unreachable,
3423 },3423 },
3424 .Optional => {3424 .optional => {
3425 const pl_ty = ty.optionalChild(zcu);3425 const pl_ty = ty.optionalChild(zcu);
3426 if (ty.optionalReprIsPayload(zcu)) {3426 if (ty.optionalReprIsPayload(zcu)) {
3427 return func.emitUndefined(pl_ty);3427 return func.emitUndefined(pl_ty);
3428 }3428 }
3429 return .{ .imm32 = 0xaaaaaaaa };3429 return .{ .imm32 = 0xaaaaaaaa };
3430 },3430 },
3431 .ErrorUnion => {3431 .error_union => {
3432 return .{ .imm32 = 0xaaaaaaaa };3432 return .{ .imm32 = 0xaaaaaaaa };
3433 },3433 },
3434 .Struct => {3434 .@"struct" => {
3435 const packed_struct = zcu.typeToPackedStruct(ty).?;3435 const packed_struct = zcu.typeToPackedStruct(ty).?;
3436 return func.emitUndefined(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)));3436 return func.emitUndefined(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)));
3437 },3437 },
...@@ -3604,7 +3604,7 @@ fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareO...@@ -3604,7 +3604,7 @@ fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareO
3604 assert(!(lhs != .stack and rhs == .stack));3604 assert(!(lhs != .stack and rhs == .stack));
3605 const pt = func.pt;3605 const pt = func.pt;
3606 const zcu = pt.zcu;3606 const zcu = pt.zcu;
3607 if (ty.zigTypeTag(zcu) == .Optional and !ty.optionalReprIsPayload(zcu)) {3607 if (ty.zigTypeTag(zcu) == .optional and !ty.optionalReprIsPayload(zcu)) {
3608 const payload_ty = ty.optionalChild(zcu);3608 const payload_ty = ty.optionalChild(zcu);
3609 if (payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {3609 if (payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
3610 // When we hit this case, we must check the value of optionals3610 // When we hit this case, we must check the value of optionals
...@@ -3620,7 +3620,7 @@ fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareO...@@ -3620,7 +3620,7 @@ fn cmp(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: std.math.CompareO
36203620
3621 const signedness: std.builtin.Signedness = blk: {3621 const signedness: std.builtin.Signedness = blk: {
3622 // by default we tell the operand type is unsigned (i.e. bools and enum values)3622 // by default we tell the operand type is unsigned (i.e. bools and enum values)
3623 if (ty.zigTypeTag(zcu) != .Int) break :blk .unsigned;3623 if (ty.zigTypeTag(zcu) != .int) break :blk .unsigned;
36243624
3625 // incase of an actual integer, we emit the correct signedness3625 // incase of an actual integer, we emit the correct signedness
3626 break :blk ty.intInfo(zcu).signedness;3626 break :blk ty.intInfo(zcu).signedness;
...@@ -3743,7 +3743,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3743,7 +3743,7 @@ fn airNot(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3743 const zcu = pt.zcu;3743 const zcu = pt.zcu;
37443744
3745 const result = result: {3745 const result = result: {
3746 if (operand_ty.zigTypeTag(zcu) == .Bool) {3746 if (operand_ty.zigTypeTag(zcu) == .bool) {
3747 try func.emitWValue(operand);3747 try func.emitWValue(operand);
3748 try func.addTag(.i32_eqz);3748 try func.addTag(.i32_eqz);
3749 const not_tmp = try func.allocLocal(operand_ty);3749 const not_tmp = try func.allocLocal(operand_ty);
...@@ -3922,14 +3922,14 @@ fn structFieldPtr(...@@ -3922,14 +3922,14 @@ fn structFieldPtr(
39223922
3923 const offset = switch (struct_ty.containerLayout(zcu)) {3923 const offset = switch (struct_ty.containerLayout(zcu)) {
3924 .@"packed" => switch (struct_ty.zigTypeTag(zcu)) {3924 .@"packed" => switch (struct_ty.zigTypeTag(zcu)) {
3925 .Struct => offset: {3925 .@"struct" => offset: {
3926 if (result_ty.ptrInfo(zcu).packed_offset.host_size != 0) {3926 if (result_ty.ptrInfo(zcu).packed_offset.host_size != 0) {
3927 break :offset @as(u32, 0);3927 break :offset @as(u32, 0);
3928 }3928 }
3929 const struct_type = zcu.typeToStruct(struct_ty).?;3929 const struct_type = zcu.typeToStruct(struct_ty).?;
3930 break :offset @divExact(pt.structPackedFieldBitOffset(struct_type, index) + struct_ptr_ty_info.packed_offset.bit_offset, 8);3930 break :offset @divExact(pt.structPackedFieldBitOffset(struct_type, index) + struct_ptr_ty_info.packed_offset.bit_offset, 8);
3931 },3931 },
3932 .Union => 0,3932 .@"union" => 0,
3933 else => unreachable,3933 else => unreachable,
3934 },3934 },
3935 else => struct_ty.structFieldOffset(index, zcu),3935 else => struct_ty.structFieldOffset(index, zcu),
...@@ -3961,7 +3961,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3961,7 +3961,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
39613961
3962 const result: WValue = switch (struct_ty.containerLayout(zcu)) {3962 const result: WValue = switch (struct_ty.containerLayout(zcu)) {
3963 .@"packed" => switch (struct_ty.zigTypeTag(zcu)) {3963 .@"packed" => switch (struct_ty.zigTypeTag(zcu)) {
3964 .Struct => result: {3964 .@"struct" => result: {
3965 const packed_struct = zcu.typeToPackedStruct(struct_ty).?;3965 const packed_struct = zcu.typeToPackedStruct(struct_ty).?;
3966 const offset = pt.structPackedFieldBitOffset(packed_struct, field_index);3966 const offset = pt.structPackedFieldBitOffset(packed_struct, field_index);
3967 const backing_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip));3967 const backing_ty = Type.fromInterned(packed_struct.backingIntTypeUnordered(ip));
...@@ -3981,7 +3981,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3981,7 +3981,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3981 else3981 else
3982 try func.binOp(operand, const_wvalue, backing_ty, .shr);3982 try func.binOp(operand, const_wvalue, backing_ty, .shr);
39833983
3984 if (field_ty.zigTypeTag(zcu) == .Float) {3984 if (field_ty.zigTypeTag(zcu) == .float) {
3985 const int_type = try pt.intType(.unsigned, @as(u16, @intCast(field_ty.bitSize(zcu))));3985 const int_type = try pt.intType(.unsigned, @as(u16, @intCast(field_ty.bitSize(zcu))));
3986 const truncated = try func.trunc(shifted_value, int_type, backing_ty);3986 const truncated = try func.trunc(shifted_value, int_type, backing_ty);
3987 break :result try func.bitcast(field_ty, int_type, truncated);3987 break :result try func.bitcast(field_ty, int_type, truncated);
...@@ -3995,7 +3995,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -3995,7 +3995,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
3995 }3995 }
3996 break :result try func.trunc(shifted_value, field_ty, backing_ty);3996 break :result try func.trunc(shifted_value, field_ty, backing_ty);
3997 },3997 },
3998 .Union => result: {3998 .@"union" => result: {
3999 if (isByRef(struct_ty, pt, func.target.*)) {3999 if (isByRef(struct_ty, pt, func.target.*)) {
4000 if (!isByRef(field_ty, pt, func.target.*)) {4000 if (!isByRef(field_ty, pt, func.target.*)) {
4001 break :result try func.load(operand, field_ty, 0);4001 break :result try func.load(operand, field_ty, 0);
...@@ -4007,7 +4007,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4007,7 +4007,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4007 }4007 }
40084008
4009 const union_int_type = try pt.intType(.unsigned, @as(u16, @intCast(struct_ty.bitSize(zcu))));4009 const union_int_type = try pt.intType(.unsigned, @as(u16, @intCast(struct_ty.bitSize(zcu))));
4010 if (field_ty.zigTypeTag(zcu) == .Float) {4010 if (field_ty.zigTypeTag(zcu) == .float) {
4011 const int_type = try pt.intType(.unsigned, @as(u16, @intCast(field_ty.bitSize(zcu))));4011 const int_type = try pt.intType(.unsigned, @as(u16, @intCast(field_ty.bitSize(zcu))));
4012 const truncated = try func.trunc(operand, int_type, union_int_type);4012 const truncated = try func.trunc(operand, int_type, union_int_type);
4013 break :result try func.bitcast(field_ty, int_type, truncated);4013 break :result try func.bitcast(field_ty, int_type, truncated);
...@@ -4136,7 +4136,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4136,7 +4136,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4136 // for errors that are not present in any branch. This is fine as this default4136 // for errors that are not present in any branch. This is fine as this default
4137 // case will never be hit for those cases but we do save runtime cost and size4137 // case will never be hit for those cases but we do save runtime cost and size
4138 // by using a jump table for this instead of if-else chains.4138 // by using a jump table for this instead of if-else chains.
4139 break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .ErrorSet) switch_br.cases_len else unreachable;4139 break :blk if (has_else_body or target_ty.zigTypeTag(zcu) == .error_set) switch_br.cases_len else unreachable;
4140 };4140 };
4141 func.mir_extra.appendAssumeCapacity(idx);4141 func.mir_extra.appendAssumeCapacity(idx);
4142 } else if (has_else_body) {4142 } else if (has_else_body) {
...@@ -4147,7 +4147,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4147,7 +4147,7 @@ fn airSwitchBr(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
41474147
4148 const signedness: std.builtin.Signedness = blk: {4148 const signedness: std.builtin.Signedness = blk: {
4149 // by default we tell the operand type is unsigned (i.e. bools and enum values)4149 // by default we tell the operand type is unsigned (i.e. bools and enum values)
4150 if (target_ty.zigTypeTag(zcu) != .Int) break :blk .unsigned;4150 if (target_ty.zigTypeTag(zcu) != .int) break :blk .unsigned;
41514151
4152 // incase of an actual integer, we emit the correct signedness4152 // incase of an actual integer, we emit the correct signedness
4153 break :blk target_ty.intInfo(zcu).signedness;4153 break :blk target_ty.intInfo(zcu).signedness;
...@@ -4364,7 +4364,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4364,7 +4364,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4364 const operand_ty = func.typeOf(ty_op.operand);4364 const operand_ty = func.typeOf(ty_op.operand);
4365 const pt = func.pt;4365 const pt = func.pt;
4366 const zcu = pt.zcu;4366 const zcu = pt.zcu;
4367 if (ty.zigTypeTag(zcu) == .Vector or operand_ty.zigTypeTag(zcu) == .Vector) {4367 if (ty.zigTypeTag(zcu) == .vector or operand_ty.zigTypeTag(zcu) == .vector) {
4368 return func.fail("todo Wasm intcast for vectors", .{});4368 return func.fail("todo Wasm intcast for vectors", .{});
4369 }4369 }
4370 if (ty.abiSize(zcu) > 16 or operand_ty.abiSize(zcu) > 16) {4370 if (ty.abiSize(zcu) > 16 or operand_ty.abiSize(zcu) > 16) {
...@@ -4682,7 +4682,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4682,7 +4682,7 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4682 const pt = func.pt;4682 const pt = func.pt;
4683 const zcu = pt.zcu;4683 const zcu = pt.zcu;
46844684
4685 if (wanted_ty.zigTypeTag(zcu) == .Vector or op_ty.zigTypeTag(zcu) == .Vector) {4685 if (wanted_ty.zigTypeTag(zcu) == .vector or op_ty.zigTypeTag(zcu) == .vector) {
4686 return func.fail("TODO: trunc for vectors", .{});4686 return func.fail("TODO: trunc for vectors", .{});
4687 }4687 }
46884688
...@@ -4990,7 +4990,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -4990,7 +4990,7 @@ fn airArrayElemVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
4990 try func.addTag(.i32_mul);4990 try func.addTag(.i32_mul);
4991 try func.addTag(.i32_add);4991 try func.addTag(.i32_add);
4992 } else {4992 } else {
4993 std.debug.assert(array_ty.zigTypeTag(zcu) == .Vector);4993 std.debug.assert(array_ty.zigTypeTag(zcu) == .vector);
49944994
4995 switch (index) {4995 switch (index) {
4996 inline .imm32, .imm64 => |lane| {4996 inline .imm32, .imm64 => |lane| {
...@@ -5281,7 +5281,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5281,7 +5281,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
52815281
5282 const result: WValue = result_value: {5282 const result: WValue = result_value: {
5283 switch (result_ty.zigTypeTag(zcu)) {5283 switch (result_ty.zigTypeTag(zcu)) {
5284 .Array => {5284 .array => {
5285 const result = try func.allocStack(result_ty);5285 const result = try func.allocStack(result_ty);
5286 const elem_ty = result_ty.childType(zcu);5286 const elem_ty = result_ty.childType(zcu);
5287 const elem_size = @as(u32, @intCast(elem_ty.abiSize(zcu)));5287 const elem_size = @as(u32, @intCast(elem_ty.abiSize(zcu)));
...@@ -5320,7 +5320,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5320,7 +5320,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5320 }5320 }
5321 break :result_value result;5321 break :result_value result;
5322 },5322 },
5323 .Struct => switch (result_ty.containerLayout(zcu)) {5323 .@"struct" => switch (result_ty.containerLayout(zcu)) {
5324 .@"packed" => {5324 .@"packed" => {
5325 if (isByRef(result_ty, pt, func.target.*)) {5325 if (isByRef(result_ty, pt, func.target.*)) {
5326 return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{});5326 return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{});
...@@ -5386,7 +5386,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5386,7 +5386,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5386 break :result_value result;5386 break :result_value result;
5387 },5387 },
5388 },5388 },
5389 .Vector => return func.fail("TODO: Wasm backend: implement airAggregateInit for vectors", .{}),5389 .vector => return func.fail("TODO: Wasm backend: implement airAggregateInit for vectors", .{}),
5390 else => unreachable,5390 else => unreachable,
5391 }5391 }
5392 };5392 };
...@@ -5458,7 +5458,7 @@ fn airUnionInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5458,7 +5458,7 @@ fn airUnionInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5458 } else {5458 } else {
5459 const operand = try func.resolveInst(extra.init);5459 const operand = try func.resolveInst(extra.init);
5460 const union_int_type = try pt.intType(.unsigned, @as(u16, @intCast(union_ty.bitSize(zcu))));5460 const union_int_type = try pt.intType(.unsigned, @as(u16, @intCast(union_ty.bitSize(zcu))));
5461 if (field_ty.zigTypeTag(zcu) == .Float) {5461 if (field_ty.zigTypeTag(zcu) == .float) {
5462 const int_type = try pt.intType(.unsigned, @intCast(field_ty.bitSize(zcu)));5462 const int_type = try pt.intType(.unsigned, @intCast(field_ty.bitSize(zcu)));
5463 const bitcasted = try func.bitcast(field_ty, int_type, operand);5463 const bitcasted = try func.bitcast(field_ty, int_type, operand);
5464 break :result try func.trunc(bitcasted, int_type, union_int_type);5464 break :result try func.trunc(bitcasted, int_type, union_int_type);
...@@ -5810,7 +5810,7 @@ fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5810,7 +5810,7 @@ fn airPopcount(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5810 const operand = try func.resolveInst(ty_op.operand);5810 const operand = try func.resolveInst(ty_op.operand);
5811 const op_ty = func.typeOf(ty_op.operand);5811 const op_ty = func.typeOf(ty_op.operand);
58125812
5813 if (op_ty.zigTypeTag(zcu) == .Vector) {5813 if (op_ty.zigTypeTag(zcu) == .vector) {
5814 return func.fail("TODO: Implement @popCount for vectors", .{});5814 return func.fail("TODO: Implement @popCount for vectors", .{});
5815 }5815 }
58165816
...@@ -5862,7 +5862,7 @@ fn airBitReverse(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -5862,7 +5862,7 @@ fn airBitReverse(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
5862 const operand = try func.resolveInst(ty_op.operand);5862 const operand = try func.resolveInst(ty_op.operand);
5863 const ty = func.typeOf(ty_op.operand);5863 const ty = func.typeOf(ty_op.operand);
58645864
5865 if (ty.zigTypeTag(zcu) == .Vector) {5865 if (ty.zigTypeTag(zcu) == .vector) {
5866 return func.fail("TODO: Implement @bitReverse for vectors", .{});5866 return func.fail("TODO: Implement @bitReverse for vectors", .{});
5867 }5867 }
58685868
...@@ -6028,7 +6028,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro...@@ -6028,7 +6028,7 @@ fn airAddSubWithOverflow(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerErro
6028 const pt = func.pt;6028 const pt = func.pt;
6029 const zcu = pt.zcu;6029 const zcu = pt.zcu;
60306030
6031 if (ty.zigTypeTag(zcu) == .Vector) {6031 if (ty.zigTypeTag(zcu) == .vector) {
6032 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});6032 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});
6033 }6033 }
60346034
...@@ -6075,7 +6075,7 @@ fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6075,7 +6075,7 @@ fn airShlWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6075 const ty = func.typeOf(extra.lhs);6075 const ty = func.typeOf(extra.lhs);
6076 const rhs_ty = func.typeOf(extra.rhs);6076 const rhs_ty = func.typeOf(extra.rhs);
60776077
6078 if (ty.zigTypeTag(zcu) == .Vector) {6078 if (ty.zigTypeTag(zcu) == .vector) {
6079 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});6079 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});
6080 }6080 }
60816081
...@@ -6121,7 +6121,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6121,7 +6121,7 @@ fn airMulWithOverflow(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6121 const pt = func.pt;6121 const pt = func.pt;
6122 const zcu = pt.zcu;6122 const zcu = pt.zcu;
61236123
6124 if (ty.zigTypeTag(zcu) == .Vector) {6124 if (ty.zigTypeTag(zcu) == .vector) {
6125 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});6125 return func.fail("TODO: Implement overflow arithmetic for vectors", .{});
6126 }6126 }
61276127
...@@ -6251,7 +6251,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -6251,7 +6251,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6251 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;6251 const bin_op = func.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
62526252
6253 const ty = func.typeOfIndex(inst);6253 const ty = func.typeOfIndex(inst);
6254 if (ty.zigTypeTag(zcu) == .Vector) {6254 if (ty.zigTypeTag(zcu) == .vector) {
6255 return func.fail("TODO: `@maximum` and `@minimum` for vectors", .{});6255 return func.fail("TODO: `@maximum` and `@minimum` for vectors", .{});
6256 }6256 }
62576257
...@@ -6262,7 +6262,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {...@@ -6262,7 +6262,7 @@ fn airMaxMin(func: *CodeGen, inst: Air.Inst.Index, op: Op) InnerError!void {
6262 const lhs = try func.resolveInst(bin_op.lhs);6262 const lhs = try func.resolveInst(bin_op.lhs);
6263 const rhs = try func.resolveInst(bin_op.rhs);6263 const rhs = try func.resolveInst(bin_op.rhs);
62646264
6265 if (ty.zigTypeTag(zcu) == .Float) {6265 if (ty.zigTypeTag(zcu) == .float) {
6266 var fn_name_buf: [64]u8 = undefined;6266 var fn_name_buf: [64]u8 = undefined;
6267 const float_bits = ty.floatBits(func.target.*);6267 const float_bits = ty.floatBits(func.target.*);
6268 const fn_name = std.fmt.bufPrint(&fn_name_buf, "{s}f{s}{s}", .{6268 const fn_name = std.fmt.bufPrint(&fn_name_buf, "{s}f{s}{s}", .{
...@@ -6292,7 +6292,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6292,7 +6292,7 @@ fn airMulAdd(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6292 const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data;6292 const bin_op = func.air.extraData(Air.Bin, pl_op.payload).data;
62936293
6294 const ty = func.typeOfIndex(inst);6294 const ty = func.typeOfIndex(inst);
6295 if (ty.zigTypeTag(zcu) == .Vector) {6295 if (ty.zigTypeTag(zcu) == .vector) {
6296 return func.fail("TODO: `@mulAdd` for vectors", .{});6296 return func.fail("TODO: `@mulAdd` for vectors", .{});
6297 }6297 }
62986298
...@@ -6326,7 +6326,7 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6326,7 +6326,7 @@ fn airClz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6326 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6326 const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
63276327
6328 const ty = func.typeOf(ty_op.operand);6328 const ty = func.typeOf(ty_op.operand);
6329 if (ty.zigTypeTag(zcu) == .Vector) {6329 if (ty.zigTypeTag(zcu) == .vector) {
6330 return func.fail("TODO: `@clz` for vectors", .{});6330 return func.fail("TODO: `@clz` for vectors", .{});
6331 }6331 }
63326332
...@@ -6378,7 +6378,7 @@ fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6378,7 +6378,7 @@ fn airCtz(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
63786378
6379 const ty = func.typeOf(ty_op.operand);6379 const ty = func.typeOf(ty_op.operand);
63806380
6381 if (ty.zigTypeTag(zcu) == .Vector) {6381 if (ty.zigTypeTag(zcu) == .vector) {
6382 return func.fail("TODO: `@ctz` for vectors", .{});6382 return func.fail("TODO: `@ctz` for vectors", .{});
6383 }6383 }
63846384
...@@ -6571,7 +6571,7 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {...@@ -6571,7 +6571,7 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6571 const ty = func.typeOfIndex(inst);6571 const ty = func.typeOfIndex(inst);
6572 const operand = try func.resolveInst(ty_op.operand);6572 const operand = try func.resolveInst(ty_op.operand);
65736573
6574 if (ty.zigTypeTag(zcu) == .Vector) {6574 if (ty.zigTypeTag(zcu) == .vector) {
6575 return func.fail("TODO: @byteSwap for vectors", .{});6575 return func.fail("TODO: @byteSwap for vectors", .{});
6576 }6576 }
6577 const int_info = ty.intInfo(zcu);6577 const int_info = ty.intInfo(zcu);
src/arch/wasm/abi.zig+24-24
...@@ -27,7 +27,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {...@@ -27,7 +27,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {
27 const target = zcu.getTarget();27 const target = zcu.getTarget();
28 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return none;28 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) return none;
29 switch (ty.zigTypeTag(zcu)) {29 switch (ty.zigTypeTag(zcu)) {
30 .Struct => {30 .@"struct" => {
31 const struct_type = zcu.typeToStruct(ty).?;31 const struct_type = zcu.typeToStruct(ty).?;
32 if (struct_type.layout == .@"packed") {32 if (struct_type.layout == .@"packed") {
33 if (ty.bitSize(zcu) <= 64) return direct;33 if (ty.bitSize(zcu) <= 64) return direct;
...@@ -45,30 +45,30 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {...@@ -45,30 +45,30 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {
45 }45 }
46 return classifyType(field_ty, zcu);46 return classifyType(field_ty, zcu);
47 },47 },
48 .Int, .Enum, .ErrorSet => {48 .int, .@"enum", .error_set => {
49 const int_bits = ty.intInfo(zcu).bits;49 const int_bits = ty.intInfo(zcu).bits;
50 if (int_bits <= 64) return direct;50 if (int_bits <= 64) return direct;
51 if (int_bits <= 128) return .{ .direct, .direct };51 if (int_bits <= 128) return .{ .direct, .direct };
52 return memory;52 return memory;
53 },53 },
54 .Float => {54 .float => {
55 const float_bits = ty.floatBits(target);55 const float_bits = ty.floatBits(target);
56 if (float_bits <= 64) return direct;56 if (float_bits <= 64) return direct;
57 if (float_bits <= 128) return .{ .direct, .direct };57 if (float_bits <= 128) return .{ .direct, .direct };
58 return memory;58 return memory;
59 },59 },
60 .Bool => return direct,60 .bool => return direct,
61 .Vector => return direct,61 .vector => return direct,
62 .Array => return memory,62 .array => return memory,
63 .Optional => {63 .optional => {
64 assert(ty.isPtrLikeOptional(zcu));64 assert(ty.isPtrLikeOptional(zcu));
65 return direct;65 return direct;
66 },66 },
67 .Pointer => {67 .pointer => {
68 assert(!ty.isSlice(zcu));68 assert(!ty.isSlice(zcu));
69 return direct;69 return direct;
70 },70 },
71 .Union => {71 .@"union" => {
72 const union_obj = zcu.typeToUnion(ty).?;72 const union_obj = zcu.typeToUnion(ty).?;
73 if (union_obj.flagsUnordered(ip).layout == .@"packed") {73 if (union_obj.flagsUnordered(ip).layout == .@"packed") {
74 if (ty.bitSize(zcu) <= 64) return direct;74 if (ty.bitSize(zcu) <= 64) return direct;
...@@ -80,19 +80,19 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {...@@ -80,19 +80,19 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {
80 const first_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[0]);80 const first_field_ty = Type.fromInterned(union_obj.field_types.get(ip)[0]);
81 return classifyType(first_field_ty, zcu);81 return classifyType(first_field_ty, zcu);
82 },82 },
83 .ErrorUnion,83 .error_union,
84 .Frame,84 .frame,
85 .AnyFrame,85 .@"anyframe",
86 .NoReturn,86 .noreturn,
87 .Void,87 .void,
88 .Type,88 .type,
89 .ComptimeFloat,89 .comptime_float,
90 .ComptimeInt,90 .comptime_int,
91 .Undefined,91 .undefined,
92 .Null,92 .null,
93 .Fn,93 .@"fn",
94 .Opaque,94 .@"opaque",
95 .EnumLiteral,95 .enum_literal,
96 => unreachable,96 => unreachable,
97 }97 }
98}98}
...@@ -103,7 +103,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {...@@ -103,7 +103,7 @@ pub fn classifyType(ty: Type, zcu: *Zcu) [2]Class {
103pub fn scalarType(ty: Type, zcu: *Zcu) Type {103pub fn scalarType(ty: Type, zcu: *Zcu) Type {
104 const ip = &zcu.intern_pool;104 const ip = &zcu.intern_pool;
105 switch (ty.zigTypeTag(zcu)) {105 switch (ty.zigTypeTag(zcu)) {
106 .Struct => {106 .@"struct" => {
107 if (zcu.typeToPackedStruct(ty)) |packed_struct| {107 if (zcu.typeToPackedStruct(ty)) |packed_struct| {
108 return scalarType(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), zcu);108 return scalarType(Type.fromInterned(packed_struct.backingIntTypeUnordered(ip)), zcu);
109 } else {109 } else {
...@@ -111,7 +111,7 @@ pub fn scalarType(ty: Type, zcu: *Zcu) Type {...@@ -111,7 +111,7 @@ pub fn scalarType(ty: Type, zcu: *Zcu) Type {
111 return scalarType(ty.fieldType(0, zcu), zcu);111 return scalarType(ty.fieldType(0, zcu), zcu);
112 }112 }
113 },113 },
114 .Union => {114 .@"union" => {
115 const union_obj = zcu.typeToUnion(ty).?;115 const union_obj = zcu.typeToUnion(ty).?;
116 if (union_obj.flagsUnordered(ip).layout != .@"packed") {116 if (union_obj.flagsUnordered(ip).layout != .@"packed") {
117 const layout = Type.getUnionLayout(union_obj, zcu);117 const layout = Type.getUnionLayout(union_obj, zcu);
src/arch/x86_64/CodeGen.zig+118-118
...@@ -2419,7 +2419,7 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {...@@ -2419,7 +2419,7 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
2419 const zcu = pt.zcu;2419 const zcu = pt.zcu;
2420 const ip = &zcu.intern_pool;2420 const ip = &zcu.intern_pool;
2421 switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) {2421 switch (Type.fromInterned(lazy_sym.ty).zigTypeTag(zcu)) {
2422 .Enum => {2422 .@"enum" => {
2423 const enum_ty = Type.fromInterned(lazy_sym.ty);2423 const enum_ty = Type.fromInterned(lazy_sym.ty);
2424 wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)});2424 wip_mir_log.debug("{}.@tagName:", .{enum_ty.fmt(pt)});
24252425
...@@ -2704,13 +2704,13 @@ fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: b...@@ -2704,13 +2704,13 @@ fn allocRegOrMemAdvanced(self: *Self, ty: Type, inst: ?Air.Inst.Index, reg_ok: b
27042704
2705 if (reg_ok) need_mem: {2705 if (reg_ok) need_mem: {
2706 if (abi_size <= @as(u32, switch (ty.zigTypeTag(zcu)) {2706 if (abi_size <= @as(u32, switch (ty.zigTypeTag(zcu)) {
2707 .Float => switch (ty.floatBits(self.target.*)) {2707 .float => switch (ty.floatBits(self.target.*)) {
2708 16, 32, 64, 128 => 16,2708 16, 32, 64, 128 => 16,
2709 80 => break :need_mem,2709 80 => break :need_mem,
2710 else => unreachable,2710 else => unreachable,
2711 },2711 },
2712 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {2712 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
2713 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {2713 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
2714 16, 32, 64, 128 => if (self.hasFeature(.avx)) 32 else 16,2714 16, 32, 64, 128 => if (self.hasFeature(.avx)) 32 else 16,
2715 80 => break :need_mem,2715 80 => break :need_mem,
2716 else => unreachable,2716 else => unreachable,
...@@ -2733,11 +2733,11 @@ fn regClassForType(self: *Self, ty: Type) RegisterManager.RegisterBitSet {...@@ -2733,11 +2733,11 @@ fn regClassForType(self: *Self, ty: Type) RegisterManager.RegisterBitSet {
2733 const pt = self.pt;2733 const pt = self.pt;
2734 const zcu = pt.zcu;2734 const zcu = pt.zcu;
2735 return switch (ty.zigTypeTag(zcu)) {2735 return switch (ty.zigTypeTag(zcu)) {
2736 .Float => switch (ty.floatBits(self.target.*)) {2736 .float => switch (ty.floatBits(self.target.*)) {
2737 80 => abi.RegisterClass.x87,2737 80 => abi.RegisterClass.x87,
2738 else => abi.RegisterClass.sse,2738 else => abi.RegisterClass.sse,
2739 },2739 },
2740 .Vector => switch (ty.childType(zcu).toIntern()) {2740 .vector => switch (ty.childType(zcu).toIntern()) {
2741 .bool_type, .u1_type => abi.RegisterClass.gp,2741 .bool_type, .u1_type => abi.RegisterClass.gp,
2742 else => if (ty.isAbiInt(zcu) and ty.intInfo(zcu).bits == 1)2742 else => if (ty.isAbiInt(zcu) and ty.intInfo(zcu).bits == 1)
2743 abi.RegisterClass.gp2743 abi.RegisterClass.gp
...@@ -2801,14 +2801,14 @@ fn restoreState(self: *Self, state: State, deaths: []const Air.Inst.Index, compt...@@ -2801,14 +2801,14 @@ fn restoreState(self: *Self, state: State, deaths: []const Air.Inst.Index, compt
2801 ) |inst, *tracking| tracking.resurrect(inst, state.scope_generation);2801 ) |inst, *tracking| tracking.resurrect(inst, state.scope_generation);
2802 for (deaths) |death| try self.processDeath(death);2802 for (deaths) |death| try self.processDeath(death);
28032803
2804 const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).Array.len]RegisterLock;2804 const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
2805 var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =2805 var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
2806 if (opts.update_tracking)2806 if (opts.update_tracking)
2807 {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);2807 {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
28082808
2809 var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(2809 var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
2810 stack.get(),2810 stack.get(),
2811 @typeInfo(ExpectedContents).Array.len,2811 @typeInfo(ExpectedContents).array.len,
2812 );2812 );
2813 defer if (!opts.update_tracking) {2813 defer if (!opts.update_tracking) {
2814 for (reg_locks.items) |lock| self.register_manager.unlockReg(lock);2814 for (reg_locks.items) |lock| self.register_manager.unlockReg(lock);
...@@ -3475,8 +3475,8 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {...@@ -3475,8 +3475,8 @@ fn airTrunc(self: *Self, inst: Air.Inst.Index) !void {
3475 break :dst dst_mcv;3475 break :dst dst_mcv;
3476 };3476 };
34773477
3478 if (dst_ty.zigTypeTag(zcu) == .Vector) {3478 if (dst_ty.zigTypeTag(zcu) == .vector) {
3479 assert(src_ty.zigTypeTag(zcu) == .Vector and dst_ty.vectorLen(zcu) == src_ty.vectorLen(zcu));3479 assert(src_ty.zigTypeTag(zcu) == .vector and dst_ty.vectorLen(zcu) == src_ty.vectorLen(zcu));
3480 const dst_elem_ty = dst_ty.childType(zcu);3480 const dst_elem_ty = dst_ty.childType(zcu);
3481 const dst_elem_abi_size: u32 = @intCast(dst_elem_ty.abiSize(zcu));3481 const dst_elem_abi_size: u32 = @intCast(dst_elem_ty.abiSize(zcu));
3482 const src_elem_ty = src_ty.childType(zcu);3482 const src_elem_ty = src_ty.childType(zcu);
...@@ -3714,7 +3714,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {...@@ -3714,7 +3714,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
3714 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];3714 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
3715 const dst_ty = self.typeOfIndex(inst);3715 const dst_ty = self.typeOfIndex(inst);
3716 switch (dst_ty.zigTypeTag(zcu)) {3716 switch (dst_ty.zigTypeTag(zcu)) {
3717 .Float, .Vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs),3717 .float, .vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs),
3718 else => {},3718 else => {},
3719 }3719 }
3720 const dst_abi_size: u32 = @intCast(dst_ty.abiSize(zcu));3720 const dst_abi_size: u32 = @intCast(dst_ty.abiSize(zcu));
...@@ -3941,7 +3941,7 @@ fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -3941,7 +3941,7 @@ fn airAddSat(self: *Self, inst: Air.Inst.Index) !void {
3941 const zcu = pt.zcu;3941 const zcu = pt.zcu;
3942 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;3942 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
3943 const ty = self.typeOf(bin_op.lhs);3943 const ty = self.typeOf(bin_op.lhs);
3944 if (ty.zigTypeTag(zcu) == .Vector or ty.abiSize(zcu) > 8) return self.fail(3944 if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail(
3945 "TODO implement airAddSat for {}",3945 "TODO implement airAddSat for {}",
3946 .{ty.fmt(pt)},3946 .{ty.fmt(pt)},
3947 );3947 );
...@@ -4042,7 +4042,7 @@ fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -4042,7 +4042,7 @@ fn airSubSat(self: *Self, inst: Air.Inst.Index) !void {
4042 const zcu = pt.zcu;4042 const zcu = pt.zcu;
4043 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;4043 const bin_op = self.air.instructions.items(.data)[@intFromEnum(inst)].bin_op;
4044 const ty = self.typeOf(bin_op.lhs);4044 const ty = self.typeOf(bin_op.lhs);
4045 if (ty.zigTypeTag(zcu) == .Vector or ty.abiSize(zcu) > 8) return self.fail(4045 if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail(
4046 "TODO implement airSubSat for {}",4046 "TODO implement airSubSat for {}",
4047 .{ty.fmt(pt)},4047 .{ty.fmt(pt)},
4048 );4048 );
...@@ -4216,7 +4216,7 @@ fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {...@@ -4216,7 +4216,7 @@ fn airMulSat(self: *Self, inst: Air.Inst.Index) !void {
4216 break :result dst_mcv;4216 break :result dst_mcv;
4217 }4217 }
42184218
4219 if (ty.zigTypeTag(zcu) == .Vector or ty.abiSize(zcu) > 8) return self.fail(4219 if (ty.zigTypeTag(zcu) == .vector or ty.abiSize(zcu) > 8) return self.fail(
4220 "TODO implement airMulSat for {}",4220 "TODO implement airMulSat for {}",
4221 .{ty.fmt(pt)},4221 .{ty.fmt(pt)},
4222 );4222 );
...@@ -4287,8 +4287,8 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -4287,8 +4287,8 @@ fn airAddSubWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
4287 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];4287 const tag = self.air.instructions.items(.tag)[@intFromEnum(inst)];
4288 const ty = self.typeOf(bin_op.lhs);4288 const ty = self.typeOf(bin_op.lhs);
4289 switch (ty.zigTypeTag(zcu)) {4289 switch (ty.zigTypeTag(zcu)) {
4290 .Vector => return self.fail("TODO implement add/sub with overflow for Vector type", .{}),4290 .vector => return self.fail("TODO implement add/sub with overflow for Vector type", .{}),
4291 .Int => {4291 .int => {
4292 try self.spillEflagsIfOccupied();4292 try self.spillEflagsIfOccupied();
4293 try self.spillRegisters(&.{ .rcx, .rdi, .rsi });4293 try self.spillRegisters(&.{ .rcx, .rdi, .rsi });
4294 const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rcx, .rdi, .rsi });4294 const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rcx, .rdi, .rsi });
...@@ -4354,8 +4354,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -4354,8 +4354,8 @@ fn airShlWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
4354 const lhs_ty = self.typeOf(bin_op.lhs);4354 const lhs_ty = self.typeOf(bin_op.lhs);
4355 const rhs_ty = self.typeOf(bin_op.rhs);4355 const rhs_ty = self.typeOf(bin_op.rhs);
4356 switch (lhs_ty.zigTypeTag(zcu)) {4356 switch (lhs_ty.zigTypeTag(zcu)) {
4357 .Vector => return self.fail("TODO implement shl with overflow for Vector type", .{}),4357 .vector => return self.fail("TODO implement shl with overflow for Vector type", .{}),
4358 .Int => {4358 .int => {
4359 try self.spillEflagsIfOccupied();4359 try self.spillEflagsIfOccupied();
4360 try self.spillRegisters(&.{ .rcx, .rdi, .rsi });4360 try self.spillRegisters(&.{ .rcx, .rdi, .rsi });
4361 const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rcx, .rdi, .rsi });4361 const reg_locks = self.register_manager.lockRegsAssumeUnused(3, .{ .rcx, .rdi, .rsi });
...@@ -4510,8 +4510,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {...@@ -4510,8 +4510,8 @@ fn airMulWithOverflow(self: *Self, inst: Air.Inst.Index) !void {
4510 const tuple_ty = self.typeOfIndex(inst);4510 const tuple_ty = self.typeOfIndex(inst);
4511 const dst_ty = self.typeOf(bin_op.lhs);4511 const dst_ty = self.typeOf(bin_op.lhs);
4512 const result: MCValue = switch (dst_ty.zigTypeTag(zcu)) {4512 const result: MCValue = switch (dst_ty.zigTypeTag(zcu)) {
4513 .Vector => return self.fail("TODO implement airMulWithOverflow for {}", .{dst_ty.fmt(pt)}),4513 .vector => return self.fail("TODO implement airMulWithOverflow for {}", .{dst_ty.fmt(pt)}),
4514 .Int => result: {4514 .int => result: {
4515 const dst_info = dst_ty.intInfo(zcu);4515 const dst_info = dst_ty.intInfo(zcu);
4516 if (dst_info.bits > 128 and dst_info.signedness == .unsigned) {4516 if (dst_info.bits > 128 and dst_info.signedness == .unsigned) {
4517 const slow_inc = self.hasFeature(.slow_incdec);4517 const slow_inc = self.hasFeature(.slow_incdec);
...@@ -5005,7 +5005,7 @@ fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {...@@ -5005,7 +5005,7 @@ fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {
5005 const rhs_ty = self.typeOf(bin_op.rhs);5005 const rhs_ty = self.typeOf(bin_op.rhs);
5006 const result: MCValue = result: {5006 const result: MCValue = result: {
5007 switch (lhs_ty.zigTypeTag(zcu)) {5007 switch (lhs_ty.zigTypeTag(zcu)) {
5008 .Int => {5008 .int => {
5009 try self.spillRegisters(&.{.rcx});5009 try self.spillRegisters(&.{.rcx});
5010 try self.register_manager.getKnownReg(.rcx, null);5010 try self.register_manager.getKnownReg(.rcx, null);
5011 const lhs_mcv = try self.resolveInst(bin_op.lhs);5011 const lhs_mcv = try self.resolveInst(bin_op.lhs);
...@@ -5047,8 +5047,8 @@ fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {...@@ -5047,8 +5047,8 @@ fn airShlShrBinOp(self: *Self, inst: Air.Inst.Index) !void {
5047 }5047 }
5048 break :result dst_mcv;5048 break :result dst_mcv;
5049 },5049 },
5050 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {5050 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
5051 .Int => if (@as(?Mir.Inst.FixedTag, switch (lhs_ty.childType(zcu).intInfo(zcu).bits) {5051 .int => if (@as(?Mir.Inst.FixedTag, switch (lhs_ty.childType(zcu).intInfo(zcu).bits) {
5052 else => null,5052 else => null,
5053 16 => switch (lhs_ty.vectorLen(zcu)) {5053 16 => switch (lhs_ty.vectorLen(zcu)) {
5054 else => null,5054 else => null,
...@@ -6212,7 +6212,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {...@@ -6212,7 +6212,7 @@ fn airClz(self: *Self, inst: Air.Inst.Index) !void {
62126212
6213 const dst_ty = self.typeOfIndex(inst);6213 const dst_ty = self.typeOfIndex(inst);
6214 const src_ty = self.typeOf(ty_op.operand);6214 const src_ty = self.typeOf(ty_op.operand);
6215 if (src_ty.zigTypeTag(zcu) == .Vector) return self.fail("TODO implement airClz for {}", .{6215 if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airClz for {}", .{
6216 src_ty.fmt(pt),6216 src_ty.fmt(pt),
6217 });6217 });
62186218
...@@ -6409,7 +6409,7 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void {...@@ -6409,7 +6409,7 @@ fn airCtz(self: *Self, inst: Air.Inst.Index) !void {
64096409
6410 const dst_ty = self.typeOfIndex(inst);6410 const dst_ty = self.typeOfIndex(inst);
6411 const src_ty = self.typeOf(ty_op.operand);6411 const src_ty = self.typeOf(ty_op.operand);
6412 if (src_ty.zigTypeTag(zcu) == .Vector) return self.fail("TODO implement airCtz for {}", .{6412 if (src_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement airCtz for {}", .{
6413 src_ty.fmt(pt),6413 src_ty.fmt(pt),
6414 });6414 });
64156415
...@@ -6571,7 +6571,7 @@ fn airPopCount(self: *Self, inst: Air.Inst.Index) !void {...@@ -6571,7 +6571,7 @@ fn airPopCount(self: *Self, inst: Air.Inst.Index) !void {
65716571
6572 const src_ty = self.typeOf(ty_op.operand);6572 const src_ty = self.typeOf(ty_op.operand);
6573 const src_abi_size: u32 = @intCast(src_ty.abiSize(zcu));6573 const src_abi_size: u32 = @intCast(src_ty.abiSize(zcu));
6574 if (src_ty.zigTypeTag(zcu) == .Vector or src_abi_size > 16)6574 if (src_ty.zigTypeTag(zcu) == .vector or src_abi_size > 16)
6575 return self.fail("TODO implement airPopCount for {}", .{src_ty.fmt(pt)});6575 return self.fail("TODO implement airPopCount for {}", .{src_ty.fmt(pt)});
6576 const src_mcv = try self.resolveInst(ty_op.operand);6576 const src_mcv = try self.resolveInst(ty_op.operand);
65776577
...@@ -6724,7 +6724,7 @@ fn genByteSwap(...@@ -6724,7 +6724,7 @@ fn genByteSwap(
6724 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;6724 const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op;
6725 const has_movbe = self.hasFeature(.movbe);6725 const has_movbe = self.hasFeature(.movbe);
67266726
6727 if (src_ty.zigTypeTag(zcu) == .Vector) return self.fail(6727 if (src_ty.zigTypeTag(zcu) == .vector) return self.fail(
6728 "TODO implement genByteSwap for {}",6728 "TODO implement genByteSwap for {}",
6729 .{src_ty.fmt(pt)},6729 .{src_ty.fmt(pt)},
6730 );6730 );
...@@ -7036,7 +7036,7 @@ fn floatSign(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type)...@@ -7036,7 +7036,7 @@ fn floatSign(self: *Self, inst: Air.Inst.Index, operand: Air.Inst.Ref, ty: Type)
7036 const result = result: {7036 const result = result: {
7037 const scalar_bits = ty.scalarType(zcu).floatBits(self.target.*);7037 const scalar_bits = ty.scalarType(zcu).floatBits(self.target.*);
7038 if (scalar_bits == 80) {7038 if (scalar_bits == 80) {
7039 if (ty.zigTypeTag(zcu) != .Float) return self.fail("TODO implement floatSign for {}", .{7039 if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement floatSign for {}", .{
7040 ty.fmt(pt),7040 ty.fmt(pt),
7041 });7041 });
70427042
...@@ -7209,14 +7209,14 @@ fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {...@@ -7209,14 +7209,14 @@ fn getRoundTag(self: *Self, ty: Type) ?Mir.Inst.FixedTag {
7209 const pt = self.pt;7209 const pt = self.pt;
7210 const zcu = pt.zcu;7210 const zcu = pt.zcu;
7211 return if (self.hasFeature(.sse4_1)) switch (ty.zigTypeTag(zcu)) {7211 return if (self.hasFeature(.sse4_1)) switch (ty.zigTypeTag(zcu)) {
7212 .Float => switch (ty.floatBits(self.target.*)) {7212 .float => switch (ty.floatBits(self.target.*)) {
7213 32 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },7213 32 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },
7214 64 => if (self.hasFeature(.avx)) .{ .v_sd, .round } else .{ ._sd, .round },7214 64 => if (self.hasFeature(.avx)) .{ .v_sd, .round } else .{ ._sd, .round },
7215 16, 80, 128 => null,7215 16, 80, 128 => null,
7216 else => unreachable,7216 else => unreachable,
7217 },7217 },
7218 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {7218 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
7219 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {7219 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
7220 32 => switch (ty.vectorLen(zcu)) {7220 32 => switch (ty.vectorLen(zcu)) {
7221 1 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },7221 1 => if (self.hasFeature(.avx)) .{ .v_ss, .round } else .{ ._ss, .round },
7222 2...4 => if (self.hasFeature(.avx)) .{ .v_ps, .round } else .{ ._ps, .round },7222 2...4 => if (self.hasFeature(.avx)) .{ .v_ps, .round } else .{ ._ps, .round },
...@@ -7243,7 +7243,7 @@ fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MC...@@ -7243,7 +7243,7 @@ fn genRoundLibcall(self: *Self, ty: Type, src_mcv: MCValue, mode: RoundMode) !MC
7243 const zcu = pt.zcu;7243 const zcu = pt.zcu;
7244 if (self.getRoundTag(ty)) |_| return .none;7244 if (self.getRoundTag(ty)) |_| return .none;
72457245
7246 if (ty.zigTypeTag(zcu) != .Float)7246 if (ty.zigTypeTag(zcu) != .float)
7247 return self.fail("TODO implement genRound for {}", .{ty.fmt(pt)});7247 return self.fail("TODO implement genRound for {}", .{ty.fmt(pt)});
72487248
7249 var callee_buf: ["__trunc?".len]u8 = undefined;7249 var callee_buf: ["__trunc?".len]u8 = undefined;
...@@ -7314,7 +7314,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {...@@ -7314,7 +7314,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
7314 const result: MCValue = result: {7314 const result: MCValue = result: {
7315 const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.zigTypeTag(zcu)) {7315 const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.zigTypeTag(zcu)) {
7316 else => null,7316 else => null,
7317 .Int => switch (ty.abiSize(zcu)) {7317 .int => switch (ty.abiSize(zcu)) {
7318 0 => unreachable,7318 0 => unreachable,
7319 1...8 => {7319 1...8 => {
7320 try self.spillEflagsIfOccupied();7320 try self.spillEflagsIfOccupied();
...@@ -7442,10 +7442,10 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {...@@ -7442,10 +7442,10 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
7442 break :result dst_mcv;7442 break :result dst_mcv;
7443 },7443 },
7444 },7444 },
7445 .Float => return self.floatSign(inst, ty_op.operand, ty),7445 .float => return self.floatSign(inst, ty_op.operand, ty),
7446 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {7446 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
7447 else => null,7447 else => null,
7448 .Int => switch (ty.childType(zcu).intInfo(zcu).bits) {7448 .int => switch (ty.childType(zcu).intInfo(zcu).bits) {
7449 else => null,7449 else => null,
7450 8 => switch (ty.vectorLen(zcu)) {7450 8 => switch (ty.vectorLen(zcu)) {
7451 else => null,7451 else => null,
...@@ -7478,7 +7478,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {...@@ -7478,7 +7478,7 @@ fn airAbs(self: *Self, inst: Air.Inst.Index) !void {
7478 5...8 => if (self.hasFeature(.avx2)) .{ .vp_d, .abs } else null,7478 5...8 => if (self.hasFeature(.avx2)) .{ .vp_d, .abs } else null,
7479 },7479 },
7480 },7480 },
7481 .Float => return self.floatSign(inst, ty_op.operand, ty),7481 .float => return self.floatSign(inst, ty_op.operand, ty),
7482 },7482 },
7483 }) orelse return self.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});7483 }) orelse return self.fail("TODO implement airAbs for {}", .{ty.fmt(pt)});
74847484
...@@ -7515,7 +7515,7 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {...@@ -7515,7 +7515,7 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {
75157515
7516 const result: MCValue = result: {7516 const result: MCValue = result: {
7517 switch (ty.zigTypeTag(zcu)) {7517 switch (ty.zigTypeTag(zcu)) {
7518 .Float => {7518 .float => {
7519 const float_bits = ty.floatBits(self.target.*);7519 const float_bits = ty.floatBits(self.target.*);
7520 if (switch (float_bits) {7520 if (switch (float_bits) {
7521 16 => !self.hasFeature(.f16c),7521 16 => !self.hasFeature(.f16c),
...@@ -7547,7 +7547,7 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {...@@ -7547,7 +7547,7 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {
7547 defer if (dst_lock) |lock| self.register_manager.unlockReg(lock);7547 defer if (dst_lock) |lock| self.register_manager.unlockReg(lock);
75487548
7549 const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.zigTypeTag(zcu)) {7549 const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.zigTypeTag(zcu)) {
7550 .Float => switch (ty.floatBits(self.target.*)) {7550 .float => switch (ty.floatBits(self.target.*)) {
7551 16 => {7551 16 => {
7552 assert(self.hasFeature(.f16c));7552 assert(self.hasFeature(.f16c));
7553 const mat_src_reg = if (src_mcv.isRegister())7553 const mat_src_reg = if (src_mcv.isRegister())
...@@ -7568,8 +7568,8 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {...@@ -7568,8 +7568,8 @@ fn airSqrt(self: *Self, inst: Air.Inst.Index) !void {
7568 64 => if (self.hasFeature(.avx)) .{ .v_sd, .sqrt } else .{ ._sd, .sqrt },7568 64 => if (self.hasFeature(.avx)) .{ .v_sd, .sqrt } else .{ ._sd, .sqrt },
7569 else => unreachable,7569 else => unreachable,
7570 },7570 },
7571 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {7571 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
7572 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {7572 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
7573 16 => if (self.hasFeature(.f16c)) switch (ty.vectorLen(zcu)) {7573 16 => if (self.hasFeature(.f16c)) switch (ty.vectorLen(zcu)) {
7574 1 => {7574 1 => {
7575 try self.asmRegisterRegister(7575 try self.asmRegisterRegister(
...@@ -8496,7 +8496,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:...@@ -8496,7 +8496,7 @@ fn genUnOp(self: *Self, maybe_inst: ?Air.Inst.Index, tag: Air.Inst.Tag, src_air:
8496 const pt = self.pt;8496 const pt = self.pt;
8497 const zcu = pt.zcu;8497 const zcu = pt.zcu;
8498 const src_ty = self.typeOf(src_air);8498 const src_ty = self.typeOf(src_air);
8499 if (src_ty.zigTypeTag(zcu) == .Vector)8499 if (src_ty.zigTypeTag(zcu) == .vector)
8500 return self.fail("TODO implement genUnOp for {}", .{src_ty.fmt(pt)});8500 return self.fail("TODO implement genUnOp for {}", .{src_ty.fmt(pt)});
85018501
8502 var src_mcv = try self.resolveInst(src_air);8502 var src_mcv = try self.resolveInst(src_air);
...@@ -9291,7 +9291,7 @@ fn genShiftBinOp(...@@ -9291,7 +9291,7 @@ fn genShiftBinOp(
9291) !MCValue {9291) !MCValue {
9292 const pt = self.pt;9292 const pt = self.pt;
9293 const zcu = pt.zcu;9293 const zcu = pt.zcu;
9294 if (lhs_ty.zigTypeTag(zcu) == .Vector) return self.fail("TODO implement genShiftBinOp for {}", .{9294 if (lhs_ty.zigTypeTag(zcu) == .vector) return self.fail("TODO implement genShiftBinOp for {}", .{
9295 lhs_ty.fmt(pt),9295 lhs_ty.fmt(pt),
9296 });9296 });
92979297
...@@ -9350,7 +9350,7 @@ fn genMulDivBinOp(...@@ -9350,7 +9350,7 @@ fn genMulDivBinOp(
9350) !MCValue {9350) !MCValue {
9351 const pt = self.pt;9351 const pt = self.pt;
9352 const zcu = pt.zcu;9352 const zcu = pt.zcu;
9353 if (dst_ty.zigTypeTag(zcu) == .Vector or dst_ty.zigTypeTag(zcu) == .Float) return self.fail(9353 if (dst_ty.zigTypeTag(zcu) == .vector or dst_ty.zigTypeTag(zcu) == .float) return self.fail(
9354 "TODO implement genMulDivBinOp for {s} from {} to {}",9354 "TODO implement genMulDivBinOp for {s} from {} to {}",
9355 .{ @tagName(tag), src_ty.fmt(pt), dst_ty.fmt(pt) },9355 .{ @tagName(tag), src_ty.fmt(pt), dst_ty.fmt(pt) },
9356 );9356 );
...@@ -9938,8 +9938,8 @@ fn genBinOp(...@@ -9938,8 +9938,8 @@ fn genBinOp(
99389938
9939 const sse_op = switch (lhs_ty.zigTypeTag(zcu)) {9939 const sse_op = switch (lhs_ty.zigTypeTag(zcu)) {
9940 else => false,9940 else => false,
9941 .Float => true,9941 .float => true,
9942 .Vector => switch (lhs_ty.childType(zcu).toIntern()) {9942 .vector => switch (lhs_ty.childType(zcu).toIntern()) {
9943 .bool_type, .u1_type => false,9943 .bool_type, .u1_type => false,
9944 else => true,9944 else => true,
9945 },9945 },
...@@ -9966,12 +9966,12 @@ fn genBinOp(...@@ -9966,12 +9966,12 @@ fn genBinOp(
99669966
9967 const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and9967 const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and
9968 switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {9968 switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
9969 .Bool => false,9969 .bool => false,
9970 .Int => switch (air_tag) {9970 .int => switch (air_tag) {
9971 .cmp_lt, .cmp_gte => true,9971 .cmp_lt, .cmp_gte => true,
9972 else => false,9972 else => false,
9973 },9973 },
9974 .Float => switch (air_tag) {9974 .float => switch (air_tag) {
9975 .cmp_gte, .cmp_gt => true,9975 .cmp_gte, .cmp_gt => true,
9976 else => false,9976 else => false,
9977 },9977 },
...@@ -10337,7 +10337,7 @@ fn genBinOp(...@@ -10337,7 +10337,7 @@ fn genBinOp(
10337 const dst_reg = registerAlias(dst_mcv.getReg().?, abi_size);10337 const dst_reg = registerAlias(dst_mcv.getReg().?, abi_size);
10338 const mir_tag = @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {10338 const mir_tag = @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {
10339 else => unreachable,10339 else => unreachable,
10340 .Float => switch (lhs_ty.floatBits(self.target.*)) {10340 .float => switch (lhs_ty.floatBits(self.target.*)) {
10341 16 => {10341 16 => {
10342 assert(self.hasFeature(.f16c));10342 assert(self.hasFeature(.f16c));
10343 const tmp_reg =10343 const tmp_reg =
...@@ -10430,9 +10430,9 @@ fn genBinOp(...@@ -10430,9 +10430,9 @@ fn genBinOp(
10430 80, 128 => null,10430 80, 128 => null,
10431 else => unreachable,10431 else => unreachable,
10432 },10432 },
10433 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {10433 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
10434 else => null,10434 else => null,
10435 .Int => switch (lhs_ty.childType(zcu).intInfo(zcu).bits) {10435 .int => switch (lhs_ty.childType(zcu).intInfo(zcu).bits) {
10436 8 => switch (lhs_ty.vectorLen(zcu)) {10436 8 => switch (lhs_ty.vectorLen(zcu)) {
10437 1...16 => switch (air_tag) {10437 1...16 => switch (air_tag) {
10438 .add,10438 .add,
...@@ -10779,7 +10779,7 @@ fn genBinOp(...@@ -10779,7 +10779,7 @@ fn genBinOp(
10779 },10779 },
10780 else => null,10780 else => null,
10781 },10781 },
10782 .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {10782 .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {
10783 16 => tag: {10783 16 => tag: {
10784 assert(self.hasFeature(.f16c));10784 assert(self.hasFeature(.f16c));
10785 switch (lhs_ty.vectorLen(zcu)) {10785 switch (lhs_ty.vectorLen(zcu)) {
...@@ -11101,7 +11101,7 @@ fn genBinOp(...@@ -11101,7 +11101,7 @@ fn genBinOp(
11101 lhs_reg,11101 lhs_reg,
11102 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {11102 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {
11103 else => Memory.Size.fromSize(abi_size),11103 else => Memory.Size.fromSize(abi_size),
11104 .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()),11104 .vector => Memory.Size.fromBitSize(dst_reg.bitSize()),
11105 }),11105 }),
11106 ) else try self.asmRegisterRegisterRegister(11106 ) else try self.asmRegisterRegisterRegister(
11107 mir_tag,11107 mir_tag,
...@@ -11119,7 +11119,7 @@ fn genBinOp(...@@ -11119,7 +11119,7 @@ fn genBinOp(
11119 dst_reg,11119 dst_reg,
11120 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {11120 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {
11121 else => Memory.Size.fromSize(abi_size),11121 else => Memory.Size.fromSize(abi_size),
11122 .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()),11122 .vector => Memory.Size.fromBitSize(dst_reg.bitSize()),
11123 }),11123 }),
11124 ) else try self.asmRegisterRegister(11124 ) else try self.asmRegisterRegister(
11125 mir_tag,11125 mir_tag,
...@@ -11147,7 +11147,7 @@ fn genBinOp(...@@ -11147,7 +11147,7 @@ fn genBinOp(
11147 lhs_reg,11147 lhs_reg,
11148 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {11148 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {
11149 else => Memory.Size.fromSize(abi_size),11149 else => Memory.Size.fromSize(abi_size),
11150 .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()),11150 .vector => Memory.Size.fromBitSize(dst_reg.bitSize()),
11151 }),11151 }),
11152 imm,11152 imm,
11153 ) else try self.asmRegisterRegisterRegisterImmediate(11153 ) else try self.asmRegisterRegisterRegisterImmediate(
...@@ -11167,7 +11167,7 @@ fn genBinOp(...@@ -11167,7 +11167,7 @@ fn genBinOp(
11167 dst_reg,11167 dst_reg,
11168 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {11168 try src_mcv.mem(self, switch (lhs_ty.zigTypeTag(zcu)) {
11169 else => Memory.Size.fromSize(abi_size),11169 else => Memory.Size.fromSize(abi_size),
11170 .Vector => Memory.Size.fromBitSize(dst_reg.bitSize()),11170 .vector => Memory.Size.fromBitSize(dst_reg.bitSize()),
11171 }),11171 }),
11172 imm,11172 imm,
11173 ) else try self.asmRegisterRegisterImmediate(11173 ) else try self.asmRegisterRegisterImmediate(
...@@ -11199,14 +11199,14 @@ fn genBinOp(...@@ -11199,14 +11199,14 @@ fn genBinOp(
1119911199
11200 try self.asmRegisterRegisterRegisterImmediate(11200 try self.asmRegisterRegisterRegisterImmediate(
11201 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {11201 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {
11202 .Float => switch (lhs_ty.floatBits(self.target.*)) {11202 .float => switch (lhs_ty.floatBits(self.target.*)) {
11203 32 => .{ .v_ss, .cmp },11203 32 => .{ .v_ss, .cmp },
11204 64 => .{ .v_sd, .cmp },11204 64 => .{ .v_sd, .cmp },
11205 16, 80, 128 => null,11205 16, 80, 128 => null,
11206 else => unreachable,11206 else => unreachable,
11207 },11207 },
11208 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {11208 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
11209 .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {11209 .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {
11210 32 => switch (lhs_ty.vectorLen(zcu)) {11210 32 => switch (lhs_ty.vectorLen(zcu)) {
11211 1 => .{ .v_ss, .cmp },11211 1 => .{ .v_ss, .cmp },
11212 2...8 => .{ .v_ps, .cmp },11212 2...8 => .{ .v_ps, .cmp },
...@@ -11233,14 +11233,14 @@ fn genBinOp(...@@ -11233,14 +11233,14 @@ fn genBinOp(
11233 );11233 );
11234 try self.asmRegisterRegisterRegisterRegister(11234 try self.asmRegisterRegisterRegisterRegister(
11235 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {11235 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {
11236 .Float => switch (lhs_ty.floatBits(self.target.*)) {11236 .float => switch (lhs_ty.floatBits(self.target.*)) {
11237 32 => .{ .v_ps, .blendv },11237 32 => .{ .v_ps, .blendv },
11238 64 => .{ .v_pd, .blendv },11238 64 => .{ .v_pd, .blendv },
11239 16, 80, 128 => null,11239 16, 80, 128 => null,
11240 else => unreachable,11240 else => unreachable,
11241 },11241 },
11242 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {11242 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
11243 .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {11243 .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {
11244 32 => switch (lhs_ty.vectorLen(zcu)) {11244 32 => switch (lhs_ty.vectorLen(zcu)) {
11245 1...8 => .{ .v_ps, .blendv },11245 1...8 => .{ .v_ps, .blendv },
11246 else => null,11246 else => null,
...@@ -11267,14 +11267,14 @@ fn genBinOp(...@@ -11267,14 +11267,14 @@ fn genBinOp(
11267 const has_blend = self.hasFeature(.sse4_1);11267 const has_blend = self.hasFeature(.sse4_1);
11268 try self.asmRegisterRegisterImmediate(11268 try self.asmRegisterRegisterImmediate(
11269 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {11269 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {
11270 .Float => switch (lhs_ty.floatBits(self.target.*)) {11270 .float => switch (lhs_ty.floatBits(self.target.*)) {
11271 32 => .{ ._ss, .cmp },11271 32 => .{ ._ss, .cmp },
11272 64 => .{ ._sd, .cmp },11272 64 => .{ ._sd, .cmp },
11273 16, 80, 128 => null,11273 16, 80, 128 => null,
11274 else => unreachable,11274 else => unreachable,
11275 },11275 },
11276 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {11276 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
11277 .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {11277 .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {
11278 32 => switch (lhs_ty.vectorLen(zcu)) {11278 32 => switch (lhs_ty.vectorLen(zcu)) {
11279 1 => .{ ._ss, .cmp },11279 1 => .{ ._ss, .cmp },
11280 2...4 => .{ ._ps, .cmp },11280 2...4 => .{ ._ps, .cmp },
...@@ -11300,14 +11300,14 @@ fn genBinOp(...@@ -11300,14 +11300,14 @@ fn genBinOp(
11300 );11300 );
11301 if (has_blend) try self.asmRegisterRegisterRegister(11301 if (has_blend) try self.asmRegisterRegisterRegister(
11302 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {11302 @as(?Mir.Inst.FixedTag, switch (lhs_ty.zigTypeTag(zcu)) {
11303 .Float => switch (lhs_ty.floatBits(self.target.*)) {11303 .float => switch (lhs_ty.floatBits(self.target.*)) {
11304 32 => .{ ._ps, .blendv },11304 32 => .{ ._ps, .blendv },
11305 64 => .{ ._pd, .blendv },11305 64 => .{ ._pd, .blendv },
11306 16, 80, 128 => null,11306 16, 80, 128 => null,
11307 else => unreachable,11307 else => unreachable,
11308 },11308 },
11309 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {11309 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
11310 .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {11310 .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {
11311 32 => switch (lhs_ty.vectorLen(zcu)) {11311 32 => switch (lhs_ty.vectorLen(zcu)) {
11312 1...4 => .{ ._ps, .blendv },11312 1...4 => .{ ._ps, .blendv },
11313 else => null,11313 else => null,
...@@ -11330,14 +11330,14 @@ fn genBinOp(...@@ -11330,14 +11330,14 @@ fn genBinOp(
11330 mask_reg,11330 mask_reg,
11331 ) else {11331 ) else {
11332 const mir_fixes = @as(?Mir.Inst.Fixes, switch (lhs_ty.zigTypeTag(zcu)) {11332 const mir_fixes = @as(?Mir.Inst.Fixes, switch (lhs_ty.zigTypeTag(zcu)) {
11333 .Float => switch (lhs_ty.floatBits(self.target.*)) {11333 .float => switch (lhs_ty.floatBits(self.target.*)) {
11334 32 => ._ps,11334 32 => ._ps,
11335 64 => ._pd,11335 64 => ._pd,
11336 16, 80, 128 => null,11336 16, 80, 128 => null,
11337 else => unreachable,11337 else => unreachable,
11338 },11338 },
11339 .Vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {11339 .vector => switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
11340 .Float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {11340 .float => switch (lhs_ty.childType(zcu).floatBits(self.target.*)) {
11341 32 => switch (lhs_ty.vectorLen(zcu)) {11341 32 => switch (lhs_ty.vectorLen(zcu)) {
11342 1...4 => ._ps,11342 1...4 => ._ps,
11343 else => null,11343 else => null,
...@@ -11362,7 +11362,7 @@ fn genBinOp(...@@ -11362,7 +11362,7 @@ fn genBinOp(
11362 },11362 },
11363 .cmp_lt, .cmp_lte, .cmp_eq, .cmp_gte, .cmp_gt, .cmp_neq => {11363 .cmp_lt, .cmp_lte, .cmp_eq, .cmp_gte, .cmp_gt, .cmp_neq => {
11364 switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {11364 switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
11365 .Int => switch (air_tag) {11365 .int => switch (air_tag) {
11366 .cmp_lt,11366 .cmp_lt,
11367 .cmp_eq,11367 .cmp_eq,
11368 .cmp_gt,11368 .cmp_gt,
...@@ -11396,7 +11396,7 @@ fn genBinOp(...@@ -11396,7 +11396,7 @@ fn genBinOp(
11396 },11396 },
11397 else => unreachable,11397 else => unreachable,
11398 },11398 },
11399 .Float => {},11399 .float => {},
11400 else => unreachable,11400 else => unreachable,
11401 }11401 }
1140211402
...@@ -12268,8 +12268,8 @@ fn genCall(self: *Self, info: union(enum) {...@@ -12268,8 +12268,8 @@ fn genCall(self: *Self, info: union(enum) {
12268 .air => |callee| fn_info: {12268 .air => |callee| fn_info: {
12269 const callee_ty = self.typeOf(callee);12269 const callee_ty = self.typeOf(callee);
12270 break :fn_info switch (callee_ty.zigTypeTag(zcu)) {12270 break :fn_info switch (callee_ty.zigTypeTag(zcu)) {
12271 .Fn => callee_ty,12271 .@"fn" => callee_ty,
12272 .Pointer => callee_ty.childType(zcu),12272 .pointer => callee_ty.childType(zcu),
12273 else => unreachable,12273 else => unreachable,
12274 };12274 };
12275 },12275 },
...@@ -12544,7 +12544,7 @@ fn genCall(self: *Self, info: union(enum) {...@@ -12544,7 +12544,7 @@ fn genCall(self: *Self, info: union(enum) {
12544 else => return self.fail("TODO implement calling bitcasted functions", .{}),12544 else => return self.fail("TODO implement calling bitcasted functions", .{}),
12545 }12545 }
12546 } else {12546 } else {
12547 assert(self.typeOf(callee).zigTypeTag(zcu) == .Pointer);12547 assert(self.typeOf(callee).zigTypeTag(zcu) == .pointer);
12548 try self.genSetReg(.rax, Type.usize, .{ .air_ref = callee }, .{});12548 try self.genSetReg(.rax, Type.usize, .{ .air_ref = callee }, .{});
12549 try self.asmRegister(.{ ._, .call }, .rax);12549 try self.asmRegister(.{ ._, .call }, .rax);
12550 },12550 },
...@@ -12650,7 +12650,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -12650,7 +12650,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
12650 defer for (rhs_locks) |rhs_lock| if (rhs_lock) |lock| self.register_manager.unlockReg(lock);12650 defer for (rhs_locks) |rhs_lock| if (rhs_lock) |lock| self.register_manager.unlockReg(lock);
1265112651
12652 switch (ty.zigTypeTag(zcu)) {12652 switch (ty.zigTypeTag(zcu)) {
12653 .Float => {12653 .float => {
12654 const float_bits = ty.floatBits(self.target.*);12654 const float_bits = ty.floatBits(self.target.*);
12655 if (switch (float_bits) {12655 if (switch (float_bits) {
12656 16 => !self.hasFeature(.f16c),12656 16 => !self.hasFeature(.f16c),
...@@ -12685,7 +12685,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -12685,7 +12685,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
12685 };12685 };
12686 }12686 }
12687 },12687 },
12688 .Optional => if (!ty.optionalReprIsPayload(zcu)) {12688 .optional => if (!ty.optionalReprIsPayload(zcu)) {
12689 const opt_ty = ty;12689 const opt_ty = ty;
12690 const opt_abi_size: u31 = @intCast(opt_ty.abiSize(zcu));12690 const opt_abi_size: u31 = @intCast(opt_ty.abiSize(zcu));
12691 ty = opt_ty.optionalChild(zcu);12691 ty = opt_ty.optionalChild(zcu);
...@@ -12982,7 +12982,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {...@@ -12982,7 +12982,7 @@ fn airCmp(self: *Self, inst: Air.Inst.Index, op: math.CompareOperator) !void {
12982 },12982 },
12983 );12983 );
12984 },12984 },
12985 .Float => {12985 .float => {
12986 const flipped = switch (op) {12986 const flipped = switch (op) {
12987 .lt, .lte => true,12987 .lt, .lte => true,
12988 .eq, .gte, .gt, .neq => false,12988 .eq, .gte, .gt, .neq => false,
...@@ -14659,7 +14659,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo...@@ -14659,7 +14659,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo
14659 else => {},14659 else => {},
14660 }14660 }
14661 },14661 },
14662 .Float => switch (ty.floatBits(self.target.*)) {14662 .float => switch (ty.floatBits(self.target.*)) {
14663 16 => return if (self.hasFeature(.avx)) .{ .vex_insert_extract = .{14663 16 => return if (self.hasFeature(.avx)) .{ .vex_insert_extract = .{
14664 .insert = .{ .vp_w, .insr },14664 .insert = .{ .vp_w, .insr },
14665 .extract = .{ .vp_w, .extr },14665 .extract = .{ .vp_w, .extr },
...@@ -14680,15 +14680,15 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo...@@ -14680,15 +14680,15 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo
14680 else if (aligned) .{ ._, .movdqa } else .{ ._, .movdqu } },14680 else if (aligned) .{ ._, .movdqa } else .{ ._, .movdqu } },
14681 else => {},14681 else => {},
14682 },14682 },
14683 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {14683 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
14684 .Bool => switch (ty.vectorLen(zcu)) {14684 .bool => switch (ty.vectorLen(zcu)) {
14685 33...64 => return .{ .move = if (self.hasFeature(.avx))14685 33...64 => return .{ .move = if (self.hasFeature(.avx))
14686 .{ .v_q, .mov }14686 .{ .v_q, .mov }
14687 else14687 else
14688 .{ ._q, .mov } },14688 .{ ._q, .mov } },
14689 else => {},14689 else => {},
14690 },14690 },
14691 .Int => switch (ty.childType(zcu).intInfo(zcu).bits) {14691 .int => switch (ty.childType(zcu).intInfo(zcu).bits) {
14692 1...8 => switch (ty.vectorLen(zcu)) {14692 1...8 => switch (ty.vectorLen(zcu)) {
14693 1...16 => return .{ .move = if (self.hasFeature(.avx))14693 1...16 => return .{ .move = if (self.hasFeature(.avx))
14694 if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu }14694 if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu }
...@@ -14754,7 +14754,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo...@@ -14754,7 +14754,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo
14754 },14754 },
14755 else => {},14755 else => {},
14756 },14756 },
14757 .Pointer, .Optional => if (ty.childType(zcu).isPtrAtRuntime(zcu))14757 .pointer, .optional => if (ty.childType(zcu).isPtrAtRuntime(zcu))
14758 switch (ty.vectorLen(zcu)) {14758 switch (ty.vectorLen(zcu)) {
14759 1...2 => return .{ .move = if (self.hasFeature(.avx))14759 1...2 => return .{ .move = if (self.hasFeature(.avx))
14760 if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu }14760 if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu }
...@@ -14768,7 +14768,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo...@@ -14768,7 +14768,7 @@ fn moveStrategy(self: *Self, ty: Type, class: Register.Class, aligned: bool) !Mo
14768 }14768 }
14769 else14769 else
14770 unreachable,14770 unreachable,
14771 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {14771 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
14772 16 => switch (ty.vectorLen(zcu)) {14772 16 => switch (ty.vectorLen(zcu)) {
14773 1...8 => return .{ .move = if (self.hasFeature(.avx))14773 1...8 => return .{ .move = if (self.hasFeature(.avx))
14774 if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu }14774 if (aligned) .{ .v_, .movdqa } else .{ .v_, .movdqu }
...@@ -15072,7 +15072,7 @@ fn genSetReg(...@@ -15072,7 +15072,7 @@ fn genSetReg(
15072 17...32 => if (self.hasFeature(.avx)) .{ .v_, .movdqa } else null,15072 17...32 => if (self.hasFeature(.avx)) .{ .v_, .movdqa } else null,
15073 else => null,15073 else => null,
15074 },15074 },
15075 .Float => switch (ty.scalarType(zcu).floatBits(self.target.*)) {15075 .float => switch (ty.scalarType(zcu).floatBits(self.target.*)) {
15076 16, 128 => switch (abi_size) {15076 16, 128 => switch (abi_size) {
15077 2...16 => if (self.hasFeature(.avx))15077 2...16 => if (self.hasFeature(.avx))
15078 .{ .v_, .movdqa }15078 .{ .v_, .movdqa }
...@@ -15368,7 +15368,7 @@ fn genSetMem(...@@ -15368,7 +15368,7 @@ fn genSetMem(
15368 }15368 }
15369 },15369 },
15370 .register_overflow => |ro| switch (ty.zigTypeTag(zcu)) {15370 .register_overflow => |ro| switch (ty.zigTypeTag(zcu)) {
15371 .Struct => {15371 .@"struct" => {
15372 try self.genSetMem(15372 try self.genSetMem(
15373 base,15373 base,
15374 disp + @as(i32, @intCast(ty.structFieldOffset(0, zcu))),15374 disp + @as(i32, @intCast(ty.structFieldOffset(0, zcu))),
...@@ -15384,7 +15384,7 @@ fn genSetMem(...@@ -15384,7 +15384,7 @@ fn genSetMem(
15384 opts,15384 opts,
15385 );15385 );
15386 },15386 },
15387 .Optional => {15387 .optional => {
15388 assert(!ty.optionalReprIsPayload(zcu));15388 assert(!ty.optionalReprIsPayload(zcu));
15389 const child_ty = ty.optionalChild(zcu);15389 const child_ty = ty.optionalChild(zcu);
15390 try self.genSetMem(base, disp, child_ty, .{ .register = ro.reg }, opts);15390 try self.genSetMem(base, disp, child_ty, .{ .register = ro.reg }, opts);
...@@ -15768,7 +15768,7 @@ fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {...@@ -15768,7 +15768,7 @@ fn airFloatFromInt(self: *Self, inst: Air.Inst.Index) !void {
15768 defer self.register_manager.unlockReg(dst_lock);15768 defer self.register_manager.unlockReg(dst_lock);
1576915769
15770 const mir_tag = @as(?Mir.Inst.FixedTag, switch (dst_ty.zigTypeTag(zcu)) {15770 const mir_tag = @as(?Mir.Inst.FixedTag, switch (dst_ty.zigTypeTag(zcu)) {
15771 .Float => switch (dst_ty.floatBits(self.target.*)) {15771 .float => switch (dst_ty.floatBits(self.target.*)) {
15772 32 => if (self.hasFeature(.avx)) .{ .v_ss, .cvtsi2 } else .{ ._ss, .cvtsi2 },15772 32 => if (self.hasFeature(.avx)) .{ .v_ss, .cvtsi2 } else .{ ._ss, .cvtsi2 },
15773 64 => if (self.hasFeature(.avx)) .{ .v_sd, .cvtsi2 } else .{ ._sd, .cvtsi2 },15773 64 => if (self.hasFeature(.avx)) .{ .v_sd, .cvtsi2 } else .{ ._sd, .cvtsi2 },
15774 16, 80, 128 => null,15774 16, 80, 128 => null,
...@@ -16702,7 +16702,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -16702,7 +16702,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
16702 const result: MCValue = result: {16702 const result: MCValue = result: {
16703 switch (scalar_ty.zigTypeTag(zcu)) {16703 switch (scalar_ty.zigTypeTag(zcu)) {
16704 else => {},16704 else => {},
16705 .Bool => {16705 .bool => {
16706 const regs =16706 const regs =
16707 try self.register_manager.allocRegs(2, .{ inst, null }, abi.RegisterClass.gp);16707 try self.register_manager.allocRegs(2, .{ inst, null }, abi.RegisterClass.gp);
16708 const reg_locks = self.register_manager.lockRegsAssumeUnused(2, regs);16708 const reg_locks = self.register_manager.lockRegsAssumeUnused(2, regs);
...@@ -16742,7 +16742,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -16742,7 +16742,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
16742 );16742 );
16743 break :result .{ .register = regs[0] };16743 break :result .{ .register = regs[0] };
16744 },16744 },
16745 .Int => if (self.hasFeature(.avx2)) avx2: {16745 .int => if (self.hasFeature(.avx2)) avx2: {
16746 const mir_tag = @as(?Mir.Inst.FixedTag, switch (scalar_ty.intInfo(zcu).bits) {16746 const mir_tag = @as(?Mir.Inst.FixedTag, switch (scalar_ty.intInfo(zcu).bits) {
16747 else => null,16747 else => null,
16748 1...8 => switch (vector_len) {16748 1...8 => switch (vector_len) {
...@@ -16835,7 +16835,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -16835,7 +16835,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
16835 );16835 );
16836 break :result .{ .register = dst_reg };16836 break :result .{ .register = dst_reg };
16837 },16837 },
16838 .Float => switch (scalar_ty.floatBits(self.target.*)) {16838 .float => switch (scalar_ty.floatBits(self.target.*)) {
16839 32 => switch (vector_len) {16839 32 => switch (vector_len) {
16840 1 => {16840 1 => {
16841 const src_mcv = try self.resolveInst(ty_op.operand);16841 const src_mcv = try self.resolveInst(ty_op.operand);
...@@ -17264,7 +17264,7 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void {...@@ -17264,7 +17264,7 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void {
1726417264
17265 const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.childType(zcu).zigTypeTag(zcu)) {17265 const mir_tag = @as(?Mir.Inst.FixedTag, switch (ty.childType(zcu).zigTypeTag(zcu)) {
17266 else => null,17266 else => null,
17267 .Int => switch (abi_size) {17267 .int => switch (abi_size) {
17268 0 => unreachable,17268 0 => unreachable,
17269 1...16 => if (has_avx)17269 1...16 => if (has_avx)
17270 .{ .vp_b, .blendv }17270 .{ .vp_b, .blendv }
...@@ -17278,7 +17278,7 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void {...@@ -17278,7 +17278,7 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void {
17278 null,17278 null,
17279 else => null,17279 else => null,
17280 },17280 },
17281 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {17281 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
17282 else => unreachable,17282 else => unreachable,
17283 16, 80, 128 => null,17283 16, 80, 128 => null,
17284 32 => switch (vec_len) {17284 32 => switch (vec_len) {
...@@ -17334,8 +17334,8 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void {...@@ -17334,8 +17334,8 @@ fn airSelect(self: *Self, inst: Air.Inst.Index) !void {
17334 ) else {17334 ) else {
17335 const mir_fixes = @as(?Mir.Inst.Fixes, switch (elem_ty.zigTypeTag(zcu)) {17335 const mir_fixes = @as(?Mir.Inst.Fixes, switch (elem_ty.zigTypeTag(zcu)) {
17336 else => null,17336 else => null,
17337 .Int => .p_,17337 .int => .p_,
17338 .Float => switch (elem_ty.floatBits(self.target.*)) {17338 .float => switch (elem_ty.floatBits(self.target.*)) {
17339 32 => ._ps,17339 32 => ._ps,
17340 64 => ._pd,17340 64 => ._pd,
17341 16, 80, 128 => null,17341 16, 80, 128 => null,
...@@ -18132,8 +18132,8 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {...@@ -18132,8 +18132,8 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {
18132 if (has_avx) try self.asmRegisterRegisterRegister(18132 if (has_avx) try self.asmRegisterRegisterRegister(
18133 .{ switch (elem_ty.zigTypeTag(zcu)) {18133 .{ switch (elem_ty.zigTypeTag(zcu)) {
18134 else => break :result null,18134 else => break :result null,
18135 .Int => .vp_,18135 .int => .vp_,
18136 .Float => switch (elem_ty.floatBits(self.target.*)) {18136 .float => switch (elem_ty.floatBits(self.target.*)) {
18137 32 => .v_ps,18137 32 => .v_ps,
18138 64 => .v_pd,18138 64 => .v_pd,
18139 16, 80, 128 => break :result null,18139 16, 80, 128 => break :result null,
...@@ -18146,8 +18146,8 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {...@@ -18146,8 +18146,8 @@ fn airShuffle(self: *Self, inst: Air.Inst.Index) !void {
18146 ) else try self.asmRegisterRegister(18146 ) else try self.asmRegisterRegister(
18147 .{ switch (elem_ty.zigTypeTag(zcu)) {18147 .{ switch (elem_ty.zigTypeTag(zcu)) {
18148 else => break :result null,18148 else => break :result null,
18149 .Int => .p_,18149 .int => .p_,
18150 .Float => switch (elem_ty.floatBits(self.target.*)) {18150 .float => switch (elem_ty.floatBits(self.target.*)) {
18151 32 => ._ps,18151 32 => ._ps,
18152 64 => ._pd,18152 64 => ._pd,
18153 16, 80, 128 => break :result null,18153 16, 80, 128 => break :result null,
...@@ -18235,7 +18235,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -18235,7 +18235,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
18235 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);18235 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);
18236 const result: MCValue = result: {18236 const result: MCValue = result: {
18237 switch (result_ty.zigTypeTag(zcu)) {18237 switch (result_ty.zigTypeTag(zcu)) {
18238 .Struct => {18238 .@"struct" => {
18239 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));18239 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, zcu));
18240 if (result_ty.containerLayout(zcu) == .@"packed") {18240 if (result_ty.containerLayout(zcu) == .@"packed") {
18241 const struct_obj = zcu.typeToStruct(result_ty).?;18241 const struct_obj = zcu.typeToStruct(result_ty).?;
...@@ -18342,7 +18342,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -18342,7 +18342,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
18342 }18342 }
18343 break :result .{ .load_frame = .{ .index = frame_index } };18343 break :result .{ .load_frame = .{ .index = frame_index } };
18344 },18344 },
18345 .Array, .Vector => {18345 .array, .vector => {
18346 const elem_ty = result_ty.childType(zcu);18346 const elem_ty = result_ty.childType(zcu);
18347 if (result_ty.isVector(zcu) and elem_ty.toIntern() == .bool_type) {18347 if (result_ty.isVector(zcu) and elem_ty.toIntern() == .bool_type) {
18348 const result_size: u32 = @intCast(result_ty.abiSize(zcu));18348 const result_size: u32 = @intCast(result_ty.abiSize(zcu));
...@@ -18483,7 +18483,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -18483,7 +18483,7 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
18483 32, 64 => !self.hasFeature(.fma),18483 32, 64 => !self.hasFeature(.fma),
18484 else => unreachable,18484 else => unreachable,
18485 }) {18485 }) {
18486 if (ty.zigTypeTag(zcu) != .Float) return self.fail("TODO implement airMulAdd for {}", .{18486 if (ty.zigTypeTag(zcu) != .float) return self.fail("TODO implement airMulAdd for {}", .{
18487 ty.fmt(pt),18487 ty.fmt(pt),
18488 });18488 });
1848918489
...@@ -18533,14 +18533,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -18533,14 +18533,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
18533 const mir_tag = @as(?Mir.Inst.FixedTag, if (mem.eql(u2, &order, &.{ 1, 3, 2 }) or18533 const mir_tag = @as(?Mir.Inst.FixedTag, if (mem.eql(u2, &order, &.{ 1, 3, 2 }) or
18534 mem.eql(u2, &order, &.{ 3, 1, 2 }))18534 mem.eql(u2, &order, &.{ 3, 1, 2 }))
18535 switch (ty.zigTypeTag(zcu)) {18535 switch (ty.zigTypeTag(zcu)) {
18536 .Float => switch (ty.floatBits(self.target.*)) {18536 .float => switch (ty.floatBits(self.target.*)) {
18537 32 => .{ .v_ss, .fmadd132 },18537 32 => .{ .v_ss, .fmadd132 },
18538 64 => .{ .v_sd, .fmadd132 },18538 64 => .{ .v_sd, .fmadd132 },
18539 16, 80, 128 => null,18539 16, 80, 128 => null,
18540 else => unreachable,18540 else => unreachable,
18541 },18541 },
18542 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {18542 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
18543 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {18543 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
18544 32 => switch (ty.vectorLen(zcu)) {18544 32 => switch (ty.vectorLen(zcu)) {
18545 1 => .{ .v_ss, .fmadd132 },18545 1 => .{ .v_ss, .fmadd132 },
18546 2...8 => .{ .v_ps, .fmadd132 },18546 2...8 => .{ .v_ps, .fmadd132 },
...@@ -18560,14 +18560,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -18560,14 +18560,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
18560 }18560 }
18561 else if (mem.eql(u2, &order, &.{ 2, 1, 3 }) or mem.eql(u2, &order, &.{ 1, 2, 3 }))18561 else if (mem.eql(u2, &order, &.{ 2, 1, 3 }) or mem.eql(u2, &order, &.{ 1, 2, 3 }))
18562 switch (ty.zigTypeTag(zcu)) {18562 switch (ty.zigTypeTag(zcu)) {
18563 .Float => switch (ty.floatBits(self.target.*)) {18563 .float => switch (ty.floatBits(self.target.*)) {
18564 32 => .{ .v_ss, .fmadd213 },18564 32 => .{ .v_ss, .fmadd213 },
18565 64 => .{ .v_sd, .fmadd213 },18565 64 => .{ .v_sd, .fmadd213 },
18566 16, 80, 128 => null,18566 16, 80, 128 => null,
18567 else => unreachable,18567 else => unreachable,
18568 },18568 },
18569 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {18569 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
18570 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {18570 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
18571 32 => switch (ty.vectorLen(zcu)) {18571 32 => switch (ty.vectorLen(zcu)) {
18572 1 => .{ .v_ss, .fmadd213 },18572 1 => .{ .v_ss, .fmadd213 },
18573 2...8 => .{ .v_ps, .fmadd213 },18573 2...8 => .{ .v_ps, .fmadd213 },
...@@ -18587,14 +18587,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {...@@ -18587,14 +18587,14 @@ fn airMulAdd(self: *Self, inst: Air.Inst.Index) !void {
18587 }18587 }
18588 else if (mem.eql(u2, &order, &.{ 2, 3, 1 }) or mem.eql(u2, &order, &.{ 3, 2, 1 }))18588 else if (mem.eql(u2, &order, &.{ 2, 3, 1 }) or mem.eql(u2, &order, &.{ 3, 2, 1 }))
18589 switch (ty.zigTypeTag(zcu)) {18589 switch (ty.zigTypeTag(zcu)) {
18590 .Float => switch (ty.floatBits(self.target.*)) {18590 .float => switch (ty.floatBits(self.target.*)) {
18591 32 => .{ .v_ss, .fmadd231 },18591 32 => .{ .v_ss, .fmadd231 },
18592 64 => .{ .v_sd, .fmadd231 },18592 64 => .{ .v_sd, .fmadd231 },
18593 16, 80, 128 => null,18593 16, 80, 128 => null,
18594 else => unreachable,18594 else => unreachable,
18595 },18595 },
18596 .Vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {18596 .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) {
18597 .Float => switch (ty.childType(zcu).floatBits(self.target.*)) {18597 .float => switch (ty.childType(zcu).floatBits(self.target.*)) {
18598 32 => switch (ty.vectorLen(zcu)) {18598 32 => switch (ty.vectorLen(zcu)) {
18599 1 => .{ .v_ss, .fmadd231 },18599 1 => .{ .v_ss, .fmadd231 },
18600 2...8 => .{ .v_ps, .fmadd231 },18600 2...8 => .{ .v_ps, .fmadd231 },
...@@ -18971,7 +18971,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) *InstTracking {...@@ -18971,7 +18971,7 @@ fn getResolvedInstValue(self: *Self, inst: Air.Inst.Index) *InstTracking {
18971/// and as a register.18971/// and as a register.
18972fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCValue {18972fn limitImmediateType(self: *Self, operand: Air.Inst.Ref, comptime T: type) !MCValue {
18973 const mcv = try self.resolveInst(operand);18973 const mcv = try self.resolveInst(operand);
18974 const ti = @typeInfo(T).Int;18974 const ti = @typeInfo(T).int;
18975 switch (mcv) {18975 switch (mcv) {
18976 .immediate => |imm| {18976 .immediate => |imm| {
18977 // This immediate is unsigned.18977 // This immediate is unsigned.
...@@ -19078,7 +19078,7 @@ fn resolveCallingConventionValues(...@@ -19078,7 +19078,7 @@ fn resolveCallingConventionValues(
19078 }19078 }
1907919079
19080 // Return values19080 // Return values
19081 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {19081 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
19082 result.return_value = InstTracking.init(.unreach);19082 result.return_value = InstTracking.init(.unreach);
19083 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {19083 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
19084 // TODO: is this even possible for C calling convention?19084 // TODO: is this even possible for C calling convention?
...@@ -19266,7 +19266,7 @@ fn resolveCallingConventionValues(...@@ -19266,7 +19266,7 @@ fn resolveCallingConventionValues(
19266 result.stack_align = .@"16";19266 result.stack_align = .@"16";
1926719267
19268 // Return values19268 // Return values
19269 if (ret_ty.zigTypeTag(zcu) == .NoReturn) {19269 if (ret_ty.zigTypeTag(zcu) == .noreturn) {
19270 result.return_value = InstTracking.init(.unreach);19270 result.return_value = InstTracking.init(.unreach);
19271 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {19271 } else if (!ret_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
19272 result.return_value = InstTracking.init(.none);19272 result.return_value = InstTracking.init(.none);
...@@ -19372,7 +19372,7 @@ fn memSize(self: *Self, ty: Type) Memory.Size {...@@ -19372,7 +19372,7 @@ fn memSize(self: *Self, ty: Type) Memory.Size {
19372 const pt = self.pt;19372 const pt = self.pt;
19373 const zcu = pt.zcu;19373 const zcu = pt.zcu;
19374 return switch (ty.zigTypeTag(zcu)) {19374 return switch (ty.zigTypeTag(zcu)) {
19375 .Float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)),19375 .float => Memory.Size.fromBitSize(ty.floatBits(self.target.*)),
19376 else => Memory.Size.fromSize(@intCast(ty.abiSize(zcu))),19376 else => Memory.Size.fromSize(@intCast(ty.abiSize(zcu))),
19377 };19377 };
19378}19378}
...@@ -19467,7 +19467,7 @@ fn regBitSize(self: *Self, ty: Type) u64 {...@@ -19467,7 +19467,7 @@ fn regBitSize(self: *Self, ty: Type) u64 {
19467 5...8 => 64,19467 5...8 => 64,
19468 else => unreachable,19468 else => unreachable,
19469 },19469 },
19470 .Float => switch (abi_size) {19470 .float => switch (abi_size) {
19471 1...16 => 128,19471 1...16 => 128,
19472 17...32 => 256,19472 17...32 => 256,
19473 else => unreachable,19473 else => unreachable,
src/arch/x86_64/Encoding.zig+3-3
...@@ -845,7 +845,7 @@ fn estimateInstructionLength(prefix: Prefix, encoding: Encoding, ops: []const Op...@@ -845,7 +845,7 @@ fn estimateInstructionLength(prefix: Prefix, encoding: Encoding, ops: []const Op
845845
846const mnemonic_to_encodings_map = init: {846const mnemonic_to_encodings_map = init: {
847 @setEvalBranchQuota(5_000);847 @setEvalBranchQuota(5_000);
848 const mnemonic_count = @typeInfo(Mnemonic).Enum.fields.len;848 const mnemonic_count = @typeInfo(Mnemonic).@"enum".fields.len;
849 var mnemonic_map: [mnemonic_count][]Data = .{&.{}} ** mnemonic_count;849 var mnemonic_map: [mnemonic_count][]Data = .{&.{}} ** mnemonic_count;
850 const encodings = @import("encodings.zig");850 const encodings = @import("encodings.zig");
851 for (encodings.table) |entry| mnemonic_map[@intFromEnum(entry[0])].len += 1;851 for (encodings.table) |entry| mnemonic_map[@intFromEnum(entry[0])].len += 1;
...@@ -856,8 +856,8 @@ const mnemonic_to_encodings_map = init: {...@@ -856,8 +856,8 @@ const mnemonic_to_encodings_map = init: {
856 storage_i += value.len;856 storage_i += value.len;
857 }857 }
858 var mnemonic_i: [mnemonic_count]usize = .{0} ** mnemonic_count;858 var mnemonic_i: [mnemonic_count]usize = .{0} ** mnemonic_count;
859 const ops_len = @typeInfo(std.meta.FieldType(Data, .ops)).Array.len;859 const ops_len = @typeInfo(std.meta.FieldType(Data, .ops)).array.len;
860 const opc_len = @typeInfo(std.meta.FieldType(Data, .opc)).Array.len;860 const opc_len = @typeInfo(std.meta.FieldType(Data, .opc)).array.len;
861 for (encodings.table) |entry| {861 for (encodings.table) |entry| {
862 const i = &mnemonic_i[@intFromEnum(entry[0])];862 const i = &mnemonic_i[@intFromEnum(entry[0])];
863 mnemonic_map[@intFromEnum(entry[0])][i.*] = .{863 mnemonic_map[@intFromEnum(entry[0])][i.*] = .{
src/arch/x86_64/Lower.zig+1-1
...@@ -571,7 +571,7 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {...@@ -571,7 +571,7 @@ fn generic(lower: *Lower, inst: Mir.Inst) Error!void {
571 @setEvalBranchQuota(2_000);571 @setEvalBranchQuota(2_000);
572572
573 comptime var max_len = 0;573 comptime var max_len = 0;
574 inline for (@typeInfo(Mnemonic).Enum.fields) |field| max_len = @max(field.name.len, max_len);574 inline for (@typeInfo(Mnemonic).@"enum".fields) |field| max_len = @max(field.name.len, max_len);
575 var buf: [max_len]u8 = undefined;575 var buf: [max_len]u8 = undefined;
576576
577 const fixes_name = @tagName(fixes);577 const fixes_name = @tagName(fixes);
src/arch/x86_64/Mir.zig+2-2
...@@ -1185,8 +1185,8 @@ pub const Memory = struct {...@@ -1185,8 +1185,8 @@ pub const Memory = struct {
1185 extra: u32,1185 extra: u32,
11861186
1187 pub const Info = packed struct(u32) {1187 pub const Info = packed struct(u32) {
1188 base: @typeInfo(bits.Memory.Base).Union.tag_type.?,1188 base: @typeInfo(bits.Memory.Base).@"union".tag_type.?,
1189 mod: @typeInfo(bits.Memory.Mod).Union.tag_type.?,1189 mod: @typeInfo(bits.Memory.Mod).@"union".tag_type.?,
1190 size: bits.Memory.Size,1190 size: bits.Memory.Size,
1191 index: Register,1191 index: Register,
1192 scale: bits.Memory.Scale,1192 scale: bits.Memory.Scale,
src/arch/x86_64/abi.zig+33-33
...@@ -54,26 +54,26 @@ pub fn classifyWindows(ty: Type, zcu: *Zcu) Class {...@@ -54,26 +54,26 @@ pub fn classifyWindows(ty: Type, zcu: *Zcu) Class {
54 // "Structs and unions of size 8, 16, 32, or 64 bits, and __m64 types, are passed54 // "Structs and unions of size 8, 16, 32, or 64 bits, and __m64 types, are passed
55 // as if they were integers of the same size."55 // as if they were integers of the same size."
56 switch (ty.zigTypeTag(zcu)) {56 switch (ty.zigTypeTag(zcu)) {
57 .Pointer,57 .pointer,
58 .Int,58 .int,
59 .Bool,59 .bool,
60 .Enum,60 .@"enum",
61 .Void,61 .void,
62 .NoReturn,62 .noreturn,
63 .ErrorSet,63 .error_set,
64 .Struct,64 .@"struct",
65 .Union,65 .@"union",
66 .Optional,66 .optional,
67 .Array,67 .array,
68 .ErrorUnion,68 .error_union,
69 .AnyFrame,69 .@"anyframe",
70 .Frame,70 .frame,
71 => switch (ty.abiSize(zcu)) {71 => switch (ty.abiSize(zcu)) {
72 0 => unreachable,72 0 => unreachable,
73 1, 2, 4, 8 => return .integer,73 1, 2, 4, 8 => return .integer,
74 else => switch (ty.zigTypeTag(zcu)) {74 else => switch (ty.zigTypeTag(zcu)) {
75 .Int => return .win_i128,75 .int => return .win_i128,
76 .Struct, .Union => if (ty.containerLayout(zcu) == .@"packed") {76 .@"struct", .@"union" => if (ty.containerLayout(zcu) == .@"packed") {
77 return .win_i128;77 return .win_i128;
78 } else {78 } else {
79 return .memory;79 return .memory;
...@@ -82,16 +82,16 @@ pub fn classifyWindows(ty: Type, zcu: *Zcu) Class {...@@ -82,16 +82,16 @@ pub fn classifyWindows(ty: Type, zcu: *Zcu) Class {
82 },82 },
83 },83 },
8484
85 .Float, .Vector => return .sse,85 .float, .vector => return .sse,
8686
87 .Type,87 .type,
88 .ComptimeFloat,88 .comptime_float,
89 .ComptimeInt,89 .comptime_int,
90 .Undefined,90 .undefined,
91 .Null,91 .null,
92 .Fn,92 .@"fn",
93 .Opaque,93 .@"opaque",
94 .EnumLiteral,94 .enum_literal,
95 => unreachable,95 => unreachable,
96 }96 }
97}97}
...@@ -107,7 +107,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -107,7 +107,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
107 };107 };
108 var result = [1]Class{.none} ** 8;108 var result = [1]Class{.none} ** 8;
109 switch (ty.zigTypeTag(zcu)) {109 switch (ty.zigTypeTag(zcu)) {
110 .Pointer => switch (ty.ptrSize(zcu)) {110 .pointer => switch (ty.ptrSize(zcu)) {
111 .Slice => {111 .Slice => {
112 result[0] = .integer;112 result[0] = .integer;
113 result[1] = .integer;113 result[1] = .integer;
...@@ -118,7 +118,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -118,7 +118,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
118 return result;118 return result;
119 },119 },
120 },120 },
121 .Int, .Enum, .ErrorSet => {121 .int, .@"enum", .error_set => {
122 const bits = ty.intInfo(zcu).bits;122 const bits = ty.intInfo(zcu).bits;
123 if (bits <= 64) {123 if (bits <= 64) {
124 result[0] = .integer;124 result[0] = .integer;
...@@ -144,11 +144,11 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -144,11 +144,11 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
144 }144 }
145 return memory_class;145 return memory_class;
146 },146 },
147 .Bool, .Void, .NoReturn => {147 .bool, .void, .noreturn => {
148 result[0] = .integer;148 result[0] = .integer;
149 return result;149 return result;
150 },150 },
151 .Float => switch (ty.floatBits(target)) {151 .float => switch (ty.floatBits(target)) {
152 16 => {152 16 => {
153 if (ctx == .field) {153 if (ctx == .field) {
154 result[0] = .memory;154 result[0] = .memory;
...@@ -184,7 +184,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -184,7 +184,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
184 },184 },
185 else => unreachable,185 else => unreachable,
186 },186 },
187 .Vector => {187 .vector => {
188 const elem_ty = ty.childType(zcu);188 const elem_ty = ty.childType(zcu);
189 const bits = elem_ty.bitSize(zcu) * ty.arrayLen(zcu);189 const bits = elem_ty.bitSize(zcu) * ty.arrayLen(zcu);
190 if (elem_ty.toIntern() == .bool_type) {190 if (elem_ty.toIntern() == .bool_type) {
...@@ -249,14 +249,14 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -249,14 +249,14 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
249 };249 };
250 return memory_class;250 return memory_class;
251 },251 },
252 .Optional => {252 .optional => {
253 if (ty.isPtrLikeOptional(zcu)) {253 if (ty.isPtrLikeOptional(zcu)) {
254 result[0] = .integer;254 result[0] = .integer;
255 return result;255 return result;
256 }256 }
257 return memory_class;257 return memory_class;
258 },258 },
259 .Struct, .Union => {259 .@"struct", .@"union" => {
260 // "If the size of an object is larger than eight eightbytes, or260 // "If the size of an object is larger than eight eightbytes, or
261 // it contains unaligned fields, it has class MEMORY"261 // it contains unaligned fields, it has class MEMORY"
262 // "If the size of the aggregate exceeds a single eightbyte, each is classified262 // "If the size of the aggregate exceeds a single eightbyte, each is classified
...@@ -305,7 +305,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8...@@ -305,7 +305,7 @@ pub fn classifySystemV(ty: Type, zcu: *Zcu, target: std.Target, ctx: Context) [8
305 }305 }
306 return result;306 return result;
307 },307 },
308 .Array => {308 .array => {
309 const ty_size = ty.abiSize(zcu);309 const ty_size = ty.abiSize(zcu);
310 if (ty_size <= 8) {310 if (ty_size <= 8) {
311 result[0] = .integer;311 result[0] = .integer;
src/arch/x86_64/bits.zig+2-2
...@@ -423,7 +423,7 @@ pub const FrameIndex = enum(u32) {...@@ -423,7 +423,7 @@ pub const FrameIndex = enum(u32) {
423 // Other indices are used for local variable stack slots423 // Other indices are used for local variable stack slots
424 _,424 _,
425425
426 pub const named_count = @typeInfo(FrameIndex).Enum.fields.len;426 pub const named_count = @typeInfo(FrameIndex).@"enum".fields.len;
427427
428 pub fn isNamed(fi: FrameIndex) bool {428 pub fn isNamed(fi: FrameIndex) bool {
429 return @intFromEnum(fi) < named_count;429 return @intFromEnum(fi) < named_count;
...@@ -463,7 +463,7 @@ pub const Memory = struct {...@@ -463,7 +463,7 @@ pub const Memory = struct {
463 frame: FrameIndex,463 frame: FrameIndex,
464 reloc: u32,464 reloc: u32,
465465
466 pub const Tag = @typeInfo(Base).Union.tag_type.?;466 pub const Tag = @typeInfo(Base).@"union".tag_type.?;
467467
468 pub fn isExtended(self: Base) bool {468 pub fn isExtended(self: Base) bool {
469 return switch (self) {469 return switch (self) {
src/arch/x86_64/encoder.zig+4-4
...@@ -2262,7 +2262,7 @@ const Assembler = struct {...@@ -2262,7 +2262,7 @@ const Assembler = struct {
2262 }2262 }
22632263
2264 fn mnemonicFromString(bytes: []const u8) ?Instruction.Mnemonic {2264 fn mnemonicFromString(bytes: []const u8) ?Instruction.Mnemonic {
2265 const ti = @typeInfo(Instruction.Mnemonic).Enum;2265 const ti = @typeInfo(Instruction.Mnemonic).@"enum";
2266 inline for (ti.fields) |field| {2266 inline for (ti.fields) |field| {
2267 if (std.mem.eql(u8, bytes, field.name)) {2267 if (std.mem.eql(u8, bytes, field.name)) {
2268 return @field(Instruction.Mnemonic, field.name);2268 return @field(Instruction.Mnemonic, field.name);
...@@ -2278,7 +2278,7 @@ const Assembler = struct {...@@ -2278,7 +2278,7 @@ const Assembler = struct {
2278 _ = try as.expect(.comma);2278 _ = try as.expect(.comma);
2279 try as.skip(1, .{.space});2279 try as.skip(1, .{.space});
2280 }2280 }
2281 if (@typeInfo(@TypeOf(cond)) != .EnumLiteral) {2281 if (@typeInfo(@TypeOf(cond)) != .enum_literal) {
2282 @compileError("invalid condition in the rule: " ++ @typeName(@TypeOf(cond)));2282 @compileError("invalid condition in the rule: " ++ @typeName(@TypeOf(cond)));
2283 }2283 }
2284 switch (cond) {2284 switch (cond) {
...@@ -2315,7 +2315,7 @@ const Assembler = struct {...@@ -2315,7 +2315,7 @@ const Assembler = struct {
2315 }2315 }
23162316
2317 fn registerFromString(bytes: []const u8) ?Register {2317 fn registerFromString(bytes: []const u8) ?Register {
2318 const ti = @typeInfo(Register).Enum;2318 const ti = @typeInfo(Register).@"enum";
2319 inline for (ti.fields) |field| {2319 inline for (ti.fields) |field| {
2320 if (std.mem.eql(u8, bytes, field.name)) {2320 if (std.mem.eql(u8, bytes, field.name)) {
2321 return @field(Register, field.name);2321 return @field(Register, field.name);
...@@ -2405,7 +2405,7 @@ const Assembler = struct {...@@ -2405,7 +2405,7 @@ const Assembler = struct {
2405 fn parseMemoryRule(as: *Assembler, rule: anytype) ParseError!MemoryParseResult {2405 fn parseMemoryRule(as: *Assembler, rule: anytype) ParseError!MemoryParseResult {
2406 var res: MemoryParseResult = .{};2406 var res: MemoryParseResult = .{};
2407 inline for (rule, 0..) |cond, i| {2407 inline for (rule, 0..) |cond, i| {
2408 if (@typeInfo(@TypeOf(cond)) != .EnumLiteral) {2408 if (@typeInfo(@TypeOf(cond)) != .enum_literal) {
2409 @compileError("unsupported condition type in the rule: " ++ @typeName(@TypeOf(cond)));2409 @compileError("unsupported condition type in the rule: " ++ @typeName(@TypeOf(cond)));
2410 }2410 }
2411 switch (cond) {2411 switch (cond) {
src/codegen.zig+25-25
...@@ -113,8 +113,8 @@ pub fn generateLazyFunction(...@@ -113,8 +113,8 @@ pub fn generateLazyFunction(
113113
114fn writeFloat(comptime F: type, f: F, target: std.Target, endian: std.builtin.Endian, code: []u8) void {114fn writeFloat(comptime F: type, f: F, target: std.Target, endian: std.builtin.Endian, code: []u8) void {
115 _ = target;115 _ = target;
116 const bits = @typeInfo(F).Float.bits;116 const bits = @typeInfo(F).float.bits;
117 const Int = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = bits } });117 const Int = @Type(.{ .int = .{ .signedness = .unsigned, .bits = bits } });
118 const int: Int = @bitCast(f);118 const int: Int = @bitCast(f);
119 mem.writeInt(Int, code[0..@divExact(bits, 8)], int, endian);119 mem.writeInt(Int, code[0..@divExact(bits, 8)], int, endian);
120}120}
...@@ -167,7 +167,7 @@ pub fn generateLazySymbol(...@@ -167,7 +167,7 @@ pub fn generateLazySymbol(
167 }167 }
168 mem.writeInt(u32, code.items[offset..][0..4], @intCast(code.items.len), endian);168 mem.writeInt(u32, code.items[offset..][0..4], @intCast(code.items.len), endian);
169 return Result.ok;169 return Result.ok;
170 } else if (Type.fromInterned(lazy_sym.ty).zigTypeTag(pt.zcu) == .Enum) {170 } else if (Type.fromInterned(lazy_sym.ty).zigTypeTag(pt.zcu) == .@"enum") {
171 alignment.* = .@"1";171 alignment.* = .@"1";
172 const enum_ty = Type.fromInterned(lazy_sym.ty);172 const enum_ty = Type.fromInterned(lazy_sym.ty);
173 const tag_names = enum_ty.enumFields(pt.zcu);173 const tag_names = enum_ty.enumFields(pt.zcu);
...@@ -519,7 +519,7 @@ pub fn generateSymbol(...@@ -519,7 +519,7 @@ pub fn generateSymbol(
519519
520 // pointer may point to a decl which must be marked used520 // pointer may point to a decl which must be marked used
521 // but can also result in a relocation. Therefore we handle those separately.521 // but can also result in a relocation. Therefore we handle those separately.
522 if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .Pointer) {522 if (Type.fromInterned(field_ty).zigTypeTag(zcu) == .pointer) {
523 const field_size = math.cast(usize, Type.fromInterned(field_ty).abiSize(zcu)) orelse523 const field_size = math.cast(usize, Type.fromInterned(field_ty).abiSize(zcu)) orelse
524 return error.Overflow;524 return error.Overflow;
525 var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size);525 var tmp_list = try std.ArrayList(u8).initCapacity(code.allocator, field_size);
...@@ -678,7 +678,7 @@ fn lowerPtr(...@@ -678,7 +678,7 @@ fn lowerPtr(
678 const base_ptr = Value.fromInterned(field.base);678 const base_ptr = Value.fromInterned(field.base);
679 const base_ty = base_ptr.typeOf(zcu).childType(zcu);679 const base_ty = base_ptr.typeOf(zcu).childType(zcu);
680 const field_off: u64 = switch (base_ty.zigTypeTag(zcu)) {680 const field_off: u64 = switch (base_ty.zigTypeTag(zcu)) {
681 .Pointer => off: {681 .pointer => off: {
682 assert(base_ty.isSlice(zcu));682 assert(base_ty.isSlice(zcu));
683 break :off switch (field.index) {683 break :off switch (field.index) {
684 Value.slice_ptr_index => 0,684 Value.slice_ptr_index => 0,
...@@ -686,7 +686,7 @@ fn lowerPtr(...@@ -686,7 +686,7 @@ fn lowerPtr(
686 else => unreachable,686 else => unreachable,
687 };687 };
688 },688 },
689 .Struct, .Union => switch (base_ty.containerLayout(zcu)) {689 .@"struct", .@"union" => switch (base_ty.containerLayout(zcu)) {
690 .auto => base_ty.structFieldOffset(@intCast(field.index), zcu),690 .auto => base_ty.structFieldOffset(@intCast(field.index), zcu),
691 .@"extern", .@"packed" => unreachable,691 .@"extern", .@"packed" => unreachable,
692 },692 },
...@@ -721,7 +721,7 @@ fn lowerUavRef(...@@ -721,7 +721,7 @@ fn lowerUavRef(
721 const uav_val = uav.val;721 const uav_val = uav.val;
722 const uav_ty = Type.fromInterned(ip.typeOf(uav_val));722 const uav_ty = Type.fromInterned(ip.typeOf(uav_val));
723 log.debug("lowerUavRef: ty = {}", .{uav_ty.fmt(pt)});723 log.debug("lowerUavRef: ty = {}", .{uav_ty.fmt(pt)});
724 const is_fn_body = uav_ty.zigTypeTag(zcu) == .Fn;724 const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn";
725 if (!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) {725 if (!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) {
726 try code.appendNTimes(0xaa, ptr_width_bytes);726 try code.appendNTimes(0xaa, ptr_width_bytes);
727 return Result.ok;727 return Result.ok;
...@@ -768,7 +768,7 @@ fn lowerNavRef(...@@ -768,7 +768,7 @@ fn lowerNavRef(
768768
769 const ptr_width = target.ptrBitWidth();769 const ptr_width = target.ptrBitWidth();
770 const nav_ty = Type.fromInterned(ip.getNav(nav_index).typeOf(ip));770 const nav_ty = Type.fromInterned(ip.getNav(nav_index).typeOf(ip));
771 const is_fn_body = nav_ty.zigTypeTag(zcu) == .Fn;771 const is_fn_body = nav_ty.zigTypeTag(zcu) == .@"fn";
772 if (!is_fn_body and !nav_ty.hasRuntimeBits(zcu)) {772 if (!is_fn_body and !nav_ty.hasRuntimeBits(zcu)) {
773 try code.appendNTimes(0xaa, @divExact(ptr_width, 8));773 try code.appendNTimes(0xaa, @divExact(ptr_width, 8));
774 return Result.ok;774 return Result.ok;
...@@ -880,7 +880,7 @@ fn genNavRef(...@@ -880,7 +880,7 @@ fn genNavRef(
880 if (zcu.typeToFunc(fn_ty).?.is_generic) {880 if (zcu.typeToFunc(fn_ty).?.is_generic) {
881 return .{ .mcv = .{ .immediate = fn_ty.abiAlignment(zcu).toByteUnits().? } };881 return .{ .mcv = .{ .immediate = fn_ty.abiAlignment(zcu).toByteUnits().? } };
882 }882 }
883 } else if (ty.zigTypeTag(zcu) == .Pointer) {883 } else if (ty.zigTypeTag(zcu) == .pointer) {
884 const elem_ty = ty.elemType2(zcu);884 const elem_ty = ty.elemType2(zcu);
885 if (!elem_ty.hasRuntimeBits(zcu)) {885 if (!elem_ty.hasRuntimeBits(zcu)) {
886 return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? } };886 return .{ .mcv = .{ .immediate = elem_ty.abiAlignment(zcu).toByteUnits().? } };
...@@ -955,8 +955,8 @@ pub fn genTypedValue(...@@ -955,8 +955,8 @@ pub fn genTypedValue(
955 if (val.isUndef(zcu)) return .{ .mcv = .undef };955 if (val.isUndef(zcu)) return .{ .mcv = .undef };
956956
957 switch (ty.zigTypeTag(zcu)) {957 switch (ty.zigTypeTag(zcu)) {
958 .Void => return .{ .mcv = .none },958 .void => return .{ .mcv = .none },
959 .Pointer => switch (ty.ptrSize(zcu)) {959 .pointer => switch (ty.ptrSize(zcu)) {
960 .Slice => {},960 .Slice => {},
961 else => switch (val.toIntern()) {961 else => switch (val.toIntern()) {
962 .null_value => {962 .null_value => {
...@@ -991,7 +991,7 @@ pub fn genTypedValue(...@@ -991,7 +991,7 @@ pub fn genTypedValue(
991 },991 },
992 },992 },
993 },993 },
994 .Int => {994 .int => {
995 const info = ty.intInfo(zcu);995 const info = ty.intInfo(zcu);
996 if (info.bits <= target.ptrBitWidth()) {996 if (info.bits <= target.ptrBitWidth()) {
997 const unsigned: u64 = switch (info.signedness) {997 const unsigned: u64 = switch (info.signedness) {
...@@ -1001,10 +1001,10 @@ pub fn genTypedValue(...@@ -1001,10 +1001,10 @@ pub fn genTypedValue(
1001 return .{ .mcv = .{ .immediate = unsigned } };1001 return .{ .mcv = .{ .immediate = unsigned } };
1002 }1002 }
1003 },1003 },
1004 .Bool => {1004 .bool => {
1005 return .{ .mcv = .{ .immediate = @intFromBool(val.toBool()) } };1005 return .{ .mcv = .{ .immediate = @intFromBool(val.toBool()) } };
1006 },1006 },
1007 .Optional => {1007 .optional => {
1008 if (ty.isPtrLikeOptional(zcu)) {1008 if (ty.isPtrLikeOptional(zcu)) {
1009 return genTypedValue(1009 return genTypedValue(
1010 lf,1010 lf,
...@@ -1017,7 +1017,7 @@ pub fn genTypedValue(...@@ -1017,7 +1017,7 @@ pub fn genTypedValue(
1017 return .{ .mcv = .{ .immediate = @intFromBool(!val.isNull(zcu)) } };1017 return .{ .mcv = .{ .immediate = @intFromBool(!val.isNull(zcu)) } };
1018 }1018 }
1019 },1019 },
1020 .Enum => {1020 .@"enum" => {
1021 const enum_tag = ip.indexToKey(val.toIntern()).enum_tag;1021 const enum_tag = ip.indexToKey(val.toIntern()).enum_tag;
1022 return genTypedValue(1022 return genTypedValue(
1023 lf,1023 lf,
...@@ -1027,12 +1027,12 @@ pub fn genTypedValue(...@@ -1027,12 +1027,12 @@ pub fn genTypedValue(
1027 target,1027 target,
1028 );1028 );
1029 },1029 },
1030 .ErrorSet => {1030 .error_set => {
1031 const err_name = ip.indexToKey(val.toIntern()).err.name;1031 const err_name = ip.indexToKey(val.toIntern()).err.name;
1032 const error_index = try pt.getErrorValue(err_name);1032 const error_index = try pt.getErrorValue(err_name);
1033 return .{ .mcv = .{ .immediate = error_index } };1033 return .{ .mcv = .{ .immediate = error_index } };
1034 },1034 },
1035 .ErrorUnion => {1035 .error_union => {
1036 const err_type = ty.errorUnionSet(zcu);1036 const err_type = ty.errorUnionSet(zcu);
1037 const payload_type = ty.errorUnionPayload(zcu);1037 const payload_type = ty.errorUnionPayload(zcu);
1038 if (!payload_type.hasRuntimeBitsIgnoreComptime(zcu)) {1038 if (!payload_type.hasRuntimeBitsIgnoreComptime(zcu)) {
...@@ -1060,14 +1060,14 @@ pub fn genTypedValue(...@@ -1060,14 +1060,14 @@ pub fn genTypedValue(
1060 }1060 }
1061 },1061 },
10621062
1063 .ComptimeInt => unreachable,1063 .comptime_int => unreachable,
1064 .ComptimeFloat => unreachable,1064 .comptime_float => unreachable,
1065 .Type => unreachable,1065 .type => unreachable,
1066 .EnumLiteral => unreachable,1066 .enum_literal => unreachable,
1067 .NoReturn => unreachable,1067 .noreturn => unreachable,
1068 .Undefined => unreachable,1068 .undefined => unreachable,
1069 .Null => unreachable,1069 .null => unreachable,
1070 .Opaque => unreachable,1070 .@"opaque" => unreachable,
10711071
1072 else => {},1072 else => {},
1073 }1073 }
src/codegen/c.zig+29-29
...@@ -1401,7 +1401,7 @@ pub const DeclGen = struct {...@@ -1401,7 +1401,7 @@ pub const DeclGen = struct {
1401 try writer.writeByte('(');1401 try writer.writeByte('(');
1402 try dg.renderCType(writer, ctype);1402 try dg.renderCType(writer, ctype);
1403 try writer.writeByte(')');1403 try writer.writeByte(')');
1404 } else if (field_ty.zigTypeTag(zcu) == .Float) {1404 } else if (field_ty.zigTypeTag(zcu) == .float) {
1405 try writer.writeByte('(');1405 try writer.writeByte('(');
1406 try dg.renderCType(writer, ctype);1406 try dg.renderCType(writer, ctype);
1407 try writer.writeByte(')');1407 try writer.writeByte(')');
...@@ -4473,8 +4473,8 @@ fn airCall(...@@ -4473,8 +4473,8 @@ fn airCall(
44734473
4474 const callee_ty = f.typeOf(pl_op.operand);4474 const callee_ty = f.typeOf(pl_op.operand);
4475 const fn_info = zcu.typeToFunc(switch (callee_ty.zigTypeTag(zcu)) {4475 const fn_info = zcu.typeToFunc(switch (callee_ty.zigTypeTag(zcu)) {
4476 .Fn => callee_ty,4476 .@"fn" => callee_ty,
4477 .Pointer => callee_ty.childType(zcu),4477 .pointer => callee_ty.childType(zcu),
4478 else => unreachable,4478 else => unreachable,
4479 }).?;4479 }).?;
4480 const ret_ty = Type.fromInterned(fn_info.return_type);4480 const ret_ty = Type.fromInterned(fn_info.return_type);
...@@ -5848,7 +5848,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5848,7 +5848,7 @@ fn airUnwrapErrUnionErr(f: *Function, inst: Air.Inst.Index) !CValue {
5848 const operand_ty = f.typeOf(ty_op.operand);5848 const operand_ty = f.typeOf(ty_op.operand);
5849 try reap(f, inst, &.{ty_op.operand});5849 try reap(f, inst, &.{ty_op.operand});
58505850
5851 const operand_is_ptr = operand_ty.zigTypeTag(zcu) == .Pointer;5851 const operand_is_ptr = operand_ty.zigTypeTag(zcu) == .pointer;
5852 const error_union_ty = if (operand_is_ptr) operand_ty.childType(zcu) else operand_ty;5852 const error_union_ty = if (operand_is_ptr) operand_ty.childType(zcu) else operand_ty;
5853 const error_ty = error_union_ty.errorUnionSet(zcu);5853 const error_ty = error_union_ty.errorUnionSet(zcu);
5854 const payload_ty = error_union_ty.errorUnionPayload(zcu);5854 const payload_ty = error_union_ty.errorUnionPayload(zcu);
...@@ -7011,23 +7011,23 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -7011,23 +7011,23 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {
7011 .Or => if (use_operator) .{ .infix = " |= " } else .{ .builtin = .{ .operation = "or" } },7011 .Or => if (use_operator) .{ .infix = " |= " } else .{ .builtin = .{ .operation = "or" } },
7012 .Xor => if (use_operator) .{ .infix = " ^= " } else .{ .builtin = .{ .operation = "xor" } },7012 .Xor => if (use_operator) .{ .infix = " ^= " } else .{ .builtin = .{ .operation = "xor" } },
7013 .Min => switch (scalar_ty.zigTypeTag(zcu)) {7013 .Min => switch (scalar_ty.zigTypeTag(zcu)) {
7014 .Int => if (use_operator) .{ .ternary = " < " } else .{ .builtin = .{ .operation = "min" } },7014 .int => if (use_operator) .{ .ternary = " < " } else .{ .builtin = .{ .operation = "min" } },
7015 .Float => .{ .builtin = .{ .operation = "min" } },7015 .float => .{ .builtin = .{ .operation = "min" } },
7016 else => unreachable,7016 else => unreachable,
7017 },7017 },
7018 .Max => switch (scalar_ty.zigTypeTag(zcu)) {7018 .Max => switch (scalar_ty.zigTypeTag(zcu)) {
7019 .Int => if (use_operator) .{ .ternary = " > " } else .{ .builtin = .{ .operation = "max" } },7019 .int => if (use_operator) .{ .ternary = " > " } else .{ .builtin = .{ .operation = "max" } },
7020 .Float => .{ .builtin = .{ .operation = "max" } },7020 .float => .{ .builtin = .{ .operation = "max" } },
7021 else => unreachable,7021 else => unreachable,
7022 },7022 },
7023 .Add => switch (scalar_ty.zigTypeTag(zcu)) {7023 .Add => switch (scalar_ty.zigTypeTag(zcu)) {
7024 .Int => if (use_operator) .{ .infix = " += " } else .{ .builtin = .{ .operation = "addw", .info = .bits } },7024 .int => if (use_operator) .{ .infix = " += " } else .{ .builtin = .{ .operation = "addw", .info = .bits } },
7025 .Float => .{ .builtin = .{ .operation = "add" } },7025 .float => .{ .builtin = .{ .operation = "add" } },
7026 else => unreachable,7026 else => unreachable,
7027 },7027 },
7028 .Mul => switch (scalar_ty.zigTypeTag(zcu)) {7028 .Mul => switch (scalar_ty.zigTypeTag(zcu)) {
7029 .Int => if (use_operator) .{ .infix = " *= " } else .{ .builtin = .{ .operation = "mulw", .info = .bits } },7029 .int => if (use_operator) .{ .infix = " *= " } else .{ .builtin = .{ .operation = "mulw", .info = .bits } },
7030 .Float => .{ .builtin = .{ .operation = "mul" } },7030 .float => .{ .builtin = .{ .operation = "mul" } },
7031 else => unreachable,7031 else => unreachable,
7032 },7032 },
7033 };7033 };
...@@ -7050,38 +7050,38 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -7050,38 +7050,38 @@ fn airReduce(f: *Function, inst: Air.Inst.Index) !CValue {
70507050
7051 try f.object.dg.renderValue(writer, switch (reduce.operation) {7051 try f.object.dg.renderValue(writer, switch (reduce.operation) {
7052 .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) {7052 .Or, .Xor => switch (scalar_ty.zigTypeTag(zcu)) {
7053 .Bool => Value.false,7053 .bool => Value.false,
7054 .Int => try pt.intValue(scalar_ty, 0),7054 .int => try pt.intValue(scalar_ty, 0),
7055 else => unreachable,7055 else => unreachable,
7056 },7056 },
7057 .And => switch (scalar_ty.zigTypeTag(zcu)) {7057 .And => switch (scalar_ty.zigTypeTag(zcu)) {
7058 .Bool => Value.true,7058 .bool => Value.true,
7059 .Int => switch (scalar_ty.intInfo(zcu).signedness) {7059 .int => switch (scalar_ty.intInfo(zcu).signedness) {
7060 .unsigned => try scalar_ty.maxIntScalar(pt, scalar_ty),7060 .unsigned => try scalar_ty.maxIntScalar(pt, scalar_ty),
7061 .signed => try pt.intValue(scalar_ty, -1),7061 .signed => try pt.intValue(scalar_ty, -1),
7062 },7062 },
7063 else => unreachable,7063 else => unreachable,
7064 },7064 },
7065 .Add => switch (scalar_ty.zigTypeTag(zcu)) {7065 .Add => switch (scalar_ty.zigTypeTag(zcu)) {
7066 .Int => try pt.intValue(scalar_ty, 0),7066 .int => try pt.intValue(scalar_ty, 0),
7067 .Float => try pt.floatValue(scalar_ty, 0.0),7067 .float => try pt.floatValue(scalar_ty, 0.0),
7068 else => unreachable,7068 else => unreachable,
7069 },7069 },
7070 .Mul => switch (scalar_ty.zigTypeTag(zcu)) {7070 .Mul => switch (scalar_ty.zigTypeTag(zcu)) {
7071 .Int => try pt.intValue(scalar_ty, 1),7071 .int => try pt.intValue(scalar_ty, 1),
7072 .Float => try pt.floatValue(scalar_ty, 1.0),7072 .float => try pt.floatValue(scalar_ty, 1.0),
7073 else => unreachable,7073 else => unreachable,
7074 },7074 },
7075 .Min => switch (scalar_ty.zigTypeTag(zcu)) {7075 .Min => switch (scalar_ty.zigTypeTag(zcu)) {
7076 .Bool => Value.true,7076 .bool => Value.true,
7077 .Int => try scalar_ty.maxIntScalar(pt, scalar_ty),7077 .int => try scalar_ty.maxIntScalar(pt, scalar_ty),
7078 .Float => try pt.floatValue(scalar_ty, std.math.nan(f128)),7078 .float => try pt.floatValue(scalar_ty, std.math.nan(f128)),
7079 else => unreachable,7079 else => unreachable,
7080 },7080 },
7081 .Max => switch (scalar_ty.zigTypeTag(zcu)) {7081 .Max => switch (scalar_ty.zigTypeTag(zcu)) {
7082 .Bool => Value.false,7082 .bool => Value.false,
7083 .Int => try scalar_ty.minIntScalar(pt, scalar_ty),7083 .int => try scalar_ty.minIntScalar(pt, scalar_ty),
7084 .Float => try pt.floatValue(scalar_ty, std.math.nan(f128)),7084 .float => try pt.floatValue(scalar_ty, std.math.nan(f128)),
7085 else => unreachable,7085 else => unreachable,
7086 },7086 },
7087 }, .Initializer);7087 }, .Initializer);
...@@ -7765,7 +7765,7 @@ fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Formatter(formatStri...@@ -7765,7 +7765,7 @@ fn fmtStringLiteral(str: []const u8, sentinel: ?u8) std.fmt.Formatter(formatStri
7765}7765}
77667766
7767fn undefPattern(comptime IntType: type) IntType {7767fn undefPattern(comptime IntType: type) IntType {
7768 const int_info = @typeInfo(IntType).Int;7768 const int_info = @typeInfo(IntType).int;
7769 const UnsignedType = std.meta.Int(.unsigned, int_info.bits);7769 const UnsignedType = std.meta.Int(.unsigned, int_info.bits);
7770 return @as(IntType, @bitCast(@as(UnsignedType, (1 << (int_info.bits | 1)) / 3)));7770 return @as(IntType, @bitCast(@as(UnsignedType, (1 << (int_info.bits | 1)) / 3)));
7771}7771}
...@@ -8027,7 +8027,7 @@ const Vectorize = struct {...@@ -8027,7 +8027,7 @@ const Vectorize = struct {
8027 pub fn start(f: *Function, inst: Air.Inst.Index, writer: anytype, ty: Type) !Vectorize {8027 pub fn start(f: *Function, inst: Air.Inst.Index, writer: anytype, ty: Type) !Vectorize {
8028 const pt = f.object.dg.pt;8028 const pt = f.object.dg.pt;
8029 const zcu = pt.zcu;8029 const zcu = pt.zcu;
8030 return if (ty.zigTypeTag(zcu) == .Vector) index: {8030 return if (ty.zigTypeTag(zcu) == .vector) index: {
8031 const local = try f.allocLocal(inst, Type.usize);8031 const local = try f.allocLocal(inst, Type.usize);
80328032
8033 try writer.writeAll("for (");8033 try writer.writeAll("for (");
...@@ -8063,7 +8063,7 @@ const Vectorize = struct {...@@ -8063,7 +8063,7 @@ const Vectorize = struct {
8063fn lowersToArray(ty: Type, pt: Zcu.PerThread) bool {8063fn lowersToArray(ty: Type, pt: Zcu.PerThread) bool {
8064 const zcu = pt.zcu;8064 const zcu = pt.zcu;
8065 return switch (ty.zigTypeTag(zcu)) {8065 return switch (ty.zigTypeTag(zcu)) {
8066 .Array, .Vector => return true,8066 .array, .vector => return true,
8067 else => return ty.isAbiInt(zcu) and toCIntBits(@as(u32, @intCast(ty.bitSize(zcu)))) == null,8067 else => return ty.isAbiInt(zcu) and toCIntBits(@as(u32, @intCast(ty.bitSize(zcu)))) == null,
8068 };8068 };
8069}8069}
src/codegen/c/Type.zig+25-25
...@@ -669,7 +669,7 @@ const Index = enum(u32) {...@@ -669,7 +669,7 @@ const Index = enum(u32) {
669669
670 _,670 _,
671671
672 const first_pool_index: u32 = @typeInfo(CType.Index).Enum.fields.len;672 const first_pool_index: u32 = @typeInfo(CType.Index).@"enum".fields.len;
673 const basic_hashes = init: {673 const basic_hashes = init: {
674 @setEvalBranchQuota(1_600);674 @setEvalBranchQuota(1_600);
675 var basic_hashes_init: [first_pool_index]Pool.Map.Hash = undefined;675 var basic_hashes_init: [first_pool_index]Pool.Map.Hash = undefined;
...@@ -740,7 +740,7 @@ pub const Info = union(enum) {...@@ -740,7 +740,7 @@ pub const Info = union(enum) {
740 aggregate: Aggregate,740 aggregate: Aggregate,
741 function: Function,741 function: Function,
742742
743 const Tag = @typeInfo(Info).Union.tag_type.?;743 const Tag = @typeInfo(Info).@"union".tag_type.?;
744744
745 pub const Pointer = struct {745 pub const Pointer = struct {
746 elem_ctype: CType,746 elem_ctype: CType,
...@@ -783,7 +783,7 @@ pub const Info = union(enum) {...@@ -783,7 +783,7 @@ pub const Info = union(enum) {
783 pub fn at(slice: Field.Slice, index: usize, pool: *const Pool) Field {783 pub fn at(slice: Field.Slice, index: usize, pool: *const Pool) Field {
784 assert(index < slice.len);784 assert(index < slice.len);
785 const extra = pool.getExtra(Pool.Field, @intCast(slice.extra_index +785 const extra = pool.getExtra(Pool.Field, @intCast(slice.extra_index +
786 index * @typeInfo(Pool.Field).Struct.fields.len));786 index * @typeInfo(Pool.Field).@"struct".fields.len));
787 return .{787 return .{
788 .name = .{ .index = extra.name },788 .name = .{ .index = extra.name },
789 .ctype = .{ .index = extra.ctype },789 .ctype = .{ .index = extra.ctype },
...@@ -991,7 +991,7 @@ pub const Pool = struct {...@@ -991,7 +991,7 @@ pub const Pool = struct {
991 _,991 _,
992992
993 const first_named_index: u32 = 1 << 31;993 const first_named_index: u32 = 1 << 31;
994 const first_pool_index: u32 = first_named_index + @typeInfo(String.Index).Enum.fields.len;994 const first_pool_index: u32 = first_named_index + @typeInfo(String.Index).@"enum".fields.len;
995 };995 };
996996
997 const Adapter = struct {997 const Adapter = struct {
...@@ -1127,7 +1127,7 @@ pub const Pool = struct {...@@ -1127,7 +1127,7 @@ pub const Pool = struct {
1127 allocator,1127 allocator,
1128 FwdDeclAnon,1128 FwdDeclAnon,
1129 extra,1129 extra,
1130 fields.len * @typeInfo(Field).Struct.fields.len,1130 fields.len * @typeInfo(Field).@"struct".fields.len,
1131 );1131 );
1132 for (fields, field_ctypes) |field, field_ctype| pool.addHashedExtraAssumeCapacity(1132 for (fields, field_ctypes) |field, field_ctype| pool.addHashedExtraAssumeCapacity(
1133 &hasher,1133 &hasher,
...@@ -1184,7 +1184,7 @@ pub const Pool = struct {...@@ -1184,7 +1184,7 @@ pub const Pool = struct {
1184 allocator,1184 allocator,
1185 AggregateAnon,1185 AggregateAnon,
1186 extra,1186 extra,
1187 aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len,1187 aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len,
1188 );1188 );
1189 for (aggregate_info.fields) |field| pool.addHashedExtraAssumeCapacity(&hasher, Field, .{1189 for (aggregate_info.fields) |field| pool.addHashedExtraAssumeCapacity(&hasher, Field, .{
1190 .name = field.name.index,1190 .name = field.name.index,
...@@ -1213,7 +1213,7 @@ pub const Pool = struct {...@@ -1213,7 +1213,7 @@ pub const Pool = struct {
1213 allocator,1213 allocator,
1214 Aggregate,1214 Aggregate,
1215 extra,1215 extra,
1216 aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len,1216 aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len,
1217 );1217 );
1218 for (aggregate_info.fields) |field| pool.addHashedExtraAssumeCapacity(&hasher, Field, .{1218 for (aggregate_info.fields) |field| pool.addHashedExtraAssumeCapacity(&hasher, Field, .{
1219 .name = field.name.index,1219 .name = field.name.index,
...@@ -1672,7 +1672,7 @@ pub const Pool = struct {...@@ -1672,7 +1672,7 @@ pub const Pool = struct {
1672 defer scratch.shrinkRetainingCapacity(scratch_top);1672 defer scratch.shrinkRetainingCapacity(scratch_top);
1673 try scratch.ensureUnusedCapacity(1673 try scratch.ensureUnusedCapacity(
1674 allocator,1674 allocator,
1675 loaded_struct.field_types.len * @typeInfo(Field).Struct.fields.len,1675 loaded_struct.field_types.len * @typeInfo(Field).@"struct".fields.len,
1676 );1676 );
1677 var hasher = Hasher.init;1677 var hasher = Hasher.init;
1678 var tag: Pool.Tag = .aggregate_struct;1678 var tag: Pool.Tag = .aggregate_struct;
...@@ -1709,14 +1709,14 @@ pub const Pool = struct {...@@ -1709,14 +1709,14 @@ pub const Pool = struct {
1709 }1709 }
1710 const fields_len: u32 = @intCast(@divExact(1710 const fields_len: u32 = @intCast(@divExact(
1711 scratch.items.len - scratch_top,1711 scratch.items.len - scratch_top,
1712 @typeInfo(Field).Struct.fields.len,1712 @typeInfo(Field).@"struct".fields.len,
1713 ));1713 ));
1714 if (fields_len == 0) return CType.void;1714 if (fields_len == 0) return CType.void;
1715 try pool.ensureUnusedCapacity(allocator, 1);1715 try pool.ensureUnusedCapacity(allocator, 1);
1716 const extra_index = try pool.addHashedExtra(allocator, &hasher, Aggregate, .{1716 const extra_index = try pool.addHashedExtra(allocator, &hasher, Aggregate, .{
1717 .fwd_decl = fwd_decl.index,1717 .fwd_decl = fwd_decl.index,
1718 .fields_len = fields_len,1718 .fields_len = fields_len,
1719 }, fields_len * @typeInfo(Field).Struct.fields.len);1719 }, fields_len * @typeInfo(Field).@"struct".fields.len);
1720 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);1720 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);
1721 return pool.tagTrailingExtraAssumeCapacity(hasher, tag, extra_index);1721 return pool.tagTrailingExtraAssumeCapacity(hasher, tag, extra_index);
1722 },1722 },
...@@ -1734,7 +1734,7 @@ pub const Pool = struct {...@@ -1734,7 +1734,7 @@ pub const Pool = struct {
1734 const scratch_top = scratch.items.len;1734 const scratch_top = scratch.items.len;
1735 defer scratch.shrinkRetainingCapacity(scratch_top);1735 defer scratch.shrinkRetainingCapacity(scratch_top);
1736 try scratch.ensureUnusedCapacity(allocator, anon_struct_info.types.len *1736 try scratch.ensureUnusedCapacity(allocator, anon_struct_info.types.len *
1737 @typeInfo(Field).Struct.fields.len);1737 @typeInfo(Field).@"struct".fields.len);
1738 var hasher = Hasher.init;1738 var hasher = Hasher.init;
1739 for (0..anon_struct_info.types.len) |field_index| {1739 for (0..anon_struct_info.types.len) |field_index| {
1740 if (anon_struct_info.values.get(ip)[field_index] != .none) continue;1740 if (anon_struct_info.values.get(ip)[field_index] != .none) continue;
...@@ -1765,7 +1765,7 @@ pub const Pool = struct {...@@ -1765,7 +1765,7 @@ pub const Pool = struct {
1765 }1765 }
1766 const fields_len: u32 = @intCast(@divExact(1766 const fields_len: u32 = @intCast(@divExact(
1767 scratch.items.len - scratch_top,1767 scratch.items.len - scratch_top,
1768 @typeInfo(Field).Struct.fields.len,1768 @typeInfo(Field).@"struct".fields.len,
1769 ));1769 ));
1770 if (fields_len == 0) return CType.void;1770 if (fields_len == 0) return CType.void;
1771 if (kind.isForward()) {1771 if (kind.isForward()) {
...@@ -1775,7 +1775,7 @@ pub const Pool = struct {...@@ -1775,7 +1775,7 @@ pub const Pool = struct {
1775 &hasher,1775 &hasher,
1776 FwdDeclAnon,1776 FwdDeclAnon,
1777 .{ .fields_len = fields_len },1777 .{ .fields_len = fields_len },
1778 fields_len * @typeInfo(Field).Struct.fields.len,1778 fields_len * @typeInfo(Field).@"struct".fields.len,
1779 );1779 );
1780 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);1780 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);
1781 return pool.tagTrailingExtra(1781 return pool.tagTrailingExtra(
...@@ -1790,7 +1790,7 @@ pub const Pool = struct {...@@ -1790,7 +1790,7 @@ pub const Pool = struct {
1790 const extra_index = try pool.addHashedExtra(allocator, &hasher, Aggregate, .{1790 const extra_index = try pool.addHashedExtra(allocator, &hasher, Aggregate, .{
1791 .fwd_decl = fwd_decl.index,1791 .fwd_decl = fwd_decl.index,
1792 .fields_len = fields_len,1792 .fields_len = fields_len,
1793 }, fields_len * @typeInfo(Field).Struct.fields.len);1793 }, fields_len * @typeInfo(Field).@"struct".fields.len);
1794 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);1794 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);
1795 return pool.tagTrailingExtraAssumeCapacity(hasher, .aggregate_struct, extra_index);1795 return pool.tagTrailingExtraAssumeCapacity(hasher, .aggregate_struct, extra_index);
1796 },1796 },
...@@ -1812,7 +1812,7 @@ pub const Pool = struct {...@@ -1812,7 +1812,7 @@ pub const Pool = struct {
1812 defer scratch.shrinkRetainingCapacity(scratch_top);1812 defer scratch.shrinkRetainingCapacity(scratch_top);
1813 try scratch.ensureUnusedCapacity(1813 try scratch.ensureUnusedCapacity(
1814 allocator,1814 allocator,
1815 loaded_union.field_types.len * @typeInfo(Field).Struct.fields.len,1815 loaded_union.field_types.len * @typeInfo(Field).@"struct".fields.len,
1816 );1816 );
1817 var hasher = Hasher.init;1817 var hasher = Hasher.init;
1818 var tag: Pool.Tag = .aggregate_union;1818 var tag: Pool.Tag = .aggregate_union;
...@@ -1850,7 +1850,7 @@ pub const Pool = struct {...@@ -1850,7 +1850,7 @@ pub const Pool = struct {
1850 }1850 }
1851 const fields_len: u32 = @intCast(@divExact(1851 const fields_len: u32 = @intCast(@divExact(
1852 scratch.items.len - scratch_top,1852 scratch.items.len - scratch_top,
1853 @typeInfo(Field).Struct.fields.len,1853 @typeInfo(Field).@"struct".fields.len,
1854 ));1854 ));
1855 if (!has_tag) {1855 if (!has_tag) {
1856 if (fields_len == 0) return CType.void;1856 if (fields_len == 0) return CType.void;
...@@ -1860,7 +1860,7 @@ pub const Pool = struct {...@@ -1860,7 +1860,7 @@ pub const Pool = struct {
1860 &hasher,1860 &hasher,
1861 Aggregate,1861 Aggregate,
1862 .{ .fwd_decl = fwd_decl.index, .fields_len = fields_len },1862 .{ .fwd_decl = fwd_decl.index, .fields_len = fields_len },
1863 fields_len * @typeInfo(Field).Struct.fields.len,1863 fields_len * @typeInfo(Field).@"struct".fields.len,
1864 );1864 );
1865 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);1865 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);
1866 return pool.tagTrailingExtraAssumeCapacity(hasher, tag, extra_index);1866 return pool.tagTrailingExtraAssumeCapacity(hasher, tag, extra_index);
...@@ -1898,7 +1898,7 @@ pub const Pool = struct {...@@ -1898,7 +1898,7 @@ pub const Pool = struct {
1898 .id = 0,1898 .id = 0,
1899 .fields_len = fields_len,1899 .fields_len = fields_len,
1900 },1900 },
1901 fields_len * @typeInfo(Field).Struct.fields.len,1901 fields_len * @typeInfo(Field).@"struct".fields.len,
1902 );1902 );
1903 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);1903 pool.extra.appendSliceAssumeCapacity(scratch.items[scratch_top..]);
1904 break :payload_ctype pool.tagTrailingExtraAssumeCapacity(1904 break :payload_ctype pool.tagTrailingExtraAssumeCapacity(
...@@ -2087,7 +2087,7 @@ pub const Pool = struct {...@@ -2087,7 +2087,7 @@ pub const Pool = struct {
2087 .tag = tag,2087 .tag = tag,
2088 .data = try pool.addExtra(allocator, FwdDeclAnon, .{2088 .data = try pool.addExtra(allocator, FwdDeclAnon, .{
2089 .fields_len = fields.len,2089 .fields_len = fields.len,
2090 }, fields.len * @typeInfo(Field).Struct.fields.len),2090 }, fields.len * @typeInfo(Field).@"struct".fields.len),
2091 });2091 });
2092 for (0..fields.len) |field_index| {2092 for (0..fields.len) |field_index| {
2093 const field = fields.at(field_index, source_pool);2093 const field = fields.at(field_index, source_pool);
...@@ -2115,11 +2115,11 @@ pub const Pool = struct {...@@ -2115,11 +2115,11 @@ pub const Pool = struct {
2115 .index = anon.index,2115 .index = anon.index,
2116 .id = anon.id,2116 .id = anon.id,
2117 .fields_len = aggregate_info.fields.len,2117 .fields_len = aggregate_info.fields.len,
2118 }, aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len),2118 }, aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len),
2119 .fwd_decl => |fwd_decl| try pool.addExtra(allocator, Aggregate, .{2119 .fwd_decl => |fwd_decl| try pool.addExtra(allocator, Aggregate, .{
2120 .fwd_decl = pool_adapter.copy(fwd_decl).index,2120 .fwd_decl = pool_adapter.copy(fwd_decl).index,
2121 .fields_len = aggregate_info.fields.len,2121 .fields_len = aggregate_info.fields.len,
2122 }, aggregate_info.fields.len * @typeInfo(Field).Struct.fields.len),2122 }, aggregate_info.fields.len * @typeInfo(Field).@"struct".fields.len),
2123 },2123 },
2124 });2124 });
2125 for (0..aggregate_info.fields.len) |field_index| {2125 for (0..aggregate_info.fields.len) |field_index| {
...@@ -2182,7 +2182,7 @@ pub const Pool = struct {...@@ -2182,7 +2182,7 @@ pub const Pool = struct {
2182 const init: Hasher = .{ .impl = Impl.init(0) };2182 const init: Hasher = .{ .impl = Impl.init(0) };
21832183
2184 fn updateExtra(hasher: *Hasher, comptime Extra: type, extra: Extra, pool: *const Pool) void {2184 fn updateExtra(hasher: *Hasher, comptime Extra: type, extra: Extra, pool: *const Pool) void {
2185 inline for (@typeInfo(Extra).Struct.fields) |field| {2185 inline for (@typeInfo(Extra).@"struct".fields) |field| {
2186 const value = @field(extra, field.name);2186 const value = @field(extra, field.name);
2187 switch (field.type) {2187 switch (field.type) {
2188 Pool.Tag, String, CType => unreachable,2188 Pool.Tag, String, CType => unreachable,
...@@ -2429,7 +2429,7 @@ pub const Pool = struct {...@@ -2429,7 +2429,7 @@ pub const Pool = struct {
2429 ) !ExtraIndex {2429 ) !ExtraIndex {
2430 try pool.extra.ensureUnusedCapacity(2430 try pool.extra.ensureUnusedCapacity(
2431 allocator,2431 allocator,
2432 @typeInfo(Extra).Struct.fields.len + trailing_len,2432 @typeInfo(Extra).@"struct".fields.len + trailing_len,
2433 );2433 );
2434 defer pool.addExtraAssumeCapacity(Extra, extra);2434 defer pool.addExtraAssumeCapacity(Extra, extra);
2435 return @intCast(pool.extra.items.len);2435 return @intCast(pool.extra.items.len);
...@@ -2442,7 +2442,7 @@ pub const Pool = struct {...@@ -2442,7 +2442,7 @@ pub const Pool = struct {
2442 comptime Extra: type,2442 comptime Extra: type,
2443 extra: Extra,2443 extra: Extra,
2444 ) void {2444 ) void {
2445 inline for (@typeInfo(Extra).Struct.fields) |field| {2445 inline for (@typeInfo(Extra).@"struct".fields) |field| {
2446 const value = @field(extra, field.name);2446 const value = @field(extra, field.name);
2447 array.appendAssumeCapacity(switch (field.type) {2447 array.appendAssumeCapacity(switch (field.type) {
2448 u32 => value,2448 u32 => value,
...@@ -2505,7 +2505,7 @@ pub const Pool = struct {...@@ -2505,7 +2505,7 @@ pub const Pool = struct {
2505 extra_index: ExtraIndex,2505 extra_index: ExtraIndex,
2506 ) struct { extra: Extra, trail: ExtraTrail } {2506 ) struct { extra: Extra, trail: ExtraTrail } {
2507 var extra: Extra = undefined;2507 var extra: Extra = undefined;
2508 const fields = @typeInfo(Extra).Struct.fields;2508 const fields = @typeInfo(Extra).@"struct".fields;
2509 inline for (fields, pool.extra.items[extra_index..][0..fields.len]) |field, value|2509 inline for (fields, pool.extra.items[extra_index..][0..fields.len]) |field, value|
2510 @field(extra, field.name) = switch (field.type) {2510 @field(extra, field.name) = switch (field.type) {
2511 u32 => value,2511 u32 => value,
src/codegen/llvm.zig+113-113
...@@ -1538,7 +1538,7 @@ pub const Object = struct {...@@ -1538,7 +1538,7 @@ pub const Object = struct {
1538 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);1538 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
1539 }1539 }
1540 }1540 }
1541 if (param_ty.zigTypeTag(zcu) != .Optional) {1541 if (param_ty.zigTypeTag(zcu) != .optional) {
1542 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);1542 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
1543 }1543 }
1544 if (ptr_info.flags.is_const) {1544 if (ptr_info.flags.is_const) {
...@@ -1907,8 +1907,8 @@ pub const Object = struct {...@@ -1907,8 +1907,8 @@ pub const Object = struct {
1907 if (o.debug_type_map.get(ty)) |debug_type| return debug_type;1907 if (o.debug_type_map.get(ty)) |debug_type| return debug_type;
19081908
1909 switch (ty.zigTypeTag(zcu)) {1909 switch (ty.zigTypeTag(zcu)) {
1910 .Void,1910 .void,
1911 .NoReturn,1911 .noreturn,
1912 => {1912 => {
1913 const debug_void_type = try o.builder.debugSignedType(1913 const debug_void_type = try o.builder.debugSignedType(
1914 try o.builder.metadataString("void"),1914 try o.builder.metadataString("void"),
...@@ -1917,7 +1917,7 @@ pub const Object = struct {...@@ -1917,7 +1917,7 @@ pub const Object = struct {
1917 try o.debug_type_map.put(gpa, ty, debug_void_type);1917 try o.debug_type_map.put(gpa, ty, debug_void_type);
1918 return debug_void_type;1918 return debug_void_type;
1919 },1919 },
1920 .Int => {1920 .int => {
1921 const info = ty.intInfo(zcu);1921 const info = ty.intInfo(zcu);
1922 assert(info.bits != 0);1922 assert(info.bits != 0);
1923 const name = try o.allocTypeName(ty);1923 const name = try o.allocTypeName(ty);
...@@ -1931,7 +1931,7 @@ pub const Object = struct {...@@ -1931,7 +1931,7 @@ pub const Object = struct {
1931 try o.debug_type_map.put(gpa, ty, debug_int_type);1931 try o.debug_type_map.put(gpa, ty, debug_int_type);
1932 return debug_int_type;1932 return debug_int_type;
1933 },1933 },
1934 .Enum => {1934 .@"enum" => {
1935 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) {1935 if (!ty.hasRuntimeBitsIgnoreComptime(zcu)) {
1936 const debug_enum_type = try o.makeEmptyNamespaceDebugType(ty);1936 const debug_enum_type = try o.makeEmptyNamespaceDebugType(ty);
1937 try o.debug_type_map.put(gpa, ty, debug_enum_type);1937 try o.debug_type_map.put(gpa, ty, debug_enum_type);
...@@ -1985,7 +1985,7 @@ pub const Object = struct {...@@ -1985,7 +1985,7 @@ pub const Object = struct {
1985 try o.debug_enums.append(gpa, debug_enum_type);1985 try o.debug_enums.append(gpa, debug_enum_type);
1986 return debug_enum_type;1986 return debug_enum_type;
1987 },1987 },
1988 .Float => {1988 .float => {
1989 const bits = ty.floatBits(target);1989 const bits = ty.floatBits(target);
1990 const name = try o.allocTypeName(ty);1990 const name = try o.allocTypeName(ty);
1991 defer gpa.free(name);1991 defer gpa.free(name);
...@@ -1996,7 +1996,7 @@ pub const Object = struct {...@@ -1996,7 +1996,7 @@ pub const Object = struct {
1996 try o.debug_type_map.put(gpa, ty, debug_float_type);1996 try o.debug_type_map.put(gpa, ty, debug_float_type);
1997 return debug_float_type;1997 return debug_float_type;
1998 },1998 },
1999 .Bool => {1999 .bool => {
2000 const debug_bool_type = try o.builder.debugBoolType(2000 const debug_bool_type = try o.builder.debugBoolType(
2001 try o.builder.metadataString("bool"),2001 try o.builder.metadataString("bool"),
2002 8, // lldb cannot handle non-byte sized types2002 8, // lldb cannot handle non-byte sized types
...@@ -2004,7 +2004,7 @@ pub const Object = struct {...@@ -2004,7 +2004,7 @@ pub const Object = struct {
2004 try o.debug_type_map.put(gpa, ty, debug_bool_type);2004 try o.debug_type_map.put(gpa, ty, debug_bool_type);
2005 return debug_bool_type;2005 return debug_bool_type;
2006 },2006 },
2007 .Pointer => {2007 .pointer => {
2008 // Normalize everything that the debug info does not represent.2008 // Normalize everything that the debug info does not represent.
2009 const ptr_info = ty.ptrInfo(zcu);2009 const ptr_info = ty.ptrInfo(zcu);
20102010
...@@ -2126,7 +2126,7 @@ pub const Object = struct {...@@ -2126,7 +2126,7 @@ pub const Object = struct {
21262126
2127 return debug_ptr_type;2127 return debug_ptr_type;
2128 },2128 },
2129 .Opaque => {2129 .@"opaque" => {
2130 if (ty.toIntern() == .anyopaque_type) {2130 if (ty.toIntern() == .anyopaque_type) {
2131 const debug_opaque_type = try o.builder.debugSignedType(2131 const debug_opaque_type = try o.builder.debugSignedType(
2132 try o.builder.metadataString("anyopaque"),2132 try o.builder.metadataString("anyopaque"),
...@@ -2158,7 +2158,7 @@ pub const Object = struct {...@@ -2158,7 +2158,7 @@ pub const Object = struct {
2158 try o.debug_type_map.put(gpa, ty, debug_opaque_type);2158 try o.debug_type_map.put(gpa, ty, debug_opaque_type);
2159 return debug_opaque_type;2159 return debug_opaque_type;
2160 },2160 },
2161 .Array => {2161 .array => {
2162 const debug_array_type = try o.builder.debugArrayType(2162 const debug_array_type = try o.builder.debugArrayType(
2163 .none, // Name2163 .none, // Name
2164 .none, // File2164 .none, // File
...@@ -2177,14 +2177,14 @@ pub const Object = struct {...@@ -2177,14 +2177,14 @@ pub const Object = struct {
2177 try o.debug_type_map.put(gpa, ty, debug_array_type);2177 try o.debug_type_map.put(gpa, ty, debug_array_type);
2178 return debug_array_type;2178 return debug_array_type;
2179 },2179 },
2180 .Vector => {2180 .vector => {
2181 const elem_ty = ty.elemType2(zcu);2181 const elem_ty = ty.elemType2(zcu);
2182 // Vector elements cannot be padded since that would make2182 // Vector elements cannot be padded since that would make
2183 // @bitSizOf(elem) * len > @bitSizOf(vec).2183 // @bitSizOf(elem) * len > @bitSizOf(vec).
2184 // Neither gdb nor lldb seem to be able to display non-byte sized2184 // Neither gdb nor lldb seem to be able to display non-byte sized
2185 // vectors properly.2185 // vectors properly.
2186 const debug_elem_type = switch (elem_ty.zigTypeTag(zcu)) {2186 const debug_elem_type = switch (elem_ty.zigTypeTag(zcu)) {
2187 .Int => blk: {2187 .int => blk: {
2188 const info = elem_ty.intInfo(zcu);2188 const info = elem_ty.intInfo(zcu);
2189 assert(info.bits != 0);2189 assert(info.bits != 0);
2190 const name = try o.allocTypeName(ty);2190 const name = try o.allocTypeName(ty);
...@@ -2195,7 +2195,7 @@ pub const Object = struct {...@@ -2195,7 +2195,7 @@ pub const Object = struct {
2195 .unsigned => try o.builder.debugUnsignedType(builder_name, info.bits),2195 .unsigned => try o.builder.debugUnsignedType(builder_name, info.bits),
2196 };2196 };
2197 },2197 },
2198 .Bool => try o.builder.debugBoolType(2198 .bool => try o.builder.debugBoolType(
2199 try o.builder.metadataString("bool"),2199 try o.builder.metadataString("bool"),
2200 1,2200 1,
2201 ),2201 ),
...@@ -2221,7 +2221,7 @@ pub const Object = struct {...@@ -2221,7 +2221,7 @@ pub const Object = struct {
2221 try o.debug_type_map.put(gpa, ty, debug_vector_type);2221 try o.debug_type_map.put(gpa, ty, debug_vector_type);
2222 return debug_vector_type;2222 return debug_vector_type;
2223 },2223 },
2224 .Optional => {2224 .optional => {
2225 const name = try o.allocTypeName(ty);2225 const name = try o.allocTypeName(ty);
2226 defer gpa.free(name);2226 defer gpa.free(name);
2227 const child_ty = ty.optionalChild(zcu);2227 const child_ty = ty.optionalChild(zcu);
...@@ -2302,7 +2302,7 @@ pub const Object = struct {...@@ -2302,7 +2302,7 @@ pub const Object = struct {
23022302
2303 return debug_optional_type;2303 return debug_optional_type;
2304 },2304 },
2305 .ErrorUnion => {2305 .error_union => {
2306 const payload_ty = ty.errorUnionPayload(zcu);2306 const payload_ty = ty.errorUnionPayload(zcu);
2307 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {2307 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
2308 // TODO: Maybe remove?2308 // TODO: Maybe remove?
...@@ -2375,7 +2375,7 @@ pub const Object = struct {...@@ -2375,7 +2375,7 @@ pub const Object = struct {
2375 try o.debug_type_map.put(gpa, ty, debug_error_union_type);2375 try o.debug_type_map.put(gpa, ty, debug_error_union_type);
2376 return debug_error_union_type;2376 return debug_error_union_type;
2377 },2377 },
2378 .ErrorSet => {2378 .error_set => {
2379 const debug_error_set = try o.builder.debugUnsignedType(2379 const debug_error_set = try o.builder.debugUnsignedType(
2380 try o.builder.metadataString("anyerror"),2380 try o.builder.metadataString("anyerror"),
2381 16,2381 16,
...@@ -2383,7 +2383,7 @@ pub const Object = struct {...@@ -2383,7 +2383,7 @@ pub const Object = struct {
2383 try o.debug_type_map.put(gpa, ty, debug_error_set);2383 try o.debug_type_map.put(gpa, ty, debug_error_set);
2384 return debug_error_set;2384 return debug_error_set;
2385 },2385 },
2386 .Struct => {2386 .@"struct" => {
2387 const name = try o.allocTypeName(ty);2387 const name = try o.allocTypeName(ty);
2388 defer gpa.free(name);2388 defer gpa.free(name);
23892389
...@@ -2531,7 +2531,7 @@ pub const Object = struct {...@@ -2531,7 +2531,7 @@ pub const Object = struct {
25312531
2532 return debug_struct_type;2532 return debug_struct_type;
2533 },2533 },
2534 .Union => {2534 .@"union" => {
2535 const name = try o.allocTypeName(ty);2535 const name = try o.allocTypeName(ty);
2536 defer gpa.free(name);2536 defer gpa.free(name);
25372537
...@@ -2693,7 +2693,7 @@ pub const Object = struct {...@@ -2693,7 +2693,7 @@ pub const Object = struct {
26932693
2694 return debug_tagged_union_type;2694 return debug_tagged_union_type;
2695 },2695 },
2696 .Fn => {2696 .@"fn" => {
2697 const fn_info = zcu.typeToFunc(ty).?;2697 const fn_info = zcu.typeToFunc(ty).?;
26982698
2699 var debug_param_types = std.ArrayList(Builder.Metadata).init(gpa);2699 var debug_param_types = std.ArrayList(Builder.Metadata).init(gpa);
...@@ -2741,15 +2741,15 @@ pub const Object = struct {...@@ -2741,15 +2741,15 @@ pub const Object = struct {
2741 try o.debug_type_map.put(gpa, ty, debug_function_type);2741 try o.debug_type_map.put(gpa, ty, debug_function_type);
2742 return debug_function_type;2742 return debug_function_type;
2743 },2743 },
2744 .ComptimeInt => unreachable,2744 .comptime_int => unreachable,
2745 .ComptimeFloat => unreachable,2745 .comptime_float => unreachable,
2746 .Type => unreachable,2746 .type => unreachable,
2747 .Undefined => unreachable,2747 .undefined => unreachable,
2748 .Null => unreachable,2748 .null => unreachable,
2749 .EnumLiteral => unreachable,2749 .enum_literal => unreachable,
27502750
2751 .Frame => @panic("TODO implement lowerDebugType for Frame types"),2751 .frame => @panic("TODO implement lowerDebugType for Frame types"),
2752 .AnyFrame => @panic("TODO implement lowerDebugType for AnyFrame types"),2752 .@"anyframe" => @panic("TODO implement lowerDebugType for AnyFrame types"),
2753 }2753 }
2754 }2754 }
27552755
...@@ -3539,9 +3539,9 @@ pub const Object = struct {...@@ -3539,9 +3539,9 @@ pub const Object = struct {
3539 const pt = o.pt;3539 const pt = o.pt;
3540 const zcu = pt.zcu;3540 const zcu = pt.zcu;
3541 const lower_elem_ty = switch (elem_ty.zigTypeTag(zcu)) {3541 const lower_elem_ty = switch (elem_ty.zigTypeTag(zcu)) {
3542 .Opaque => true,3542 .@"opaque" => true,
3543 .Fn => !zcu.typeToFunc(elem_ty).?.is_generic,3543 .@"fn" => !zcu.typeToFunc(elem_ty).?.is_generic,
3544 .Array => elem_ty.childType(zcu).hasRuntimeBitsIgnoreComptime(zcu),3544 .array => elem_ty.childType(zcu).hasRuntimeBitsIgnoreComptime(zcu),
3545 else => elem_ty.hasRuntimeBitsIgnoreComptime(zcu),3545 else => elem_ty.hasRuntimeBitsIgnoreComptime(zcu),
3546 };3546 };
3547 return if (lower_elem_ty) try o.lowerType(elem_ty) else .i8;3547 return if (lower_elem_ty) try o.lowerType(elem_ty) else .i8;
...@@ -3883,7 +3883,7 @@ pub const Object = struct {...@@ -3883,7 +3883,7 @@ pub const Object = struct {
3883 },3883 },
3884 else => |payload| try o.lowerValue(payload),3884 else => |payload| try o.lowerValue(payload),
3885 };3885 };
3886 assert(payload_ty.zigTypeTag(zcu) != .Fn);3886 assert(payload_ty.zigTypeTag(zcu) != .@"fn");
38873887
3888 var fields: [3]Builder.Type = undefined;3888 var fields: [3]Builder.Type = undefined;
3889 var vals: [3]Builder.Constant = undefined;3889 var vals: [3]Builder.Constant = undefined;
...@@ -4303,7 +4303,7 @@ pub const Object = struct {...@@ -4303,7 +4303,7 @@ pub const Object = struct {
4303 .field => |field| {4303 .field => |field| {
4304 const agg_ty = Value.fromInterned(field.base).typeOf(zcu).childType(zcu);4304 const agg_ty = Value.fromInterned(field.base).typeOf(zcu).childType(zcu);
4305 const field_off: u64 = switch (agg_ty.zigTypeTag(zcu)) {4305 const field_off: u64 = switch (agg_ty.zigTypeTag(zcu)) {
4306 .Pointer => off: {4306 .pointer => off: {
4307 assert(agg_ty.isSlice(zcu));4307 assert(agg_ty.isSlice(zcu));
4308 break :off switch (field.index) {4308 break :off switch (field.index) {
4309 Value.slice_ptr_index => 0,4309 Value.slice_ptr_index => 0,
...@@ -4311,7 +4311,7 @@ pub const Object = struct {...@@ -4311,7 +4311,7 @@ pub const Object = struct {
4311 else => unreachable,4311 else => unreachable,
4312 };4312 };
4313 },4313 },
4314 .Struct, .Union => switch (agg_ty.containerLayout(zcu)) {4314 .@"struct", .@"union" => switch (agg_ty.containerLayout(zcu)) {
4315 .auto => agg_ty.structFieldOffset(@intCast(field.index), zcu),4315 .auto => agg_ty.structFieldOffset(@intCast(field.index), zcu),
4316 .@"extern", .@"packed" => unreachable,4316 .@"extern", .@"packed" => unreachable,
4317 },4317 },
...@@ -4344,7 +4344,7 @@ pub const Object = struct {...@@ -4344,7 +4344,7 @@ pub const Object = struct {
43444344
4345 const ptr_ty = Type.fromInterned(uav.orig_ty);4345 const ptr_ty = Type.fromInterned(uav.orig_ty);
43464346
4347 const is_fn_body = uav_ty.zigTypeTag(zcu) == .Fn;4347 const is_fn_body = uav_ty.zigTypeTag(zcu) == .@"fn";
4348 if ((!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) or4348 if ((!is_fn_body and !uav_ty.hasRuntimeBits(zcu)) or
4349 (is_fn_body and zcu.typeToFunc(uav_ty).?.is_generic)) return o.lowerPtrToVoid(ptr_ty);4349 (is_fn_body and zcu.typeToFunc(uav_ty).?.is_generic)) return o.lowerPtrToVoid(ptr_ty);
43504350
...@@ -4383,7 +4383,7 @@ pub const Object = struct {...@@ -4383,7 +4383,7 @@ pub const Object = struct {
4383 const nav_ty = Type.fromInterned(owner_nav.typeOf(ip));4383 const nav_ty = Type.fromInterned(owner_nav.typeOf(ip));
4384 const ptr_ty = try pt.navPtrType(owner_nav_index);4384 const ptr_ty = try pt.navPtrType(owner_nav_index);
43854385
4386 const is_fn_body = nav_ty.zigTypeTag(zcu) == .Fn;4386 const is_fn_body = nav_ty.zigTypeTag(zcu) == .@"fn";
4387 if ((!is_fn_body and !nav_ty.hasRuntimeBits(zcu)) or4387 if ((!is_fn_body and !nav_ty.hasRuntimeBits(zcu)) or
4388 (is_fn_body and zcu.typeToFunc(nav_ty).?.is_generic))4388 (is_fn_body and zcu.typeToFunc(nav_ty).?.is_generic))
4389 {4389 {
...@@ -4435,13 +4435,13 @@ pub const Object = struct {...@@ -4435,13 +4435,13 @@ pub const Object = struct {
4435 const pt = o.pt;4435 const pt = o.pt;
4436 const zcu = pt.zcu;4436 const zcu = pt.zcu;
4437 const int_ty = switch (ty.zigTypeTag(zcu)) {4437 const int_ty = switch (ty.zigTypeTag(zcu)) {
4438 .Int => ty,4438 .int => ty,
4439 .Enum => ty.intTagType(zcu),4439 .@"enum" => ty.intTagType(zcu),
4440 .Float => {4440 .float => {
4441 if (!is_rmw_xchg) return .none;4441 if (!is_rmw_xchg) return .none;
4442 return o.builder.intType(@intCast(ty.abiSize(zcu) * 8));4442 return o.builder.intType(@intCast(ty.abiSize(zcu) * 8));
4443 },4443 },
4444 .Bool => return .i8,4444 .bool => return .i8,
4445 else => return .none,4445 else => return .none,
4446 };4446 };
4447 const bit_count = int_ty.intInfo(zcu).bits;4447 const bit_count = int_ty.intInfo(zcu).bits;
...@@ -4693,7 +4693,7 @@ pub const NavGen = struct {...@@ -4693,7 +4693,7 @@ pub const NavGen = struct {
4693 const global_index = o.nav_map.get(nav_index).?;4693 const global_index = o.nav_map.get(nav_index).?;
46944694
4695 const decl_name = decl_name: {4695 const decl_name = decl_name: {
4696 if (zcu.getTarget().isWasm() and ty.zigTypeTag(zcu) == .Fn) {4696 if (zcu.getTarget().isWasm() and ty.zigTypeTag(zcu) == .@"fn") {
4697 if (lib_name.toSlice(ip)) |lib_name_slice| {4697 if (lib_name.toSlice(ip)) |lib_name_slice| {
4698 if (!std.mem.eql(u8, lib_name_slice, "c")) {4698 if (!std.mem.eql(u8, lib_name_slice, "c")) {
4699 break :decl_name try o.builder.strtabStringFmt("{}|{s}", .{ nav.name.fmt(ip), lib_name_slice });4699 break :decl_name try o.builder.strtabStringFmt("{}|{s}", .{ nav.name.fmt(ip), lib_name_slice });
...@@ -5192,8 +5192,8 @@ pub const FuncGen = struct {...@@ -5192,8 +5192,8 @@ pub const FuncGen = struct {
5192 const ip = &zcu.intern_pool;5192 const ip = &zcu.intern_pool;
5193 const callee_ty = self.typeOf(pl_op.operand);5193 const callee_ty = self.typeOf(pl_op.operand);
5194 const zig_fn_ty = switch (callee_ty.zigTypeTag(zcu)) {5194 const zig_fn_ty = switch (callee_ty.zigTypeTag(zcu)) {
5195 .Fn => callee_ty,5195 .@"fn" => callee_ty,
5196 .Pointer => callee_ty.childType(zcu),5196 .pointer => callee_ty.childType(zcu),
5197 else => unreachable,5197 else => unreachable,
5198 };5198 };
5199 const fn_info = zcu.typeToFunc(zig_fn_ty).?;5199 const fn_info = zcu.typeToFunc(zig_fn_ty).?;
...@@ -5410,7 +5410,7 @@ pub const FuncGen = struct {...@@ -5410,7 +5410,7 @@ pub const FuncGen = struct {
5410 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);5410 try attributes.addParamAttr(llvm_arg_i, .@"noalias", &o.builder);
5411 }5411 }
5412 }5412 }
5413 if (param_ty.zigTypeTag(zcu) != .Optional) {5413 if (param_ty.zigTypeTag(zcu) != .optional) {
5414 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);5414 try attributes.addParamAttr(llvm_arg_i, .nonnull, &o.builder);
5415 }5415 }
5416 if (ptr_info.flags.is_const) {5416 if (ptr_info.flags.is_const) {
...@@ -5773,9 +5773,9 @@ pub const FuncGen = struct {...@@ -5773,9 +5773,9 @@ pub const FuncGen = struct {
5773 const zcu = pt.zcu;5773 const zcu = pt.zcu;
5774 const scalar_ty = operand_ty.scalarType(zcu);5774 const scalar_ty = operand_ty.scalarType(zcu);
5775 const int_ty = switch (scalar_ty.zigTypeTag(zcu)) {5775 const int_ty = switch (scalar_ty.zigTypeTag(zcu)) {
5776 .Enum => scalar_ty.intTagType(zcu),5776 .@"enum" => scalar_ty.intTagType(zcu),
5777 .Int, .Bool, .Pointer, .ErrorSet => scalar_ty,5777 .int, .bool, .pointer, .error_set => scalar_ty,
5778 .Optional => blk: {5778 .optional => blk: {
5779 const payload_ty = operand_ty.optionalChild(zcu);5779 const payload_ty = operand_ty.optionalChild(zcu);
5780 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu) or5780 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu) or
5781 operand_ty.optionalReprIsPayload(zcu))5781 operand_ty.optionalReprIsPayload(zcu))
...@@ -5848,7 +5848,7 @@ pub const FuncGen = struct {...@@ -5848,7 +5848,7 @@ pub const FuncGen = struct {
5848 );5848 );
5849 return phi.toValue();5849 return phi.toValue();
5850 },5850 },
5851 .Float => return self.buildFloatCmp(fast, op, operand_ty, .{ lhs, rhs }),5851 .float => return self.buildFloatCmp(fast, op, operand_ty, .{ lhs, rhs }),
5852 else => unreachable,5852 else => unreachable,
5853 };5853 };
5854 const is_signed = int_ty.isSignedInt(zcu);5854 const is_signed = int_ty.isSignedInt(zcu);
...@@ -5909,7 +5909,7 @@ pub const FuncGen = struct {...@@ -5909,7 +5909,7 @@ pub const FuncGen = struct {
5909 // a pointer to it. LLVM IR allows the call instruction to use function bodies instead5909 // a pointer to it. LLVM IR allows the call instruction to use function bodies instead
5910 // of function pointers, however the phi makes it a runtime value and therefore5910 // of function pointers, however the phi makes it a runtime value and therefore
5911 // the LLVM type has to be wrapped in a pointer.5911 // the LLVM type has to be wrapped in a pointer.
5912 if (inst_ty.zigTypeTag(zcu) == .Fn or isByRef(inst_ty, zcu)) {5912 if (inst_ty.zigTypeTag(zcu) == .@"fn" or isByRef(inst_ty, zcu)) {
5913 break :ty .ptr;5913 break :ty .ptr;
5914 }5914 }
5915 break :ty raw_llvm_ty;5915 break :ty raw_llvm_ty;
...@@ -6605,7 +6605,7 @@ pub const FuncGen = struct {...@@ -6605,7 +6605,7 @@ pub const FuncGen = struct {
6605 if (!isByRef(struct_ty, zcu)) {6605 if (!isByRef(struct_ty, zcu)) {
6606 assert(!isByRef(field_ty, zcu));6606 assert(!isByRef(field_ty, zcu));
6607 switch (struct_ty.zigTypeTag(zcu)) {6607 switch (struct_ty.zigTypeTag(zcu)) {
6608 .Struct => switch (struct_ty.containerLayout(zcu)) {6608 .@"struct" => switch (struct_ty.containerLayout(zcu)) {
6609 .@"packed" => {6609 .@"packed" => {
6610 const struct_type = zcu.typeToStruct(struct_ty).?;6610 const struct_type = zcu.typeToStruct(struct_ty).?;
6611 const bit_offset = pt.structPackedFieldBitOffset(struct_type, field_index);6611 const bit_offset = pt.structPackedFieldBitOffset(struct_type, field_index);
...@@ -6614,7 +6614,7 @@ pub const FuncGen = struct {...@@ -6614,7 +6614,7 @@ pub const FuncGen = struct {
6614 try o.builder.intValue(containing_int.typeOfWip(&self.wip), bit_offset);6614 try o.builder.intValue(containing_int.typeOfWip(&self.wip), bit_offset);
6615 const shifted_value = try self.wip.bin(.lshr, containing_int, shift_amt, "");6615 const shifted_value = try self.wip.bin(.lshr, containing_int, shift_amt, "");
6616 const elem_llvm_ty = try o.lowerType(field_ty);6616 const elem_llvm_ty = try o.lowerType(field_ty);
6617 if (field_ty.zigTypeTag(zcu) == .Float or field_ty.zigTypeTag(zcu) == .Vector) {6617 if (field_ty.zigTypeTag(zcu) == .float or field_ty.zigTypeTag(zcu) == .vector) {
6618 const same_size_int = try o.builder.intType(@intCast(field_ty.bitSize(zcu)));6618 const same_size_int = try o.builder.intType(@intCast(field_ty.bitSize(zcu)));
6619 const truncated_int =6619 const truncated_int =
6620 try self.wip.cast(.trunc, shifted_value, same_size_int, "");6620 try self.wip.cast(.trunc, shifted_value, same_size_int, "");
...@@ -6632,11 +6632,11 @@ pub const FuncGen = struct {...@@ -6632,11 +6632,11 @@ pub const FuncGen = struct {
6632 return self.wip.extractValue(struct_llvm_val, &.{llvm_field_index}, "");6632 return self.wip.extractValue(struct_llvm_val, &.{llvm_field_index}, "");
6633 },6633 },
6634 },6634 },
6635 .Union => {6635 .@"union" => {
6636 assert(struct_ty.containerLayout(zcu) == .@"packed");6636 assert(struct_ty.containerLayout(zcu) == .@"packed");
6637 const containing_int = struct_llvm_val;6637 const containing_int = struct_llvm_val;
6638 const elem_llvm_ty = try o.lowerType(field_ty);6638 const elem_llvm_ty = try o.lowerType(field_ty);
6639 if (field_ty.zigTypeTag(zcu) == .Float or field_ty.zigTypeTag(zcu) == .Vector) {6639 if (field_ty.zigTypeTag(zcu) == .float or field_ty.zigTypeTag(zcu) == .vector) {
6640 const same_size_int = try o.builder.intType(@intCast(field_ty.bitSize(zcu)));6640 const same_size_int = try o.builder.intType(@intCast(field_ty.bitSize(zcu)));
6641 const truncated_int =6641 const truncated_int =
6642 try self.wip.cast(.trunc, containing_int, same_size_int, "");6642 try self.wip.cast(.trunc, containing_int, same_size_int, "");
...@@ -6654,7 +6654,7 @@ pub const FuncGen = struct {...@@ -6654,7 +6654,7 @@ pub const FuncGen = struct {
6654 }6654 }
66556655
6656 switch (struct_ty.zigTypeTag(zcu)) {6656 switch (struct_ty.zigTypeTag(zcu)) {
6657 .Struct => {6657 .@"struct" => {
6658 const layout = struct_ty.containerLayout(zcu);6658 const layout = struct_ty.containerLayout(zcu);
6659 assert(layout != .@"packed");6659 assert(layout != .@"packed");
6660 const struct_llvm_ty = try o.lowerType(struct_ty);6660 const struct_llvm_ty = try o.lowerType(struct_ty);
...@@ -6677,7 +6677,7 @@ pub const FuncGen = struct {...@@ -6677,7 +6677,7 @@ pub const FuncGen = struct {
6677 return self.load(field_ptr, field_ptr_ty);6677 return self.load(field_ptr, field_ptr_ty);
6678 }6678 }
6679 },6679 },
6680 .Union => {6680 .@"union" => {
6681 const union_llvm_ty = try o.lowerType(struct_ty);6681 const union_llvm_ty = try o.lowerType(struct_ty);
6682 const layout = struct_ty.unionGetLayout(zcu);6682 const layout = struct_ty.unionGetLayout(zcu);
6683 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));6683 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));
...@@ -6934,7 +6934,7 @@ pub const FuncGen = struct {...@@ -6934,7 +6934,7 @@ pub const FuncGen = struct {
6934 if (output != .none) {6934 if (output != .none) {
6935 const output_inst = try self.resolveInst(output);6935 const output_inst = try self.resolveInst(output);
6936 const output_ty = self.typeOf(output);6936 const output_ty = self.typeOf(output);
6937 assert(output_ty.zigTypeTag(zcu) == .Pointer);6937 assert(output_ty.zigTypeTag(zcu) == .pointer);
6938 const elem_llvm_ty = try o.lowerPtrElemTy(output_ty.childType(zcu));6938 const elem_llvm_ty = try o.lowerPtrElemTy(output_ty.childType(zcu));
69396939
6940 switch (constraint[0]) {6940 switch (constraint[0]) {
...@@ -8280,7 +8280,7 @@ pub const FuncGen = struct {...@@ -8280,7 +8280,7 @@ pub const FuncGen = struct {
8280 .gte => .sge,8280 .gte => .sge,
8281 };8281 };
82828282
8283 if (ty.zigTypeTag(zcu) == .Vector) {8283 if (ty.zigTypeTag(zcu) == .vector) {
8284 const vec_len = ty.vectorLen(zcu);8284 const vec_len = ty.vectorLen(zcu);
8285 const vector_result_ty = try o.builder.vectorType(.normal, vec_len, .i32);8285 const vector_result_ty = try o.builder.vectorType(.normal, vec_len, .i32);
82868286
...@@ -8457,7 +8457,7 @@ pub const FuncGen = struct {...@@ -8457,7 +8457,7 @@ pub const FuncGen = struct {
8457 ([1]Builder.Type{scalar_llvm_ty} ** 3)[0..params.len],8457 ([1]Builder.Type{scalar_llvm_ty} ** 3)[0..params.len],
8458 scalar_llvm_ty,8458 scalar_llvm_ty,
8459 );8459 );
8460 if (ty.zigTypeTag(zcu) == .Vector) {8460 if (ty.zigTypeTag(zcu) == .vector) {
8461 const result = try o.builder.poisonValue(llvm_ty);8461 const result = try o.builder.poisonValue(llvm_ty);
8462 return self.buildElementwiseCall(libc_fn, &params, result, ty.vectorLen(zcu));8462 return self.buildElementwiseCall(libc_fn, &params, result, ty.vectorLen(zcu));
8463 }8463 }
...@@ -8658,7 +8658,7 @@ pub const FuncGen = struct {...@@ -8658,7 +8658,7 @@ pub const FuncGen = struct {
8658 const scalar_ty = operand_ty.scalarType(zcu);8658 const scalar_ty = operand_ty.scalarType(zcu);
86598659
8660 switch (scalar_ty.zigTypeTag(zcu)) {8660 switch (scalar_ty.zigTypeTag(zcu)) {
8661 .Int => return self.wip.callIntrinsic(8661 .int => return self.wip.callIntrinsic(
8662 .normal,8662 .normal,
8663 .none,8663 .none,
8664 .abs,8664 .abs,
...@@ -8666,7 +8666,7 @@ pub const FuncGen = struct {...@@ -8666,7 +8666,7 @@ pub const FuncGen = struct {
8666 &.{ operand, try o.builder.intValue(.i1, 0) },8666 &.{ operand, try o.builder.intValue(.i1, 0) },
8667 "",8667 "",
8668 ),8668 ),
8669 .Float => return self.buildFloatOp(.fabs, .normal, operand_ty, 1, .{operand}),8669 .float => return self.buildFloatOp(.fabs, .normal, operand_ty, 1, .{operand}),
8670 else => unreachable,8670 else => unreachable,
8671 }8671 }
8672 }8672 }
...@@ -8806,11 +8806,11 @@ pub const FuncGen = struct {...@@ -8806,11 +8806,11 @@ pub const FuncGen = struct {
8806 return self.wip.conv(.unsigned, operand, llvm_dest_ty, "");8806 return self.wip.conv(.unsigned, operand, llvm_dest_ty, "");
8807 }8807 }
88088808
8809 if (operand_ty.zigTypeTag(zcu) == .Int and inst_ty.isPtrAtRuntime(zcu)) {8809 if (operand_ty.zigTypeTag(zcu) == .int and inst_ty.isPtrAtRuntime(zcu)) {
8810 return self.wip.cast(.inttoptr, operand, llvm_dest_ty, "");8810 return self.wip.cast(.inttoptr, operand, llvm_dest_ty, "");
8811 }8811 }
88128812
8813 if (operand_ty.zigTypeTag(zcu) == .Vector and inst_ty.zigTypeTag(zcu) == .Array) {8813 if (operand_ty.zigTypeTag(zcu) == .vector and inst_ty.zigTypeTag(zcu) == .array) {
8814 const elem_ty = operand_ty.childType(zcu);8814 const elem_ty = operand_ty.childType(zcu);
8815 if (!result_is_ref) {8815 if (!result_is_ref) {
8816 return self.ng.todo("implement bitcast vector to non-ref array", .{});8816 return self.ng.todo("implement bitcast vector to non-ref array", .{});
...@@ -8837,7 +8837,7 @@ pub const FuncGen = struct {...@@ -8837,7 +8837,7 @@ pub const FuncGen = struct {
8837 }8837 }
8838 }8838 }
8839 return array_ptr;8839 return array_ptr;
8840 } else if (operand_ty.zigTypeTag(zcu) == .Array and inst_ty.zigTypeTag(zcu) == .Vector) {8840 } else if (operand_ty.zigTypeTag(zcu) == .array and inst_ty.zigTypeTag(zcu) == .vector) {
8841 const elem_ty = operand_ty.childType(zcu);8841 const elem_ty = operand_ty.childType(zcu);
8842 const llvm_vector_ty = try o.lowerType(inst_ty);8842 const llvm_vector_ty = try o.lowerType(inst_ty);
8843 if (!operand_is_ref) return self.ng.todo("implement bitcast non-ref array to vector", .{});8843 if (!operand_is_ref) return self.ng.todo("implement bitcast non-ref array to vector", .{});
...@@ -8883,7 +8883,7 @@ pub const FuncGen = struct {...@@ -8883,7 +8883,7 @@ pub const FuncGen = struct {
8883 }8883 }
88848884
8885 if (llvm_dest_ty.isStruct(&o.builder) or8885 if (llvm_dest_ty.isStruct(&o.builder) or
8886 ((operand_ty.zigTypeTag(zcu) == .Vector or inst_ty.zigTypeTag(zcu) == .Vector) and8886 ((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and
8887 operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))8887 operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
8888 {8888 {
8889 // Both our operand and our result are values, not pointers,8889 // Both our operand and our result are values, not pointers,
...@@ -9687,7 +9687,7 @@ pub const FuncGen = struct {...@@ -9687,7 +9687,7 @@ pub const FuncGen = struct {
9687 // If not an even byte-multiple, we need zero-extend + shift-left 1 byte9687 // If not an even byte-multiple, we need zero-extend + shift-left 1 byte
9688 // The truncated result at the end will be the correct bswap9688 // The truncated result at the end will be the correct bswap
9689 const scalar_ty = try o.builder.intType(@intCast(bits + 8));9689 const scalar_ty = try o.builder.intType(@intCast(bits + 8));
9690 if (operand_ty.zigTypeTag(zcu) == .Vector) {9690 if (operand_ty.zigTypeTag(zcu) == .vector) {
9691 const vec_len = operand_ty.vectorLen(zcu);9691 const vec_len = operand_ty.vectorLen(zcu);
9692 llvm_operand_ty = try o.builder.vectorType(.normal, vec_len, scalar_ty);9692 llvm_operand_ty = try o.builder.vectorType(.normal, vec_len, scalar_ty);
9693 } else llvm_operand_ty = scalar_ty;9693 } else llvm_operand_ty = scalar_ty;
...@@ -9993,7 +9993,7 @@ pub const FuncGen = struct {...@@ -9993,7 +9993,7 @@ pub const FuncGen = struct {
9993 else => unreachable,9993 else => unreachable,
9994 }, &.{llvm_operand_ty}, &.{operand}, ""),9994 }, &.{llvm_operand_ty}, &.{operand}, ""),
9995 .Min, .Max => switch (scalar_ty.zigTypeTag(zcu)) {9995 .Min, .Max => switch (scalar_ty.zigTypeTag(zcu)) {
9996 .Int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) {9996 .int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) {
9997 .Min => if (scalar_ty.isSignedInt(zcu))9997 .Min => if (scalar_ty.isSignedInt(zcu))
9998 .@"vector.reduce.smin"9998 .@"vector.reduce.smin"
9999 else9999 else
...@@ -10004,7 +10004,7 @@ pub const FuncGen = struct {...@@ -10004,7 +10004,7 @@ pub const FuncGen = struct {
10004 .@"vector.reduce.umax",10004 .@"vector.reduce.umax",
10005 else => unreachable,10005 else => unreachable,
10006 }, &.{llvm_operand_ty}, &.{operand}, ""),10006 }, &.{llvm_operand_ty}, &.{operand}, ""),
10007 .Float => if (intrinsicsAllowed(scalar_ty, target))10007 .float => if (intrinsicsAllowed(scalar_ty, target))
10008 return self.wip.callIntrinsic(fast, .none, switch (reduce.operation) {10008 return self.wip.callIntrinsic(fast, .none, switch (reduce.operation) {
10009 .Min => .@"vector.reduce.fmin",10009 .Min => .@"vector.reduce.fmin",
10010 .Max => .@"vector.reduce.fmax",10010 .Max => .@"vector.reduce.fmax",
...@@ -10013,12 +10013,12 @@ pub const FuncGen = struct {...@@ -10013,12 +10013,12 @@ pub const FuncGen = struct {
10013 else => unreachable,10013 else => unreachable,
10014 },10014 },
10015 .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) {10015 .Add, .Mul => switch (scalar_ty.zigTypeTag(zcu)) {
10016 .Int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) {10016 .int => return self.wip.callIntrinsic(.normal, .none, switch (reduce.operation) {
10017 .Add => .@"vector.reduce.add",10017 .Add => .@"vector.reduce.add",
10018 .Mul => .@"vector.reduce.mul",10018 .Mul => .@"vector.reduce.mul",
10019 else => unreachable,10019 else => unreachable,
10020 }, &.{llvm_operand_ty}, &.{operand}, ""),10020 }, &.{llvm_operand_ty}, &.{operand}, ""),
10021 .Float => if (intrinsicsAllowed(scalar_ty, target))10021 .float => if (intrinsicsAllowed(scalar_ty, target))
10022 return self.wip.callIntrinsic(fast, .none, switch (reduce.operation) {10022 return self.wip.callIntrinsic(fast, .none, switch (reduce.operation) {
10023 .Add => .@"vector.reduce.fadd",10023 .Add => .@"vector.reduce.fadd",
10024 .Mul => .@"vector.reduce.fmul",10024 .Mul => .@"vector.reduce.fmul",
...@@ -10095,7 +10095,7 @@ pub const FuncGen = struct {...@@ -10095,7 +10095,7 @@ pub const FuncGen = struct {
10095 const llvm_result_ty = try o.lowerType(result_ty);10095 const llvm_result_ty = try o.lowerType(result_ty);
1009610096
10097 switch (result_ty.zigTypeTag(zcu)) {10097 switch (result_ty.zigTypeTag(zcu)) {
10098 .Vector => {10098 .vector => {
10099 var vector = try o.builder.poisonValue(llvm_result_ty);10099 var vector = try o.builder.poisonValue(llvm_result_ty);
10100 for (elements, 0..) |elem, i| {10100 for (elements, 0..) |elem, i| {
10101 const index_u32 = try o.builder.intValue(.i32, i);10101 const index_u32 = try o.builder.intValue(.i32, i);
...@@ -10104,7 +10104,7 @@ pub const FuncGen = struct {...@@ -10104,7 +10104,7 @@ pub const FuncGen = struct {
10104 }10104 }
10105 return vector;10105 return vector;
10106 },10106 },
10107 .Struct => {10107 .@"struct" => {
10108 if (zcu.typeToPackedStruct(result_ty)) |struct_type| {10108 if (zcu.typeToPackedStruct(result_ty)) |struct_type| {
10109 const backing_int_ty = struct_type.backingIntTypeUnordered(ip);10109 const backing_int_ty = struct_type.backingIntTypeUnordered(ip);
10110 assert(backing_int_ty != .none);10110 assert(backing_int_ty != .none);
...@@ -10170,7 +10170,7 @@ pub const FuncGen = struct {...@@ -10170,7 +10170,7 @@ pub const FuncGen = struct {
10170 return result;10170 return result;
10171 }10171 }
10172 },10172 },
10173 .Array => {10173 .array => {
10174 assert(isByRef(result_ty, zcu));10174 assert(isByRef(result_ty, zcu));
1017510175
10176 const llvm_usize = try o.lowerType(Type.usize);10176 const llvm_usize = try o.lowerType(Type.usize);
...@@ -10577,7 +10577,7 @@ pub const FuncGen = struct {...@@ -10577,7 +10577,7 @@ pub const FuncGen = struct {
10577 const zcu = pt.zcu;10577 const zcu = pt.zcu;
10578 const struct_ty = struct_ptr_ty.childType(zcu);10578 const struct_ty = struct_ptr_ty.childType(zcu);
10579 switch (struct_ty.zigTypeTag(zcu)) {10579 switch (struct_ty.zigTypeTag(zcu)) {
10580 .Struct => switch (struct_ty.containerLayout(zcu)) {10580 .@"struct" => switch (struct_ty.containerLayout(zcu)) {
10581 .@"packed" => {10581 .@"packed" => {
10582 const result_ty = self.typeOfIndex(inst);10582 const result_ty = self.typeOfIndex(inst);
10583 const result_ty_info = result_ty.ptrInfo(zcu);10583 const result_ty_info = result_ty.ptrInfo(zcu);
...@@ -10618,7 +10618,7 @@ pub const FuncGen = struct {...@@ -10618,7 +10618,7 @@ pub const FuncGen = struct {
10618 }10618 }
10619 },10619 },
10620 },10620 },
10621 .Union => {10621 .@"union" => {
10622 const layout = struct_ty.unionGetLayout(zcu);10622 const layout = struct_ty.unionGetLayout(zcu);
10623 if (layout.payload_size == 0 or struct_ty.containerLayout(zcu) == .@"packed") return struct_ptr;10623 if (layout.payload_size == 0 or struct_ty.containerLayout(zcu) == .@"packed") return struct_ptr;
10624 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));10624 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));
...@@ -10761,7 +10761,7 @@ pub const FuncGen = struct {...@@ -10761,7 +10761,7 @@ pub const FuncGen = struct {
10761 return result_ptr;10761 return result_ptr;
10762 }10762 }
1076310763
10764 if (elem_ty.zigTypeTag(zcu) == .Float or elem_ty.zigTypeTag(zcu) == .Vector) {10764 if (elem_ty.zigTypeTag(zcu) == .float or elem_ty.zigTypeTag(zcu) == .vector) {
10765 const same_size_int = try o.builder.intType(@intCast(elem_bits));10765 const same_size_int = try o.builder.intType(@intCast(elem_bits));
10766 const truncated_int = try self.wip.cast(.trunc, shifted_value, same_size_int, "");10766 const truncated_int = try self.wip.cast(.trunc, shifted_value, same_size_int, "");
10767 return self.wip.cast(.bitcast, truncated_int, elem_llvm_ty, "");10767 return self.wip.cast(.bitcast, truncated_int, elem_llvm_ty, "");
...@@ -11432,7 +11432,7 @@ const ParamTypeIterator = struct {...@@ -11432,7 +11432,7 @@ const ParamTypeIterator = struct {
11432 it.zig_index += 1;11432 it.zig_index += 1;
11433 it.llvm_index += 1;11433 it.llvm_index += 1;
11434 if (ty.isSlice(zcu) or11434 if (ty.isSlice(zcu) or
11435 (ty.zigTypeTag(zcu) == .Optional and ty.optionalChild(zcu).isSlice(zcu) and !ty.ptrAllowsZero(zcu)))11435 (ty.zigTypeTag(zcu) == .optional and ty.optionalChild(zcu).isSlice(zcu) and !ty.ptrAllowsZero(zcu)))
11436 {11436 {
11437 it.llvm_index += 1;11437 it.llvm_index += 1;
11438 return .slice;11438 return .slice;
...@@ -11707,8 +11707,8 @@ fn ccAbiPromoteInt(...@@ -11707,8 +11707,8 @@ fn ccAbiPromoteInt(
11707 else => {},11707 else => {},
11708 }11708 }
11709 const int_info = switch (ty.zigTypeTag(zcu)) {11709 const int_info = switch (ty.zigTypeTag(zcu)) {
11710 .Bool => Type.u1.intInfo(zcu),11710 .bool => Type.u1.intInfo(zcu),
11711 .Int, .Enum, .ErrorSet => ty.intInfo(zcu),11711 .int, .@"enum", .error_set => ty.intInfo(zcu),
11712 else => return null,11712 else => return null,
11713 };11713 };
11714 return switch (target.os.tag) {11714 return switch (target.os.tag) {
...@@ -11753,30 +11753,30 @@ fn isByRef(ty: Type, zcu: *Zcu) bool {...@@ -11753,30 +11753,30 @@ fn isByRef(ty: Type, zcu: *Zcu) bool {
11753 const ip = &zcu.intern_pool;11753 const ip = &zcu.intern_pool;
1175411754
11755 switch (ty.zigTypeTag(zcu)) {11755 switch (ty.zigTypeTag(zcu)) {
11756 .Type,11756 .type,
11757 .ComptimeInt,11757 .comptime_int,
11758 .ComptimeFloat,11758 .comptime_float,
11759 .EnumLiteral,11759 .enum_literal,
11760 .Undefined,11760 .undefined,
11761 .Null,11761 .null,
11762 .Opaque,11762 .@"opaque",
11763 => unreachable,11763 => unreachable,
1176411764
11765 .NoReturn,11765 .noreturn,
11766 .Void,11766 .void,
11767 .Bool,11767 .bool,
11768 .Int,11768 .int,
11769 .Float,11769 .float,
11770 .Pointer,11770 .pointer,
11771 .ErrorSet,11771 .error_set,
11772 .Fn,11772 .@"fn",
11773 .Enum,11773 .@"enum",
11774 .Vector,11774 .vector,
11775 .AnyFrame,11775 .@"anyframe",
11776 => return false,11776 => return false,
1177711777
11778 .Array, .Frame => return ty.hasRuntimeBits(zcu),11778 .array, .frame => return ty.hasRuntimeBits(zcu),
11779 .Struct => {11779 .@"struct" => {
11780 const struct_type = switch (ip.indexToKey(ty.toIntern())) {11780 const struct_type = switch (ip.indexToKey(ty.toIntern())) {
11781 .anon_struct_type => |tuple| {11781 .anon_struct_type => |tuple| {
11782 var count: usize = 0;11782 var count: usize = 0;
...@@ -11807,18 +11807,18 @@ fn isByRef(ty: Type, zcu: *Zcu) bool {...@@ -11807,18 +11807,18 @@ fn isByRef(ty: Type, zcu: *Zcu) bool {
11807 }11807 }
11808 return false;11808 return false;
11809 },11809 },
11810 .Union => switch (ty.containerLayout(zcu)) {11810 .@"union" => switch (ty.containerLayout(zcu)) {
11811 .@"packed" => return false,11811 .@"packed" => return false,
11812 else => return ty.hasRuntimeBits(zcu),11812 else => return ty.hasRuntimeBits(zcu),
11813 },11813 },
11814 .ErrorUnion => {11814 .error_union => {
11815 const payload_ty = ty.errorUnionPayload(zcu);11815 const payload_ty = ty.errorUnionPayload(zcu);
11816 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {11816 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
11817 return false;11817 return false;
11818 }11818 }
11819 return true;11819 return true;
11820 },11820 },
11821 .Optional => {11821 .optional => {
11822 const payload_ty = ty.optionalChild(zcu);11822 const payload_ty = ty.optionalChild(zcu);
11823 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {11823 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
11824 return false;11824 return false;
...@@ -11833,21 +11833,21 @@ fn isByRef(ty: Type, zcu: *Zcu) bool {...@@ -11833,21 +11833,21 @@ fn isByRef(ty: Type, zcu: *Zcu) bool {
1183311833
11834fn isScalar(zcu: *Zcu, ty: Type) bool {11834fn isScalar(zcu: *Zcu, ty: Type) bool {
11835 return switch (ty.zigTypeTag(zcu)) {11835 return switch (ty.zigTypeTag(zcu)) {
11836 .Void,11836 .void,
11837 .Bool,11837 .bool,
11838 .NoReturn,11838 .noreturn,
11839 .Int,11839 .int,
11840 .Float,11840 .float,
11841 .Pointer,11841 .pointer,
11842 .Optional,11842 .optional,
11843 .ErrorSet,11843 .error_set,
11844 .Enum,11844 .@"enum",
11845 .AnyFrame,11845 .@"anyframe",
11846 .Vector,11846 .vector,
11847 => true,11847 => true,
1184811848
11849 .Struct => ty.containerLayout(zcu) == .@"packed",11849 .@"struct" => ty.containerLayout(zcu) == .@"packed",
11850 .Union => ty.containerLayout(zcu) == .@"packed",11850 .@"union" => ty.containerLayout(zcu) == .@"packed",
11851 else => false,11851 else => false,
11852 };11852 };
11853}11853}
src/codegen/llvm/BitcodeReader.zig+3-3
...@@ -273,7 +273,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void {...@@ -273,7 +273,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void {
273 };273 };
274 try state.abbrevs.abbrevs.ensureTotalCapacity(274 try state.abbrevs.abbrevs.ensureTotalCapacity(
275 bc.allocator,275 bc.allocator,
276 @typeInfo(Abbrev.Builtin).Enum.fields.len + abbrevs.len,276 @typeInfo(Abbrev.Builtin).@"enum".fields.len + abbrevs.len,
277 );277 );
278278
279 assert(state.abbrevs.abbrevs.items.len == @intFromEnum(Abbrev.Builtin.end_block));279 assert(state.abbrevs.abbrevs.items.len == @intFromEnum(Abbrev.Builtin.end_block));
...@@ -309,7 +309,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void {...@@ -309,7 +309,7 @@ fn startBlock(bc: *BitcodeReader, block_id: ?u32, new_abbrev_len: u6) !void {
309 .{ .encoding = .{ .vbr = 6 } }, // ops309 .{ .encoding = .{ .vbr = 6 } }, // ops
310 },310 },
311 });311 });
312 assert(state.abbrevs.abbrevs.items.len == @typeInfo(Abbrev.Builtin).Enum.fields.len);312 assert(state.abbrevs.abbrevs.items.len == @typeInfo(Abbrev.Builtin).@"enum".fields.len);
313 for (abbrevs) |abbrev| try state.abbrevs.addAbbrevAssumeCapacity(bc.allocator, abbrev);313 for (abbrevs) |abbrev| try state.abbrevs.addAbbrevAssumeCapacity(bc.allocator, abbrev);
314}314}
315315
...@@ -448,7 +448,7 @@ const Abbrev = struct {...@@ -448,7 +448,7 @@ const Abbrev = struct {
448 define_abbrev,448 define_abbrev,
449 unabbrev_record,449 unabbrev_record,
450450
451 const first_record_id: u32 = std.math.maxInt(u32) - @typeInfo(Builtin).Enum.fields.len + 1;451 const first_record_id: u32 = std.math.maxInt(u32) - @typeInfo(Builtin).@"enum".fields.len + 1;
452 fn toRecordId(builtin: Builtin) u32 {452 fn toRecordId(builtin: Builtin) u32 {
453 return first_record_id + @intFromEnum(builtin);453 return first_record_id + @intFromEnum(builtin);
454 }454 }
src/codegen/llvm/Builder.zig+47-47
...@@ -1115,7 +1115,7 @@ pub const Attribute = union(Kind) {...@@ -1115,7 +1115,7 @@ pub const Attribute = union(Kind) {
1115 => |kind| {1115 => |kind| {
1116 const field = comptime blk: {1116 const field = comptime blk: {
1117 @setEvalBranchQuota(10_000);1117 @setEvalBranchQuota(10_000);
1118 for (@typeInfo(Attribute).Union.fields) |field| {1118 for (@typeInfo(Attribute).@"union".fields) |field| {
1119 if (std.mem.eql(u8, field.name, @tagName(kind))) break :blk field;1119 if (std.mem.eql(u8, field.name, @tagName(kind))) break :blk field;
1120 }1120 }
1121 unreachable;1121 unreachable;
...@@ -1232,11 +1232,11 @@ pub const Attribute = union(Kind) {...@@ -1232,11 +1232,11 @@ pub const Attribute = union(Kind) {
1232 .dereferenceable_or_null,1232 .dereferenceable_or_null,
1233 => |size| try writer.print(" {s}({d})", .{ @tagName(attribute), size }),1233 => |size| try writer.print(" {s}({d})", .{ @tagName(attribute), size }),
1234 .nofpclass => |fpclass| {1234 .nofpclass => |fpclass| {
1235 const Int = @typeInfo(FpClass).Struct.backing_integer.?;1235 const Int = @typeInfo(FpClass).@"struct".backing_integer.?;
1236 try writer.print(" {s}(", .{@tagName(attribute)});1236 try writer.print(" {s}(", .{@tagName(attribute)});
1237 var any = false;1237 var any = false;
1238 var remaining: Int = @bitCast(fpclass);1238 var remaining: Int = @bitCast(fpclass);
1239 inline for (@typeInfo(FpClass).Struct.decls) |decl| {1239 inline for (@typeInfo(FpClass).@"struct".decls) |decl| {
1240 const pattern: Int = @bitCast(@field(FpClass, decl.name));1240 const pattern: Int = @bitCast(@field(FpClass, decl.name));
1241 if (remaining & pattern == pattern) {1241 if (remaining & pattern == pattern) {
1242 if (!any) {1242 if (!any) {
...@@ -1259,7 +1259,7 @@ pub const Attribute = union(Kind) {...@@ -1259,7 +1259,7 @@ pub const Attribute = union(Kind) {
1259 .allockind => |allockind| {1259 .allockind => |allockind| {
1260 try writer.print(" {s}(\"", .{@tagName(attribute)});1260 try writer.print(" {s}(\"", .{@tagName(attribute)});
1261 var any = false;1261 var any = false;
1262 inline for (@typeInfo(AllocKind).Struct.fields) |field| {1262 inline for (@typeInfo(AllocKind).@"struct".fields) |field| {
1263 if (comptime std.mem.eql(u8, field.name, "_")) continue;1263 if (comptime std.mem.eql(u8, field.name, "_")) continue;
1264 if (@field(allockind, field.name)) {1264 if (@field(allockind, field.name)) {
1265 if (!any) {1265 if (!any) {
...@@ -1418,7 +1418,7 @@ pub const Attribute = union(Kind) {...@@ -1418,7 +1418,7 @@ pub const Attribute = union(Kind) {
1418 none = std.math.maxInt(u32),1418 none = std.math.maxInt(u32),
1419 _,1419 _,
14201420
1421 pub const len = @typeInfo(Kind).Enum.fields.len - 2;1421 pub const len = @typeInfo(Kind).@"enum".fields.len - 2;
14221422
1423 pub fn fromString(str: String) Kind {1423 pub fn fromString(str: String) Kind {
1424 assert(!str.isAnon());1424 assert(!str.isAnon());
...@@ -5037,7 +5037,7 @@ pub const Function = struct {...@@ -5037,7 +5037,7 @@ pub const Function = struct {
5037 index: Instruction.ExtraIndex,5037 index: Instruction.ExtraIndex,
5038 ) struct { data: T, trail: ExtraDataTrail } {5038 ) struct { data: T, trail: ExtraDataTrail } {
5039 var result: T = undefined;5039 var result: T = undefined;
5040 const fields = @typeInfo(T).Struct.fields;5040 const fields = @typeInfo(T).@"struct".fields;
5041 inline for (fields, self.extra[index..][0..fields.len]) |field, value|5041 inline for (fields, self.extra[index..][0..fields.len]) |field, value|
5042 @field(result, field.name) = switch (field.type) {5042 @field(result, field.name) = switch (field.type) {
5043 u32 => value,5043 u32 => value,
...@@ -6151,7 +6151,7 @@ pub const WipFunction = struct {...@@ -6151,7 +6151,7 @@ pub const WipFunction = struct {
61516151
6152 fn addExtra(wip_extra: *@This(), extra: anytype) Instruction.ExtraIndex {6152 fn addExtra(wip_extra: *@This(), extra: anytype) Instruction.ExtraIndex {
6153 const result = wip_extra.index;6153 const result = wip_extra.index;
6154 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {6154 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| {
6155 const value = @field(extra, field.name);6155 const value = @field(extra, field.name);
6156 wip_extra.items[wip_extra.index] = switch (field.type) {6156 wip_extra.items[wip_extra.index] = switch (field.type) {
6157 u32 => value,6157 u32 => value,
...@@ -6175,7 +6175,7 @@ pub const WipFunction = struct {...@@ -6175,7 +6175,7 @@ pub const WipFunction = struct {
6175 }6175 }
61766176
6177 fn appendSlice(wip_extra: *@This(), slice: anytype) void {6177 fn appendSlice(wip_extra: *@This(), slice: anytype) void {
6178 if (@typeInfo(@TypeOf(slice)).Pointer.child == Value)6178 if (@typeInfo(@TypeOf(slice)).pointer.child == Value)
6179 @compileError("use appendMappedValues");6179 @compileError("use appendMappedValues");
6180 const data: []const u32 = @ptrCast(slice);6180 const data: []const u32 = @ptrCast(slice);
6181 @memcpy(wip_extra.items[wip_extra.index..][0..data.len], data);6181 @memcpy(wip_extra.items[wip_extra.index..][0..data.len], data);
...@@ -6760,7 +6760,7 @@ pub const WipFunction = struct {...@@ -6760,7 +6760,7 @@ pub const WipFunction = struct {
6760 ) Allocator.Error!void {6760 ) Allocator.Error!void {
6761 try self.extra.ensureUnusedCapacity(6761 try self.extra.ensureUnusedCapacity(
6762 self.builder.gpa,6762 self.builder.gpa,
6763 count * (@typeInfo(Extra).Struct.fields.len + trail_len),6763 count * (@typeInfo(Extra).@"struct".fields.len + trail_len),
6764 );6764 );
6765 }6765 }
67666766
...@@ -6799,7 +6799,7 @@ pub const WipFunction = struct {...@@ -6799,7 +6799,7 @@ pub const WipFunction = struct {
67996799
6800 fn addExtraAssumeCapacity(self: *WipFunction, extra: anytype) Instruction.ExtraIndex {6800 fn addExtraAssumeCapacity(self: *WipFunction, extra: anytype) Instruction.ExtraIndex {
6801 const result: Instruction.ExtraIndex = @intCast(self.extra.items.len);6801 const result: Instruction.ExtraIndex = @intCast(self.extra.items.len);
6802 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {6802 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| {
6803 const value = @field(extra, field.name);6803 const value = @field(extra, field.name);
6804 self.extra.appendAssumeCapacity(switch (field.type) {6804 self.extra.appendAssumeCapacity(switch (field.type) {
6805 u32 => value,6805 u32 => value,
...@@ -6848,7 +6848,7 @@ pub const WipFunction = struct {...@@ -6848,7 +6848,7 @@ pub const WipFunction = struct {
6848 index: Instruction.ExtraIndex,6848 index: Instruction.ExtraIndex,
6849 ) struct { data: T, trail: ExtraDataTrail } {6849 ) struct { data: T, trail: ExtraDataTrail } {
6850 var result: T = undefined;6850 var result: T = undefined;
6851 const fields = @typeInfo(T).Struct.fields;6851 const fields = @typeInfo(T).@"struct".fields;
6852 inline for (fields, self.extra.items[index..][0..fields.len]) |field, value|6852 inline for (fields, self.extra.items[index..][0..fields.len]) |field, value|
6853 @field(result, field.name) = switch (field.type) {6853 @field(result, field.name) = switch (field.type) {
6854 u32 => value,6854 u32 => value,
...@@ -7926,17 +7926,17 @@ pub const Metadata = enum(u32) {...@@ -7926,17 +7926,17 @@ pub const Metadata = enum(u32) {
7926 writer: anytype,7926 writer: anytype,
7927 ) @TypeOf(writer).Error!void {7927 ) @TypeOf(writer).Error!void {
7928 var need_pipe = false;7928 var need_pipe = false;
7929 inline for (@typeInfo(DIFlags).Struct.fields) |field| {7929 inline for (@typeInfo(DIFlags).@"struct".fields) |field| {
7930 switch (@typeInfo(field.type)) {7930 switch (@typeInfo(field.type)) {
7931 .Bool => if (@field(self, field.name)) {7931 .bool => if (@field(self, field.name)) {
7932 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;7932 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;
7933 try writer.print("DIFlag{s}", .{field.name});7933 try writer.print("DIFlag{s}", .{field.name});
7934 },7934 },
7935 .Enum => if (@field(self, field.name) != .Zero) {7935 .@"enum" => if (@field(self, field.name) != .Zero) {
7936 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;7936 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;
7937 try writer.print("DIFlag{s}", .{@tagName(@field(self, field.name))});7937 try writer.print("DIFlag{s}", .{@tagName(@field(self, field.name))});
7938 },7938 },
7939 .Int => assert(@field(self, field.name) == 0),7939 .int => assert(@field(self, field.name) == 0),
7940 else => @compileError("bad field type: " ++ field.name ++ ": " ++7940 else => @compileError("bad field type: " ++ field.name ++ ": " ++
7941 @typeName(field.type)),7941 @typeName(field.type)),
7942 }7942 }
...@@ -7988,17 +7988,17 @@ pub const Metadata = enum(u32) {...@@ -7988,17 +7988,17 @@ pub const Metadata = enum(u32) {
7988 writer: anytype,7988 writer: anytype,
7989 ) @TypeOf(writer).Error!void {7989 ) @TypeOf(writer).Error!void {
7990 var need_pipe = false;7990 var need_pipe = false;
7991 inline for (@typeInfo(DISPFlags).Struct.fields) |field| {7991 inline for (@typeInfo(DISPFlags).@"struct".fields) |field| {
7992 switch (@typeInfo(field.type)) {7992 switch (@typeInfo(field.type)) {
7993 .Bool => if (@field(self, field.name)) {7993 .bool => if (@field(self, field.name)) {
7994 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;7994 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;
7995 try writer.print("DISPFlag{s}", .{field.name});7995 try writer.print("DISPFlag{s}", .{field.name});
7996 },7996 },
7997 .Enum => if (@field(self, field.name) != .Zero) {7997 .@"enum" => if (@field(self, field.name) != .Zero) {
7998 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;7998 if (need_pipe) try writer.writeAll(" | ") else need_pipe = true;
7999 try writer.print("DISPFlag{s}", .{@tagName(@field(self, field.name))});7999 try writer.print("DISPFlag{s}", .{@tagName(@field(self, field.name))});
8000 },8000 },
8001 .Int => assert(@field(self, field.name) == 0),8001 .int => assert(@field(self, field.name) == 0),
8002 else => @compileError("bad field type: " ++ field.name ++ ": " ++8002 else => @compileError("bad field type: " ++ field.name ++ ": " ++
8003 @typeName(field.type)),8003 @typeName(field.type)),
8004 }8004 }
...@@ -8281,16 +8281,16 @@ pub const Metadata = enum(u32) {...@@ -8281,16 +8281,16 @@ pub const Metadata = enum(u32) {
8281 }!std.fmt.Formatter(format) {8281 }!std.fmt.Formatter(format) {
8282 const Node = @TypeOf(node);8282 const Node = @TypeOf(node);
8283 const MaybeNode = switch (@typeInfo(Node)) {8283 const MaybeNode = switch (@typeInfo(Node)) {
8284 .Optional => Node,8284 .optional => Node,
8285 .Null => ?noreturn,8285 .null => ?noreturn,
8286 else => ?Node,8286 else => ?Node,
8287 };8287 };
8288 const Some = @typeInfo(MaybeNode).Optional.child;8288 const Some = @typeInfo(MaybeNode).optional.child;
8289 return .{ .data = .{8289 return .{ .data = .{
8290 .formatter = formatter,8290 .formatter = formatter,
8291 .prefix = prefix,8291 .prefix = prefix,
8292 .node = if (@as(MaybeNode, node)) |some| switch (@typeInfo(Some)) {8292 .node = if (@as(MaybeNode, node)) |some| switch (@typeInfo(Some)) {
8293 .Enum => |enum_info| switch (Some) {8293 .@"enum" => |enum_info| switch (Some) {
8294 Metadata => switch (some) {8294 Metadata => switch (some) {
8295 .none => .none,8295 .none => .none,
8296 else => try formatter.refUnwrapped(some.unwrap(formatter.builder)),8296 else => try formatter.refUnwrapped(some.unwrap(formatter.builder)),
...@@ -8301,18 +8301,18 @@ pub const Metadata = enum(u32) {...@@ -8301,18 +8301,18 @@ pub const Metadata = enum(u32) {
8301 else8301 else
8302 @compileError("unknown type to format: " ++ @typeName(Node)),8302 @compileError("unknown type to format: " ++ @typeName(Node)),
8303 },8303 },
8304 .EnumLiteral => .{ .raw = @tagName(some) },8304 .enum_literal => .{ .raw = @tagName(some) },
8305 .Bool => .{ .bool = some },8305 .bool => .{ .bool = some },
8306 .Struct => switch (Some) {8306 .@"struct" => switch (Some) {
8307 DIFlags => .{ .di_flags = some },8307 DIFlags => .{ .di_flags = some },
8308 Subprogram.DISPFlags => .{ .sp_flags = some },8308 Subprogram.DISPFlags => .{ .sp_flags = some },
8309 else => @compileError("unknown type to format: " ++ @typeName(Node)),8309 else => @compileError("unknown type to format: " ++ @typeName(Node)),
8310 },8310 },
8311 .Int, .ComptimeInt => .{ .u64 = some },8311 .int, .comptime_int => .{ .u64 = some },
8312 .Pointer => .{ .raw = some },8312 .pointer => .{ .raw = some },
8313 else => @compileError("unknown type to format: " ++ @typeName(Node)),8313 else => @compileError("unknown type to format: " ++ @typeName(Node)),
8314 } else switch (@typeInfo(Node)) {8314 } else switch (@typeInfo(Node)) {
8315 .Optional, .Null => .none,8315 .optional, .null => .none,
8316 else => unreachable,8316 else => unreachable,
8317 },8317 },
8318 } };8318 } };
...@@ -8414,7 +8414,7 @@ pub const Metadata = enum(u32) {...@@ -8414,7 +8414,7 @@ pub const Metadata = enum(u32) {
8414 }8414 }
8415 fmt_str = fmt_str ++ ")\n";8415 fmt_str = fmt_str ++ ")\n";
84168416
8417 var fmt_args: @Type(.{ .Struct = .{8417 var fmt_args: @Type(.{ .@"struct" = .{
8418 .layout = .auto,8418 .layout = .auto,
8419 .fields = &fields,8419 .fields = &fields,
8420 .decls = &.{},8420 .decls = &.{},
...@@ -8501,10 +8501,10 @@ pub fn init(options: Options) Allocator.Error!Builder {...@@ -8501,10 +8501,10 @@ pub fn init(options: Options) Allocator.Error!Builder {
8501 }8501 }
85028502
8503 {8503 {
8504 const static_len = @typeInfo(Type).Enum.fields.len - 1;8504 const static_len = @typeInfo(Type).@"enum".fields.len - 1;
8505 try self.type_map.ensureTotalCapacity(self.gpa, static_len);8505 try self.type_map.ensureTotalCapacity(self.gpa, static_len);
8506 try self.type_items.ensureTotalCapacity(self.gpa, static_len);8506 try self.type_items.ensureTotalCapacity(self.gpa, static_len);
8507 inline for (@typeInfo(Type.Simple).Enum.fields) |simple_field| {8507 inline for (@typeInfo(Type.Simple).@"enum".fields) |simple_field| {
8508 const result = self.getOrPutTypeNoExtraAssumeCapacity(8508 const result = self.getOrPutTypeNoExtraAssumeCapacity(
8509 .{ .tag = .simple, .data = simple_field.value },8509 .{ .tag = .simple, .data = simple_field.value },
8510 );8510 );
...@@ -9031,14 +9031,14 @@ pub fn getIntrinsic(...@@ -9031,14 +9031,14 @@ pub fn getIntrinsic(
90319031
9032pub fn intConst(self: *Builder, ty: Type, value: anytype) Allocator.Error!Constant {9032pub fn intConst(self: *Builder, ty: Type, value: anytype) Allocator.Error!Constant {
9033 const int_value = switch (@typeInfo(@TypeOf(value))) {9033 const int_value = switch (@typeInfo(@TypeOf(value))) {
9034 .Int, .ComptimeInt => value,9034 .int, .comptime_int => value,
9035 .Enum => @intFromEnum(value),9035 .@"enum" => @intFromEnum(value),
9036 else => @compileError("intConst expected an integral value, got " ++ @typeName(@TypeOf(value))),9036 else => @compileError("intConst expected an integral value, got " ++ @typeName(@TypeOf(value))),
9037 };9037 };
9038 var limbs: [9038 var limbs: [
9039 switch (@typeInfo(@TypeOf(int_value))) {9039 switch (@typeInfo(@TypeOf(int_value))) {
9040 .Int => |info| std.math.big.int.calcTwosCompLimbCount(info.bits),9040 .int => |info| std.math.big.int.calcTwosCompLimbCount(info.bits),
9041 .ComptimeInt => std.math.big.int.calcLimbLen(int_value),9041 .comptime_int => std.math.big.int.calcLimbLen(int_value),
9042 else => unreachable,9042 else => unreachable,
9043 }9043 }
9044 ]std.math.big.Limb = undefined;9044 ]std.math.big.Limb = undefined;
...@@ -10759,7 +10759,7 @@ fn ensureUnusedTypeCapacity(...@@ -10759,7 +10759,7 @@ fn ensureUnusedTypeCapacity(
10759 try self.type_items.ensureUnusedCapacity(self.gpa, count);10759 try self.type_items.ensureUnusedCapacity(self.gpa, count);
10760 try self.type_extra.ensureUnusedCapacity(10760 try self.type_extra.ensureUnusedCapacity(
10761 self.gpa,10761 self.gpa,
10762 count * (@typeInfo(Extra).Struct.fields.len + trail_len),10762 count * (@typeInfo(Extra).@"struct".fields.len + trail_len),
10763 );10763 );
10764}10764}
1076510765
...@@ -10789,7 +10789,7 @@ fn getOrPutTypeNoExtraAssumeCapacity(self: *Builder, item: Type.Item) struct { n...@@ -10789,7 +10789,7 @@ fn getOrPutTypeNoExtraAssumeCapacity(self: *Builder, item: Type.Item) struct { n
1078910789
10790fn addTypeExtraAssumeCapacity(self: *Builder, extra: anytype) Type.Item.ExtraIndex {10790fn addTypeExtraAssumeCapacity(self: *Builder, extra: anytype) Type.Item.ExtraIndex {
10791 const result: Type.Item.ExtraIndex = @intCast(self.type_extra.items.len);10791 const result: Type.Item.ExtraIndex = @intCast(self.type_extra.items.len);
10792 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {10792 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| {
10793 const value = @field(extra, field.name);10793 const value = @field(extra, field.name);
10794 self.type_extra.appendAssumeCapacity(switch (field.type) {10794 self.type_extra.appendAssumeCapacity(switch (field.type) {
10795 u32 => value,10795 u32 => value,
...@@ -10827,7 +10827,7 @@ fn typeExtraDataTrail(...@@ -10827,7 +10827,7 @@ fn typeExtraDataTrail(
10827 index: Type.Item.ExtraIndex,10827 index: Type.Item.ExtraIndex,
10828) struct { data: T, trail: TypeExtraDataTrail } {10828) struct { data: T, trail: TypeExtraDataTrail } {
10829 var result: T = undefined;10829 var result: T = undefined;
10830 const fields = @typeInfo(T).Struct.fields;10830 const fields = @typeInfo(T).@"struct".fields;
10831 inline for (fields, self.type_extra.items[index..][0..fields.len]) |field, value|10831 inline for (fields, self.type_extra.items[index..][0..fields.len]) |field, value|
10832 @field(result, field.name) = switch (field.type) {10832 @field(result, field.name) = switch (field.type) {
10833 u32 => value,10833 u32 => value,
...@@ -11642,7 +11642,7 @@ fn ensureUnusedConstantCapacity(...@@ -11642,7 +11642,7 @@ fn ensureUnusedConstantCapacity(
11642 try self.constant_items.ensureUnusedCapacity(self.gpa, count);11642 try self.constant_items.ensureUnusedCapacity(self.gpa, count);
11643 try self.constant_extra.ensureUnusedCapacity(11643 try self.constant_extra.ensureUnusedCapacity(
11644 self.gpa,11644 self.gpa,
11645 count * (@typeInfo(Extra).Struct.fields.len + trail_len),11645 count * (@typeInfo(Extra).@"struct".fields.len + trail_len),
11646 );11646 );
11647}11647}
1164811648
...@@ -11717,7 +11717,7 @@ fn getOrPutConstantAggregateAssumeCapacity(...@@ -11717,7 +11717,7 @@ fn getOrPutConstantAggregateAssumeCapacity(
1171711717
11718fn addConstantExtraAssumeCapacity(self: *Builder, extra: anytype) Constant.Item.ExtraIndex {11718fn addConstantExtraAssumeCapacity(self: *Builder, extra: anytype) Constant.Item.ExtraIndex {
11719 const result: Constant.Item.ExtraIndex = @intCast(self.constant_extra.items.len);11719 const result: Constant.Item.ExtraIndex = @intCast(self.constant_extra.items.len);
11720 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {11720 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| {
11721 const value = @field(extra, field.name);11721 const value = @field(extra, field.name);
11722 self.constant_extra.appendAssumeCapacity(switch (field.type) {11722 self.constant_extra.appendAssumeCapacity(switch (field.type) {
11723 u32 => value,11723 u32 => value,
...@@ -11756,7 +11756,7 @@ fn constantExtraDataTrail(...@@ -11756,7 +11756,7 @@ fn constantExtraDataTrail(
11756 index: Constant.Item.ExtraIndex,11756 index: Constant.Item.ExtraIndex,
11757) struct { data: T, trail: ConstantExtraDataTrail } {11757) struct { data: T, trail: ConstantExtraDataTrail } {
11758 var result: T = undefined;11758 var result: T = undefined;
11759 const fields = @typeInfo(T).Struct.fields;11759 const fields = @typeInfo(T).@"struct".fields;
11760 inline for (fields, self.constant_extra.items[index..][0..fields.len]) |field, value|11760 inline for (fields, self.constant_extra.items[index..][0..fields.len]) |field, value|
11761 @field(result, field.name) = switch (field.type) {11761 @field(result, field.name) = switch (field.type) {
11762 u32 => value,11762 u32 => value,
...@@ -11784,13 +11784,13 @@ fn ensureUnusedMetadataCapacity(...@@ -11784,13 +11784,13 @@ fn ensureUnusedMetadataCapacity(
11784 try self.metadata_items.ensureUnusedCapacity(self.gpa, count);11784 try self.metadata_items.ensureUnusedCapacity(self.gpa, count);
11785 try self.metadata_extra.ensureUnusedCapacity(11785 try self.metadata_extra.ensureUnusedCapacity(
11786 self.gpa,11786 self.gpa,
11787 count * (@typeInfo(Extra).Struct.fields.len + trail_len),11787 count * (@typeInfo(Extra).@"struct".fields.len + trail_len),
11788 );11788 );
11789}11789}
1179011790
11791fn addMetadataExtraAssumeCapacity(self: *Builder, extra: anytype) Metadata.Item.ExtraIndex {11791fn addMetadataExtraAssumeCapacity(self: *Builder, extra: anytype) Metadata.Item.ExtraIndex {
11792 const result: Metadata.Item.ExtraIndex = @intCast(self.metadata_extra.items.len);11792 const result: Metadata.Item.ExtraIndex = @intCast(self.metadata_extra.items.len);
11793 inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| {11793 inline for (@typeInfo(@TypeOf(extra)).@"struct".fields) |field| {
11794 const value = @field(extra, field.name);11794 const value = @field(extra, field.name);
11795 self.metadata_extra.appendAssumeCapacity(switch (field.type) {11795 self.metadata_extra.appendAssumeCapacity(switch (field.type) {
11796 u32 => value,11796 u32 => value,
...@@ -11829,7 +11829,7 @@ fn metadataExtraDataTrail(...@@ -11829,7 +11829,7 @@ fn metadataExtraDataTrail(
11829 index: Metadata.Item.ExtraIndex,11829 index: Metadata.Item.ExtraIndex,
11830) struct { data: T, trail: MetadataExtraDataTrail } {11830) struct { data: T, trail: MetadataExtraDataTrail } {
11831 var result: T = undefined;11831 var result: T = undefined;
11832 const fields = @typeInfo(T).Struct.fields;11832 const fields = @typeInfo(T).@"struct".fields;
11833 inline for (fields, self.metadata_extra.items[index..][0..fields.len]) |field, value|11833 inline for (fields, self.metadata_extra.items[index..][0..fields.len]) |field, value|
11834 @field(result, field.name) = switch (field.type) {11834 @field(result, field.name) = switch (field.type) {
11835 u32 => value,11835 u32 => value,
...@@ -13921,7 +13921,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -13921,7 +13921,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
13921 const MetadataKindBlock = ir.MetadataKindBlock;13921 const MetadataKindBlock = ir.MetadataKindBlock;
13922 var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);13922 var metadata_kind_block = try module_block.enterSubBlock(MetadataKindBlock, true);
1392313923
13924 inline for (@typeInfo(ir.FixedMetadataKind).Enum.fields) |field| {13924 inline for (@typeInfo(ir.FixedMetadataKind).@"enum".fields) |field| {
13925 // don't include `dbg` in stripped functions13925 // don't include `dbg` in stripped functions
13926 if (!(self.strip and std.mem.eql(u8, field.name, "dbg"))) {13926 if (!(self.strip and std.mem.eql(u8, field.name, "dbg"))) {
13927 try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{13927 try metadata_kind_block.writeAbbrev(MetadataKindBlock.Kind{
...@@ -14197,7 +14197,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co...@@ -14197,7 +14197,7 @@ pub fn toBitcode(self: *Builder, allocator: Allocator) bitcode_writer.Error![]co
14197 const limbs_len = std.math.divCeil(u32, extra.bit_width, 64) catch unreachable;14197 const limbs_len = std.math.divCeil(u32, extra.bit_width, 64) catch unreachable;
14198 try record.ensureTotalCapacity(self.gpa, 3 + limbs_len);14198 try record.ensureTotalCapacity(self.gpa, 3 + limbs_len);
14199 record.appendAssumeCapacity(@as(14199 record.appendAssumeCapacity(@as(
14200 @typeInfo(MetadataBlock.Enumerator.Flags).Struct.backing_integer.?,14200 @typeInfo(MetadataBlock.Enumerator.Flags).@"struct".backing_integer.?,
14201 @bitCast(flags),14201 @bitCast(flags),
14202 ));14202 ));
14203 record.appendAssumeCapacity(extra.bit_width);14203 record.appendAssumeCapacity(extra.bit_width);
src/codegen/llvm/bitcode_writer.zig+9-9
...@@ -407,14 +407,14 @@ fn charTo6Bit(c: u8) u8 {...@@ -407,14 +407,14 @@ fn charTo6Bit(c: u8) u8 {
407407
408fn BufType(comptime T: type, comptime min_len: usize) type {408fn BufType(comptime T: type, comptime min_len: usize) type {
409 return std.meta.Int(.unsigned, @max(min_len, @bitSizeOf(switch (@typeInfo(T)) {409 return std.meta.Int(.unsigned, @max(min_len, @bitSizeOf(switch (@typeInfo(T)) {
410 .ComptimeInt => u32,410 .comptime_int => u32,
411 .Int => |info| if (info.signedness == .unsigned)411 .int => |info| if (info.signedness == .unsigned)
412 T412 T
413 else413 else
414 @compileError("Unsupported type: " ++ @typeName(T)),414 @compileError("Unsupported type: " ++ @typeName(T)),
415 .Enum => |info| info.tag_type,415 .@"enum" => |info| info.tag_type,
416 .Bool => u1,416 .bool => u1,
417 .Struct => |info| switch (info.layout) {417 .@"struct" => |info| switch (info.layout) {
418 .auto, .@"extern" => @compileError("Unsupported type: " ++ @typeName(T)),418 .auto, .@"extern" => @compileError("Unsupported type: " ++ @typeName(T)),
419 .@"packed" => std.meta.Int(.unsigned, @bitSizeOf(T)),419 .@"packed" => std.meta.Int(.unsigned, @bitSizeOf(T)),
420 },420 },
...@@ -424,10 +424,10 @@ fn BufType(comptime T: type, comptime min_len: usize) type {...@@ -424,10 +424,10 @@ fn BufType(comptime T: type, comptime min_len: usize) type {
424424
425fn bufValue(value: anytype, comptime min_len: usize) BufType(@TypeOf(value), min_len) {425fn bufValue(value: anytype, comptime min_len: usize) BufType(@TypeOf(value), min_len) {
426 return switch (@typeInfo(@TypeOf(value))) {426 return switch (@typeInfo(@TypeOf(value))) {
427 .ComptimeInt, .Int => @intCast(value),427 .comptime_int, .int => @intCast(value),
428 .Enum => @intFromEnum(value),428 .@"enum" => @intFromEnum(value),
429 .Bool => @intFromBool(value),429 .bool => @intFromBool(value),
430 .Struct => @intCast(@as(std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(value))), @bitCast(value))),430 .@"struct" => @intCast(@as(std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(value))), @bitCast(value))),
431 else => unreachable,431 else => unreachable,
432 };432 };
433}433}
src/codegen/spirv.zig+65-65
...@@ -439,7 +439,7 @@ const NavGen = struct {...@@ -439,7 +439,7 @@ const NavGen = struct {
439 const zcu = pt.zcu;439 const zcu = pt.zcu;
440 if (try self.air.value(inst, pt)) |val| {440 if (try self.air.value(inst, pt)) |val| {
441 const ty = self.typeOf(inst);441 const ty = self.typeOf(inst);
442 if (ty.zigTypeTag(zcu) == .Fn) {442 if (ty.zigTypeTag(zcu) == .@"fn") {
443 const fn_nav = switch (zcu.intern_pool.indexToKey(val.ip_index)) {443 const fn_nav = switch (zcu.intern_pool.indexToKey(val.ip_index)) {
444 .@"extern" => |@"extern"| @"extern".owner_nav,444 .@"extern" => |@"extern"| @"extern".owner_nav,
445 .func => |func| func.owner_nav,445 .func => |func| func.owner_nav,
...@@ -641,16 +641,16 @@ const NavGen = struct {...@@ -641,16 +641,16 @@ const NavGen = struct {
641 fn isSpvVector(self: *NavGen, ty: Type) bool {641 fn isSpvVector(self: *NavGen, ty: Type) bool {
642 const zcu = self.pt.zcu;642 const zcu = self.pt.zcu;
643 const target = self.getTarget();643 const target = self.getTarget();
644 if (ty.zigTypeTag(zcu) != .Vector) return false;644 if (ty.zigTypeTag(zcu) != .vector) return false;
645645
646 // TODO: This check must be expanded for types that can be represented646 // TODO: This check must be expanded for types that can be represented
647 // as integers (enums / packed structs?) and types that are represented647 // as integers (enums / packed structs?) and types that are represented
648 // by multiple SPIR-V values.648 // by multiple SPIR-V values.
649 const scalar_ty = ty.scalarType(zcu);649 const scalar_ty = ty.scalarType(zcu);
650 switch (scalar_ty.zigTypeTag(zcu)) {650 switch (scalar_ty.zigTypeTag(zcu)) {
651 .Bool,651 .bool,
652 .Int,652 .int,
653 .Float,653 .float,
654 => {},654 => {},
655 else => return false,655 else => return false,
656 }656 }
...@@ -668,26 +668,26 @@ const NavGen = struct {...@@ -668,26 +668,26 @@ const NavGen = struct {
668 const zcu = self.pt.zcu;668 const zcu = self.pt.zcu;
669 const target = self.getTarget();669 const target = self.getTarget();
670 var scalar_ty = ty.scalarType(zcu);670 var scalar_ty = ty.scalarType(zcu);
671 if (scalar_ty.zigTypeTag(zcu) == .Enum) {671 if (scalar_ty.zigTypeTag(zcu) == .@"enum") {
672 scalar_ty = scalar_ty.intTagType(zcu);672 scalar_ty = scalar_ty.intTagType(zcu);
673 }673 }
674 const vector_len = if (ty.isVector(zcu)) ty.vectorLen(zcu) else null;674 const vector_len = if (ty.isVector(zcu)) ty.vectorLen(zcu) else null;
675 return switch (scalar_ty.zigTypeTag(zcu)) {675 return switch (scalar_ty.zigTypeTag(zcu)) {
676 .Bool => ArithmeticTypeInfo{676 .bool => ArithmeticTypeInfo{
677 .bits = 1, // Doesn't matter for this class.677 .bits = 1, // Doesn't matter for this class.
678 .backing_bits = self.backingIntBits(1).?,678 .backing_bits = self.backingIntBits(1).?,
679 .vector_len = vector_len,679 .vector_len = vector_len,
680 .signedness = .unsigned, // Technically, but doesn't matter for this class.680 .signedness = .unsigned, // Technically, but doesn't matter for this class.
681 .class = .bool,681 .class = .bool,
682 },682 },
683 .Float => ArithmeticTypeInfo{683 .float => ArithmeticTypeInfo{
684 .bits = scalar_ty.floatBits(target),684 .bits = scalar_ty.floatBits(target),
685 .backing_bits = scalar_ty.floatBits(target), // TODO: F80?685 .backing_bits = scalar_ty.floatBits(target), // TODO: F80?
686 .vector_len = vector_len,686 .vector_len = vector_len,
687 .signedness = .signed, // Technically, but doesn't matter for this class.687 .signedness = .signed, // Technically, but doesn't matter for this class.
688 .class = .float,688 .class = .float,
689 },689 },
690 .Int => blk: {690 .int => blk: {
691 const int_info = scalar_ty.intInfo(zcu);691 const int_info = scalar_ty.intInfo(zcu);
692 // TODO: Maybe it's useful to also return this value.692 // TODO: Maybe it's useful to also return this value.
693 const maybe_backing_bits = self.backingIntBits(int_info.bits);693 const maybe_backing_bits = self.backingIntBits(int_info.bits);
...@@ -705,8 +705,8 @@ const NavGen = struct {...@@ -705,8 +705,8 @@ const NavGen = struct {
705 .composite_integer,705 .composite_integer,
706 };706 };
707 },707 },
708 .Enum => unreachable,708 .@"enum" => unreachable,
709 .Vector => unreachable,709 .vector => unreachable,
710 else => unreachable, // Unhandled arithmetic type710 else => unreachable, // Unhandled arithmetic type
711 };711 };
712 }712 }
...@@ -748,8 +748,8 @@ const NavGen = struct {...@@ -748,8 +748,8 @@ const NavGen = struct {
748 const backing_bits = self.backingIntBits(int_info.bits).?; // Assertion failure means big int748 const backing_bits = self.backingIntBits(int_info.bits).?; // Assertion failure means big int
749749
750 const signedness: Signedness = switch (@typeInfo(@TypeOf(value))) {750 const signedness: Signedness = switch (@typeInfo(@TypeOf(value))) {
751 .Int => |int| int.signedness,751 .int => |int| int.signedness,
752 .ComptimeInt => if (value < 0) .signed else .unsigned,752 .comptime_int => if (value < 0) .signed else .unsigned,
753 else => unreachable,753 else => unreachable,
754 };754 };
755755
...@@ -1243,7 +1243,7 @@ const NavGen = struct {...@@ -1243,7 +1243,7 @@ const NavGen = struct {
1243 else => {},1243 else => {},
1244 }1244 }
12451245
1246 // const is_fn_body = decl_ty.zigTypeTag(zcu) == .Fn;1246 // const is_fn_body = decl_ty.zigTypeTag(zcu) == .@"fn";
1247 if (!uav_ty.isFnOrHasRuntimeBitsIgnoreComptime(zcu)) {1247 if (!uav_ty.isFnOrHasRuntimeBitsIgnoreComptime(zcu)) {
1248 // Pointer to nothing - return undefined1248 // Pointer to nothing - return undefined
1249 return self.spv.constUndef(ty_id);1249 return self.spv.constUndef(ty_id);
...@@ -1539,11 +1539,11 @@ const NavGen = struct {...@@ -1539,11 +1539,11 @@ const NavGen = struct {
1539 const section = &self.spv.sections.types_globals_constants;1539 const section = &self.spv.sections.types_globals_constants;
15401540
1541 switch (ty.zigTypeTag(zcu)) {1541 switch (ty.zigTypeTag(zcu)) {
1542 .NoReturn => {1542 .noreturn => {
1543 assert(repr == .direct);1543 assert(repr == .direct);
1544 return try self.spv.voidType();1544 return try self.spv.voidType();
1545 },1545 },
1546 .Void => switch (repr) {1546 .void => switch (repr) {
1547 .direct => {1547 .direct => {
1548 return try self.spv.voidType();1548 return try self.spv.voidType();
1549 },1549 },
...@@ -1557,11 +1557,11 @@ const NavGen = struct {...@@ -1557,11 +1557,11 @@ const NavGen = struct {
1557 return result_id;1557 return result_id;
1558 },1558 },
1559 },1559 },
1560 .Bool => switch (repr) {1560 .bool => switch (repr) {
1561 .direct => return try self.spv.boolType(),1561 .direct => return try self.spv.boolType(),
1562 .indirect => return try self.resolveType(Type.u1, .indirect),1562 .indirect => return try self.resolveType(Type.u1, .indirect),
1563 },1563 },
1564 .Int => {1564 .int => {
1565 const int_info = ty.intInfo(zcu);1565 const int_info = ty.intInfo(zcu);
1566 if (int_info.bits == 0) {1566 if (int_info.bits == 0) {
1567 // Some times, the backend will be asked to generate a pointer to i0. OpTypeInt1567 // Some times, the backend will be asked to generate a pointer to i0. OpTypeInt
...@@ -1576,11 +1576,11 @@ const NavGen = struct {...@@ -1576,11 +1576,11 @@ const NavGen = struct {
1576 }1576 }
1577 return try self.intType(int_info.signedness, int_info.bits);1577 return try self.intType(int_info.signedness, int_info.bits);
1578 },1578 },
1579 .Enum => {1579 .@"enum" => {
1580 const tag_ty = ty.intTagType(zcu);1580 const tag_ty = ty.intTagType(zcu);
1581 return try self.resolveType(tag_ty, repr);1581 return try self.resolveType(tag_ty, repr);
1582 },1582 },
1583 .Float => {1583 .float => {
1584 // We can (and want) not really emulate floating points with other floating point types like with the integer types,1584 // We can (and want) not really emulate floating points with other floating point types like with the integer types,
1585 // so if the float is not supported, just return an error.1585 // so if the float is not supported, just return an error.
1586 const bits = ty.floatBits(target);1586 const bits = ty.floatBits(target);
...@@ -1598,7 +1598,7 @@ const NavGen = struct {...@@ -1598,7 +1598,7 @@ const NavGen = struct {
15981598
1599 return try self.spv.floatType(bits);1599 return try self.spv.floatType(bits);
1600 },1600 },
1601 .Array => {1601 .array => {
1602 const elem_ty = ty.childType(zcu);1602 const elem_ty = ty.childType(zcu);
1603 const elem_ty_id = try self.resolveType(elem_ty, .indirect);1603 const elem_ty_id = try self.resolveType(elem_ty, .indirect);
1604 const total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(zcu)) orelse {1604 const total_len = std.math.cast(u32, ty.arrayLenIncludingSentinel(zcu)) orelse {
...@@ -1633,7 +1633,7 @@ const NavGen = struct {...@@ -1633,7 +1633,7 @@ const NavGen = struct {
1633 return try self.arrayType(total_len, elem_ty_id);1633 return try self.arrayType(total_len, elem_ty_id);
1634 }1634 }
1635 },1635 },
1636 .Fn => switch (repr) {1636 .@"fn" => switch (repr) {
1637 .direct => {1637 .direct => {
1638 const fn_info = zcu.typeToFunc(ty).?;1638 const fn_info = zcu.typeToFunc(ty).?;
16391639
...@@ -1676,7 +1676,7 @@ const NavGen = struct {...@@ -1676,7 +1676,7 @@ const NavGen = struct {
1676 return try self.resolveType(Type.usize, .indirect);1676 return try self.resolveType(Type.usize, .indirect);
1677 },1677 },
1678 },1678 },
1679 .Pointer => {1679 .pointer => {
1680 const ptr_info = ty.ptrInfo(zcu);1680 const ptr_info = ty.ptrInfo(zcu);
16811681
1682 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);1682 const storage_class = self.spvStorageClass(ptr_info.flags.address_space);
...@@ -1692,7 +1692,7 @@ const NavGen = struct {...@@ -1692,7 +1692,7 @@ const NavGen = struct {
1692 &.{ "ptr", "len" },1692 &.{ "ptr", "len" },
1693 );1693 );
1694 },1694 },
1695 .Vector => {1695 .vector => {
1696 const elem_ty = ty.childType(zcu);1696 const elem_ty = ty.childType(zcu);
1697 const elem_ty_id = try self.resolveType(elem_ty, repr);1697 const elem_ty_id = try self.resolveType(elem_ty, repr);
1698 const len = ty.vectorLen(zcu);1698 const len = ty.vectorLen(zcu);
...@@ -1703,7 +1703,7 @@ const NavGen = struct {...@@ -1703,7 +1703,7 @@ const NavGen = struct {
1703 return try self.arrayType(len, elem_ty_id);1703 return try self.arrayType(len, elem_ty_id);
1704 }1704 }
1705 },1705 },
1706 .Struct => {1706 .@"struct" => {
1707 const struct_type = switch (ip.indexToKey(ty.toIntern())) {1707 const struct_type = switch (ip.indexToKey(ty.toIntern())) {
1708 .anon_struct_type => |tuple| {1708 .anon_struct_type => |tuple| {
1709 const member_types = try self.gpa.alloc(IdRef, tuple.values.len);1709 const member_types = try self.gpa.alloc(IdRef, tuple.values.len);
...@@ -1757,7 +1757,7 @@ const NavGen = struct {...@@ -1757,7 +1757,7 @@ const NavGen = struct {
1757 try self.spv.debugName(result_id, type_name);1757 try self.spv.debugName(result_id, type_name);
1758 return result_id;1758 return result_id;
1759 },1759 },
1760 .Optional => {1760 .optional => {
1761 const payload_ty = ty.optionalChild(zcu);1761 const payload_ty = ty.optionalChild(zcu);
1762 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {1762 if (!payload_ty.hasRuntimeBitsIgnoreComptime(zcu)) {
1763 // Just use a bool.1763 // Just use a bool.
...@@ -1779,9 +1779,9 @@ const NavGen = struct {...@@ -1779,9 +1779,9 @@ const NavGen = struct {
1779 &.{ "payload", "valid" },1779 &.{ "payload", "valid" },
1780 );1780 );
1781 },1781 },
1782 .Union => return try self.resolveUnionType(ty),1782 .@"union" => return try self.resolveUnionType(ty),
1783 .ErrorSet => return try self.resolveType(Type.u16, repr),1783 .error_set => return try self.resolveType(Type.u16, repr),
1784 .ErrorUnion => {1784 .error_union => {
1785 const payload_ty = ty.errorUnionPayload(zcu);1785 const payload_ty = ty.errorUnionPayload(zcu);
1786 const error_ty_id = try self.resolveType(Type.anyerror, .indirect);1786 const error_ty_id = try self.resolveType(Type.anyerror, .indirect);
17871787
...@@ -1808,7 +1808,7 @@ const NavGen = struct {...@@ -1808,7 +1808,7 @@ const NavGen = struct {
18081808
1809 return try self.spv.structType(&member_types, &member_names);1809 return try self.spv.structType(&member_types, &member_names);
1810 },1810 },
1811 .Opaque => {1811 .@"opaque" => {
1812 const type_name = try self.resolveTypeName(ty);1812 const type_name = try self.resolveTypeName(ty);
1813 defer self.gpa.free(type_name);1813 defer self.gpa.free(type_name);
18141814
...@@ -1820,15 +1820,15 @@ const NavGen = struct {...@@ -1820,15 +1820,15 @@ const NavGen = struct {
1820 return result_id;1820 return result_id;
1821 },1821 },
18221822
1823 .Null,1823 .null,
1824 .Undefined,1824 .undefined,
1825 .EnumLiteral,1825 .enum_literal,
1826 .ComptimeFloat,1826 .comptime_float,
1827 .ComptimeInt,1827 .comptime_int,
1828 .Type,1828 .type,
1829 => unreachable, // Must be comptime.1829 => unreachable, // Must be comptime.
18301830
1831 .Frame, .AnyFrame => unreachable, // TODO1831 .frame, .@"anyframe" => unreachable, // TODO
1832 }1832 }
1833 }1833 }
18341834
...@@ -2429,7 +2429,7 @@ const NavGen = struct {...@@ -2429,7 +2429,7 @@ const NavGen = struct {
2429 const op_result_ty_id = try self.resolveType(op_result_ty, .direct);2429 const op_result_ty_id = try self.resolveType(op_result_ty, .direct);
2430 const result_ty = try v.resultType(self, lhs.ty);2430 const result_ty = try v.resultType(self, lhs.ty);
24312431
2432 assert(condition.ty.scalarType(zcu).zigTypeTag(zcu) == .Bool);2432 assert(condition.ty.scalarType(zcu).zigTypeTag(zcu) == .bool);
24332433
2434 const cond = try v.prepare(self, condition);2434 const cond = try v.prepare(self, condition);
2435 const object_1 = try v.prepare(self, lhs);2435 const object_1 = try v.prepare(self, lhs);
...@@ -3119,7 +3119,7 @@ const NavGen = struct {...@@ -3119,7 +3119,7 @@ const NavGen = struct {
3119 fn convertToDirect(self: *NavGen, ty: Type, operand_id: IdRef) !IdRef {3119 fn convertToDirect(self: *NavGen, ty: Type, operand_id: IdRef) !IdRef {
3120 const zcu = self.pt.zcu;3120 const zcu = self.pt.zcu;
3121 switch (ty.scalarType(zcu).zigTypeTag(zcu)) {3121 switch (ty.scalarType(zcu).zigTypeTag(zcu)) {
3122 .Bool => {3122 .bool => {
3123 const false_id = try self.constBool(false, .indirect);3123 const false_id = try self.constBool(false, .indirect);
3124 // The operation below requires inputs in direct representation, but the operand3124 // The operation below requires inputs in direct representation, but the operand
3125 // is actually in indirect representation.3125 // is actually in indirect representation.
...@@ -3145,7 +3145,7 @@ const NavGen = struct {...@@ -3145,7 +3145,7 @@ const NavGen = struct {
3145 fn convertToIndirect(self: *NavGen, ty: Type, operand_id: IdRef) !IdRef {3145 fn convertToIndirect(self: *NavGen, ty: Type, operand_id: IdRef) !IdRef {
3146 const zcu = self.pt.zcu;3146 const zcu = self.pt.zcu;
3147 switch (ty.scalarType(zcu).zigTypeTag(zcu)) {3147 switch (ty.scalarType(zcu).zigTypeTag(zcu)) {
3148 .Bool => {3148 .bool => {
3149 const result = try self.intFromBool(Temporary.init(ty, operand_id));3149 const result = try self.intFromBool(Temporary.init(ty, operand_id));
3150 return try result.materialize(self);3150 return try result.materialize(self);
3151 },3151 },
...@@ -4281,17 +4281,17 @@ const NavGen = struct {...@@ -4281,17 +4281,17 @@ const NavGen = struct {
4281 const is_vector = lhs.ty.isVector(zcu);4281 const is_vector = lhs.ty.isVector(zcu);
42824282
4283 switch (scalar_ty.zigTypeTag(zcu)) {4283 switch (scalar_ty.zigTypeTag(zcu)) {
4284 .Int, .Bool, .Float => {},4284 .int, .bool, .float => {},
4285 .Enum => {4285 .@"enum" => {
4286 assert(!is_vector);4286 assert(!is_vector);
4287 const ty = lhs.ty.intTagType(zcu);4287 const ty = lhs.ty.intTagType(zcu);
4288 return try self.cmp(op, lhs.pun(ty), rhs.pun(ty));4288 return try self.cmp(op, lhs.pun(ty), rhs.pun(ty));
4289 },4289 },
4290 .ErrorSet => {4290 .error_set => {
4291 assert(!is_vector);4291 assert(!is_vector);
4292 return try self.cmp(op, lhs.pun(Type.u16), rhs.pun(Type.u16));4292 return try self.cmp(op, lhs.pun(Type.u16), rhs.pun(Type.u16));
4293 },4293 },
4294 .Pointer => {4294 .pointer => {
4295 assert(!is_vector);4295 assert(!is_vector);
4296 // Note that while SPIR-V offers OpPtrEqual and OpPtrNotEqual, they are4296 // Note that while SPIR-V offers OpPtrEqual and OpPtrNotEqual, they are
4297 // currently not implemented in the SPIR-V LLVM translator. Thus, we emit these using4297 // currently not implemented in the SPIR-V LLVM translator. Thus, we emit these using
...@@ -4317,7 +4317,7 @@ const NavGen = struct {...@@ -4317,7 +4317,7 @@ const NavGen = struct {
4317 const rhs_int = Temporary.init(Type.usize, rhs_int_id);4317 const rhs_int = Temporary.init(Type.usize, rhs_int_id);
4318 return try self.cmp(op, lhs_int, rhs_int);4318 return try self.cmp(op, lhs_int, rhs_int);
4319 },4319 },
4320 .Optional => {4320 .optional => {
4321 assert(!is_vector);4321 assert(!is_vector);
43224322
4323 const ty = lhs.ty;4323 const ty = lhs.ty;
...@@ -4478,7 +4478,7 @@ const NavGen = struct {...@@ -4478,7 +4478,7 @@ const NavGen = struct {
4478 // TODO: Some more cases are missing here4478 // TODO: Some more cases are missing here
4479 // See fn bitCast in llvm.zig4479 // See fn bitCast in llvm.zig
44804480
4481 if (src_ty.zigTypeTag(zcu) == .Int and dst_ty.isPtrAtRuntime(zcu)) {4481 if (src_ty.zigTypeTag(zcu) == .int and dst_ty.isPtrAtRuntime(zcu)) {
4482 const result_id = self.spv.allocId();4482 const result_id = self.spv.allocId();
4483 try self.func.body.emit(self.spv.gpa, .OpConvertUToPtr, .{4483 try self.func.body.emit(self.spv.gpa, .OpConvertUToPtr, .{
4484 .id_result_type = dst_ty_id,4484 .id_result_type = dst_ty_id,
...@@ -4520,7 +4520,7 @@ const NavGen = struct {...@@ -4520,7 +4520,7 @@ const NavGen = struct {
4520 // the result here.4520 // the result here.
4521 // TODO: This detail could cause stuff like @as(*const i1, @ptrCast(&@as(u1, 1))) to break4521 // TODO: This detail could cause stuff like @as(*const i1, @ptrCast(&@as(u1, 1))) to break
4522 // should we change the representation of strange integers?4522 // should we change the representation of strange integers?
4523 if (dst_ty.zigTypeTag(zcu) == .Int) {4523 if (dst_ty.zigTypeTag(zcu) == .int) {
4524 const info = self.arithmeticTypeInfo(dst_ty);4524 const info = self.arithmeticTypeInfo(dst_ty);
4525 const result = try self.normalize(Temporary.init(dst_ty, result_id), info);4525 const result = try self.normalize(Temporary.init(dst_ty, result_id), info);
4526 return try result.materialize(self);4526 return try result.materialize(self);
...@@ -4729,7 +4729,7 @@ const NavGen = struct {...@@ -4729,7 +4729,7 @@ const NavGen = struct {
4729 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);4729 const elements: []const Air.Inst.Ref = @ptrCast(self.air.extra[ty_pl.payload..][0..len]);
47304730
4731 switch (result_ty.zigTypeTag(zcu)) {4731 switch (result_ty.zigTypeTag(zcu)) {
4732 .Struct => {4732 .@"struct" => {
4733 if (zcu.typeToPackedStruct(result_ty)) |struct_type| {4733 if (zcu.typeToPackedStruct(result_ty)) |struct_type| {
4734 _ = struct_type;4734 _ = struct_type;
4735 unreachable; // TODO4735 unreachable; // TODO
...@@ -4777,7 +4777,7 @@ const NavGen = struct {...@@ -4777,7 +4777,7 @@ const NavGen = struct {
4777 constituents[0..index],4777 constituents[0..index],
4778 );4778 );
4779 },4779 },
4780 .Vector => {4780 .vector => {
4781 const n_elems = result_ty.vectorLen(zcu);4781 const n_elems = result_ty.vectorLen(zcu);
4782 const elem_ids = try self.gpa.alloc(IdRef, n_elems);4782 const elem_ids = try self.gpa.alloc(IdRef, n_elems);
4783 defer self.gpa.free(elem_ids);4783 defer self.gpa.free(elem_ids);
...@@ -4788,7 +4788,7 @@ const NavGen = struct {...@@ -4788,7 +4788,7 @@ const NavGen = struct {
47884788
4789 return try self.constructVector(result_ty, elem_ids);4789 return try self.constructVector(result_ty, elem_ids);
4790 },4790 },
4791 .Array => {4791 .array => {
4792 const array_info = result_ty.arrayInfo(zcu);4792 const array_info = result_ty.arrayInfo(zcu);
4793 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(zcu));4793 const n_elems: usize = @intCast(result_ty.arrayLenIncludingSentinel(zcu));
4794 const elem_ids = try self.gpa.alloc(IdRef, n_elems);4794 const elem_ids = try self.gpa.alloc(IdRef, n_elems);
...@@ -5153,11 +5153,11 @@ const NavGen = struct {...@@ -5153,11 +5153,11 @@ const NavGen = struct {
5153 if (!field_ty.hasRuntimeBitsIgnoreComptime(zcu)) return null;5153 if (!field_ty.hasRuntimeBitsIgnoreComptime(zcu)) return null;
51545154
5155 switch (object_ty.zigTypeTag(zcu)) {5155 switch (object_ty.zigTypeTag(zcu)) {
5156 .Struct => switch (object_ty.containerLayout(zcu)) {5156 .@"struct" => switch (object_ty.containerLayout(zcu)) {
5157 .@"packed" => unreachable, // TODO5157 .@"packed" => unreachable, // TODO
5158 else => return try self.extractField(field_ty, object_id, field_index),5158 else => return try self.extractField(field_ty, object_id, field_index),
5159 },5159 },
5160 .Union => switch (object_ty.containerLayout(zcu)) {5160 .@"union" => switch (object_ty.containerLayout(zcu)) {
5161 .@"packed" => unreachable, // TODO5161 .@"packed" => unreachable, // TODO
5162 else => {5162 else => {
5163 // Store, ptr-elem-ptr, pointer-cast, load5163 // Store, ptr-elem-ptr, pointer-cast, load
...@@ -5229,17 +5229,17 @@ const NavGen = struct {...@@ -5229,17 +5229,17 @@ const NavGen = struct {
5229 const zcu = self.pt.zcu;5229 const zcu = self.pt.zcu;
5230 const object_ty = object_ptr_ty.childType(zcu);5230 const object_ty = object_ptr_ty.childType(zcu);
5231 switch (object_ty.zigTypeTag(zcu)) {5231 switch (object_ty.zigTypeTag(zcu)) {
5232 .Pointer => {5232 .pointer => {
5233 assert(object_ty.isSlice(zcu));5233 assert(object_ty.isSlice(zcu));
5234 return self.accessChain(result_ty_id, object_ptr, &.{field_index});5234 return self.accessChain(result_ty_id, object_ptr, &.{field_index});
5235 },5235 },
5236 .Struct => switch (object_ty.containerLayout(zcu)) {5236 .@"struct" => switch (object_ty.containerLayout(zcu)) {
5237 .@"packed" => unreachable, // TODO5237 .@"packed" => unreachable, // TODO
5238 else => {5238 else => {
5239 return try self.accessChain(result_ty_id, object_ptr, &.{field_index});5239 return try self.accessChain(result_ty_id, object_ptr, &.{field_index});
5240 },5240 },
5241 },5241 },
5242 .Union => switch (object_ty.containerLayout(zcu)) {5242 .@"union" => switch (object_ty.containerLayout(zcu)) {
5243 .@"packed" => unreachable, // TODO5243 .@"packed" => unreachable, // TODO
5244 else => {5244 else => {
5245 const layout = self.unionLayout(object_ty);5245 const layout = self.unionLayout(object_ty);
...@@ -6179,15 +6179,15 @@ const NavGen = struct {...@@ -6179,15 +6179,15 @@ const NavGen = struct {
6179 var cond_indirect = try self.convertToIndirect(cond_ty, cond);6179 var cond_indirect = try self.convertToIndirect(cond_ty, cond);
61806180
6181 const cond_words: u32 = switch (cond_ty.zigTypeTag(zcu)) {6181 const cond_words: u32 = switch (cond_ty.zigTypeTag(zcu)) {
6182 .Bool, .ErrorSet => 1,6182 .bool, .error_set => 1,
6183 .Int => blk: {6183 .int => blk: {
6184 const bits = cond_ty.intInfo(zcu).bits;6184 const bits = cond_ty.intInfo(zcu).bits;
6185 const backing_bits = self.backingIntBits(bits) orelse {6185 const backing_bits = self.backingIntBits(bits) orelse {
6186 return self.todo("implement composite int switch", .{});6186 return self.todo("implement composite int switch", .{});
6187 };6187 };
6188 break :blk if (backing_bits <= 32) 1 else 2;6188 break :blk if (backing_bits <= 32) 1 else 2;
6189 },6189 },
6190 .Enum => blk: {6190 .@"enum" => blk: {
6191 const int_ty = cond_ty.intTagType(zcu);6191 const int_ty = cond_ty.intTagType(zcu);
6192 const int_info = int_ty.intInfo(zcu);6192 const int_info = int_ty.intInfo(zcu);
6193 const backing_bits = self.backingIntBits(int_info.bits) orelse {6193 const backing_bits = self.backingIntBits(int_info.bits) orelse {
...@@ -6195,7 +6195,7 @@ const NavGen = struct {...@@ -6195,7 +6195,7 @@ const NavGen = struct {
6195 };6195 };
6196 break :blk if (backing_bits <= 32) 1 else 2;6196 break :blk if (backing_bits <= 32) 1 else 2;
6197 },6197 },
6198 .Pointer => blk: {6198 .pointer => blk: {
6199 cond_indirect = try self.intFromPtr(cond_indirect);6199 cond_indirect = try self.intFromPtr(cond_indirect);
6200 break :blk target.ptrBitWidth() / 32;6200 break :blk target.ptrBitWidth() / 32;
6201 },6201 },
...@@ -6248,13 +6248,13 @@ const NavGen = struct {...@@ -6248,13 +6248,13 @@ const NavGen = struct {
6248 for (case.items) |item| {6248 for (case.items) |item| {
6249 const value = (try self.air.value(item, pt)) orelse unreachable;6249 const value = (try self.air.value(item, pt)) orelse unreachable;
6250 const int_val: u64 = switch (cond_ty.zigTypeTag(zcu)) {6250 const int_val: u64 = switch (cond_ty.zigTypeTag(zcu)) {
6251 .Bool, .Int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu),6251 .bool, .int => if (cond_ty.isSignedInt(zcu)) @bitCast(value.toSignedInt(zcu)) else value.toUnsignedInt(zcu),
6252 .Enum => blk: {6252 .@"enum" => blk: {
6253 // TODO: figure out of cond_ty is correct (something with enum literals)6253 // TODO: figure out of cond_ty is correct (something with enum literals)
6254 break :blk (try value.intFromEnum(cond_ty, pt)).toUnsignedInt(zcu); // TODO: composite integer constants6254 break :blk (try value.intFromEnum(cond_ty, pt)).toUnsignedInt(zcu); // TODO: composite integer constants
6255 },6255 },
6256 .ErrorSet => value.getErrorInt(zcu),6256 .error_set => value.getErrorInt(zcu),
6257 .Pointer => value.toUnsignedInt(zcu),6257 .pointer => value.toUnsignedInt(zcu),
6258 else => unreachable,6258 else => unreachable,
6259 };6259 };
6260 const int_lit: spec.LiteralContextDependentNumber = switch (cond_words) {6260 const int_lit: spec.LiteralContextDependentNumber = switch (cond_words) {
...@@ -6496,8 +6496,8 @@ const NavGen = struct {...@@ -6496,8 +6496,8 @@ const NavGen = struct {
6496 const args: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]);6496 const args: []const Air.Inst.Ref = @ptrCast(self.air.extra[extra.end..][0..extra.data.args_len]);
6497 const callee_ty = self.typeOf(pl_op.operand);6497 const callee_ty = self.typeOf(pl_op.operand);
6498 const zig_fn_ty = switch (callee_ty.zigTypeTag(zcu)) {6498 const zig_fn_ty = switch (callee_ty.zigTypeTag(zcu)) {
6499 .Fn => callee_ty,6499 .@"fn" => callee_ty,
6500 .Pointer => return self.fail("cannot call function pointers", .{}),6500 .pointer => return self.fail("cannot call function pointers", .{}),
6501 else => unreachable,6501 else => unreachable,
6502 };6502 };
6503 const fn_info = zcu.typeToFunc(zig_fn_ty).?;6503 const fn_info = zcu.typeToFunc(zig_fn_ty).?;
src/codegen/spirv/Section.zig+26-26
...@@ -98,7 +98,7 @@ pub fn emitSpecConstantOp(...@@ -98,7 +98,7 @@ pub fn emitSpecConstantOp(
98 section.writeOperand(spec.IdRef, operands.id_result);98 section.writeOperand(spec.IdRef, operands.id_result);
99 section.writeOperand(Opcode, opcode);99 section.writeOperand(Opcode, opcode);
100100
101 const fields = @typeInfo(opcode.Operands()).Struct.fields;101 const fields = @typeInfo(opcode.Operands()).@"struct".fields;
102 // First 2 fields are always id_result_type and id_result.102 // First 2 fields are always id_result_type and id_result.
103 inline for (fields[2..]) |field| {103 inline for (fields[2..]) |field| {
104 section.writeOperand(field.type, @field(operands, field.name));104 section.writeOperand(field.type, @field(operands, field.name));
...@@ -122,8 +122,8 @@ pub fn writeDoubleWord(section: *Section, dword: DoubleWord) void {...@@ -122,8 +122,8 @@ pub fn writeDoubleWord(section: *Section, dword: DoubleWord) void {
122122
123fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) void {123fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) void {
124 const fields = switch (@typeInfo(Operands)) {124 const fields = switch (@typeInfo(Operands)) {
125 .Struct => |info| info.fields,125 .@"struct" => |info| info.fields,
126 .Void => return,126 .void => return,
127 else => unreachable,127 else => unreachable,
128 };128 };
129129
...@@ -154,24 +154,24 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)...@@ -154,24 +154,24 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
154 spec.PairIdRefIdRef => section.writeWords(&.{ @intFromEnum(operand[0]), @intFromEnum(operand[1]) }),154 spec.PairIdRefIdRef => section.writeWords(&.{ @intFromEnum(operand[0]), @intFromEnum(operand[1]) }),
155155
156 else => switch (@typeInfo(Operand)) {156 else => switch (@typeInfo(Operand)) {
157 .Enum => section.writeWord(@intFromEnum(operand)),157 .@"enum" => section.writeWord(@intFromEnum(operand)),
158 .Optional => |info| if (operand) |child| {158 .optional => |info| if (operand) |child| {
159 section.writeOperand(info.child, child);159 section.writeOperand(info.child, child);
160 },160 },
161 .Pointer => |info| {161 .pointer => |info| {
162 std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.162 std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.
163 for (operand) |item| {163 for (operand) |item| {
164 section.writeOperand(info.child, item);164 section.writeOperand(info.child, item);
165 }165 }
166 },166 },
167 .Struct => |info| {167 .@"struct" => |info| {
168 if (info.layout == .@"packed") {168 if (info.layout == .@"packed") {
169 section.writeWord(@as(Word, @bitCast(operand)));169 section.writeWord(@as(Word, @bitCast(operand)));
170 } else {170 } else {
171 section.writeExtendedMask(Operand, operand);171 section.writeExtendedMask(Operand, operand);
172 }172 }
173 },173 },
174 .Union => section.writeExtendedUnion(Operand, operand),174 .@"union" => section.writeExtendedUnion(Operand, operand),
175 else => unreachable,175 else => unreachable,
176 },176 },
177 }177 }
...@@ -207,12 +207,12 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe...@@ -207,12 +207,12 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe
207207
208fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void {208fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void {
209 var mask: Word = 0;209 var mask: Word = 0;
210 inline for (@typeInfo(Operand).Struct.fields, 0..) |field, bit| {210 inline for (@typeInfo(Operand).@"struct".fields, 0..) |field, bit| {
211 switch (@typeInfo(field.type)) {211 switch (@typeInfo(field.type)) {
212 .Optional => if (@field(operand, field.name) != null) {212 .optional => if (@field(operand, field.name) != null) {
213 mask |= 1 << @as(u5, @intCast(bit));213 mask |= 1 << @as(u5, @intCast(bit));
214 },214 },
215 .Bool => if (@field(operand, field.name)) {215 .bool => if (@field(operand, field.name)) {
216 mask |= 1 << @as(u5, @intCast(bit));216 mask |= 1 << @as(u5, @intCast(bit));
217 },217 },
218 else => unreachable,218 else => unreachable,
...@@ -221,12 +221,12 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand...@@ -221,12 +221,12 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand
221221
222 section.writeWord(mask);222 section.writeWord(mask);
223223
224 inline for (@typeInfo(Operand).Struct.fields) |field| {224 inline for (@typeInfo(Operand).@"struct".fields) |field| {
225 switch (@typeInfo(field.type)) {225 switch (@typeInfo(field.type)) {
226 .Optional => |info| if (@field(operand, field.name)) |child| {226 .optional => |info| if (@field(operand, field.name)) |child| {
227 section.writeOperands(info.child, child);227 section.writeOperands(info.child, child);
228 },228 },
229 .Bool => {},229 .bool => {},
230 else => unreachable,230 else => unreachable,
231 }231 }
232 }232 }
...@@ -236,7 +236,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan...@@ -236,7 +236,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan
236 const tag = std.meta.activeTag(operand);236 const tag = std.meta.activeTag(operand);
237 section.writeWord(@intFromEnum(tag));237 section.writeWord(@intFromEnum(tag));
238238
239 inline for (@typeInfo(Operand).Union.fields) |field| {239 inline for (@typeInfo(Operand).@"union".fields) |field| {
240 if (@field(Operand, field.name) == tag) {240 if (@field(Operand, field.name) == tag) {
241 section.writeOperands(field.type, @field(operand, field.name));241 section.writeOperands(field.type, @field(operand, field.name));
242 return;242 return;
...@@ -251,8 +251,8 @@ fn instructionSize(comptime opcode: spec.Opcode, operands: opcode.Operands()) us...@@ -251,8 +251,8 @@ fn instructionSize(comptime opcode: spec.Opcode, operands: opcode.Operands()) us
251251
252fn operandsSize(comptime Operands: type, operands: Operands) usize {252fn operandsSize(comptime Operands: type, operands: Operands) usize {
253 const fields = switch (@typeInfo(Operands)) {253 const fields = switch (@typeInfo(Operands)) {
254 .Struct => |info| info.fields,254 .@"struct" => |info| info.fields,
255 .Void => return 0,255 .void => return 0,
256 else => unreachable,256 else => unreachable,
257 };257 };
258258
...@@ -289,9 +289,9 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {...@@ -289,9 +289,9 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
289 => 2,289 => 2,
290290
291 else => switch (@typeInfo(Operand)) {291 else => switch (@typeInfo(Operand)) {
292 .Enum => 1,292 .@"enum" => 1,
293 .Optional => |info| if (operand) |child| operandSize(info.child, child) else 0,293 .optional => |info| if (operand) |child| operandSize(info.child, child) else 0,
294 .Pointer => |info| blk: {294 .pointer => |info| blk: {
295 std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.295 std.debug.assert(info.size == .Slice); // Should be no other pointer types in the spec.
296 var total: usize = 0;296 var total: usize = 0;
297 for (operand) |item| {297 for (operand) |item| {
...@@ -299,8 +299,8 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {...@@ -299,8 +299,8 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
299 }299 }
300 break :blk total;300 break :blk total;
301 },301 },
302 .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand),302 .@"struct" => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand),
303 .Union => extendedUnionSize(Operand, operand),303 .@"union" => extendedUnionSize(Operand, operand),
304 else => unreachable,304 else => unreachable,
305 },305 },
306 };306 };
...@@ -309,13 +309,13 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {...@@ -309,13 +309,13 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
309fn extendedMaskSize(comptime Operand: type, operand: Operand) usize {309fn extendedMaskSize(comptime Operand: type, operand: Operand) usize {
310 var total: usize = 0;310 var total: usize = 0;
311 var any_set = false;311 var any_set = false;
312 inline for (@typeInfo(Operand).Struct.fields) |field| {312 inline for (@typeInfo(Operand).@"struct".fields) |field| {
313 switch (@typeInfo(field.type)) {313 switch (@typeInfo(field.type)) {
314 .Optional => |info| if (@field(operand, field.name)) |child| {314 .optional => |info| if (@field(operand, field.name)) |child| {
315 total += operandsSize(info.child, child);315 total += operandsSize(info.child, child);
316 any_set = true;316 any_set = true;
317 },317 },
318 .Bool => if (@field(operand, field.name)) {318 .bool => if (@field(operand, field.name)) {
319 any_set = true;319 any_set = true;
320 },320 },
321 else => unreachable,321 else => unreachable,
...@@ -326,7 +326,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize {...@@ -326,7 +326,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize {
326326
327fn extendedUnionSize(comptime Operand: type, operand: Operand) usize {327fn extendedUnionSize(comptime Operand: type, operand: Operand) usize {
328 const tag = std.meta.activeTag(operand);328 const tag = std.meta.activeTag(operand);
329 inline for (@typeInfo(Operand).Union.fields) |field| {329 inline for (@typeInfo(Operand).@"union".fields) |field| {
330 if (@field(Operand, field.name) == tag) {330 if (@field(Operand, field.name) == tag) {
331 // Add one for the tag itself.331 // Add one for the tag itself.
332 return 1 + operandsSize(field.type, @field(operand, field.name));332 return 1 + operandsSize(field.type, @field(operand, field.name));
src/link.zig+5-7
...@@ -936,13 +936,11 @@ pub const File = struct {...@@ -936,13 +936,11 @@ pub const File = struct {
936 missing_libc: bool = false,936 missing_libc: bool = false,
937937
938 const Int = blk: {938 const Int = blk: {
939 const bits = @typeInfo(@This()).Struct.fields.len;939 const bits = @typeInfo(@This()).@"struct".fields.len;
940 break :blk @Type(.{940 break :blk @Type(.{ .int = .{
941 .Int = .{941 .signedness = .unsigned,
942 .signedness = .unsigned,942 .bits = bits,
943 .bits = bits,943 } });
944 },
945 });
946 };944 };
947945
948 fn isSet(ef: ErrorFlags) bool {946 fn isSet(ef: ErrorFlags) bool {
src/link/Coff.zig+1-1
...@@ -1368,7 +1368,7 @@ fn getNavOutputSection(self: *Coff, nav_index: InternPool.Nav.Index) u16 {...@@ -1368,7 +1368,7 @@ fn getNavOutputSection(self: *Coff, nav_index: InternPool.Nav.Index) u16 {
13681368
1369 switch (zig_ty) {1369 switch (zig_ty) {
1370 // TODO: what if this is a function pointer?1370 // TODO: what if this is a function pointer?
1371 .Fn => break :blk self.text_section_index.?,1371 .@"fn" => break :blk self.text_section_index.?,
1372 else => {1372 else => {
1373 if (val.getVariable(zcu)) |_| {1373 if (val.getVariable(zcu)) |_| {
1374 break :blk self.data_section_index.?;1374 break :blk self.data_section_index.?;
src/link/Dwarf.zig+18-10
...@@ -1756,7 +1756,7 @@ pub const WipNav = struct {...@@ -1756,7 +1756,7 @@ pub const WipNav = struct {
1756 var bit: usize = 0;1756 var bit: usize = 0;
1757 var carry: u1 = 1;1757 var carry: u1 = 1;
1758 while (bit < bits) : (bit += 7) {1758 while (bit < bits) : (bit += 7) {
1759 const limb_bits = @typeInfo(std.math.big.Limb).Int.bits;1759 const limb_bits = @typeInfo(std.math.big.Limb).int.bits;
1760 const limb_index = bit / limb_bits;1760 const limb_index = bit / limb_bits;
1761 const limb_shift: std.math.Log2Int(std.math.big.Limb) = @intCast(bit % limb_bits);1761 const limb_shift: std.math.Log2Int(std.math.big.Limb) = @intCast(bit % limb_bits);
1762 const low_abs_part: u7 = @truncate(big_int.limbs[limb_index] >> limb_shift);1762 const low_abs_part: u7 = @truncate(big_int.limbs[limb_index] >> limb_shift);
...@@ -2477,6 +2477,18 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2477,6 +2477,18 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2477 assert(file.zir_loaded);2477 assert(file.zir_loaded);
2478 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));2478 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));
2479 assert(decl_inst.tag == .declaration);2479 assert(decl_inst.tag == .declaration);
2480 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2481
2482 const is_test = switch (decl_extra.data.name) {
2483 .unnamed_test, .decltest => true,
2484 .@"comptime", .@"usingnamespace" => false,
2485 _ => decl_extra.data.name.isNamedTest(file.zir),
2486 };
2487 if (is_test) {
2488 // This isn't actually a comptime Nav! It's a test, so it'll definitely never be referenced at comptime.
2489 return;
2490 }
2491
2480 const tree = try file.getTree(dwarf.gpa);2492 const tree = try file.getTree(dwarf.gpa);
2481 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);2493 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
2482 assert(loc.line == zcu.navSrcLine(nav_index));2494 assert(loc.line == zcu.navSrcLine(nav_index));
...@@ -2515,7 +2527,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2515,7 +2527,7 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2515 ) != abbrev_code_buf.len) return error.InputOutput;2527 ) != abbrev_code_buf.len) return error.InputOutput;
2516 var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf);2528 var abbrev_code_fbs = std.io.fixedBufferStream(&abbrev_code_buf);
2517 const abbrev_code: AbbrevCode = @enumFromInt(2529 const abbrev_code: AbbrevCode = @enumFromInt(
2518 std.leb.readUleb128(@typeInfo(AbbrevCode).Enum.tag_type, abbrev_code_fbs.reader()) catch unreachable,2530 std.leb.readUleb128(@typeInfo(AbbrevCode).@"enum".tag_type, abbrev_code_fbs.reader()) catch unreachable,
2519 );2531 );
2520 switch (abbrev_code) {2532 switch (abbrev_code) {
2521 else => unreachable,2533 else => unreachable,
...@@ -2582,7 +2594,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2582,7 +2594,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2582 if (loaded_struct.zir_index == .none) break :decl_struct;2594 if (loaded_struct.zir_index == .none) break :decl_struct;
25832595
2584 const value_inst = value_inst: {2596 const value_inst = value_inst: {
2585 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2586 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2597 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2587 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2598 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2588 if (break_inst.tag != .break_inline) break :value_inst null;2599 if (break_inst.tag != .break_inline) break :value_inst null;
...@@ -2704,7 +2715,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2704,7 +2715,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2704 if (loaded_enum.zir_index == .none) break :decl_enum;2715 if (loaded_enum.zir_index == .none) break :decl_enum;
27052716
2706 const value_inst = value_inst: {2717 const value_inst = value_inst: {
2707 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2708 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2718 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2709 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2719 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2710 if (break_inst.tag != .break_inline) break :value_inst null;2720 if (break_inst.tag != .break_inline) break :value_inst null;
...@@ -2788,7 +2798,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2788,7 +2798,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27882798
2789 decl_union: {2799 decl_union: {
2790 const value_inst = value_inst: {2800 const value_inst = value_inst: {
2791 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2792 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2801 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2793 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2802 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2794 if (break_inst.tag != .break_inline) break :value_inst null;2803 if (break_inst.tag != .break_inline) break :value_inst null;
...@@ -2911,7 +2920,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2911,7 +2920,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
29112920
2912 decl_opaque: {2921 decl_opaque: {
2913 const value_inst = value_inst: {2922 const value_inst = value_inst: {
2914 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2915 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2923 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2916 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2924 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2917 if (break_inst.tag != .break_inline) break :value_inst null;2925 if (break_inst.tag != .break_inline) break :value_inst null;
...@@ -3685,7 +3693,7 @@ pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void {...@@ -3685,7 +3693,7 @@ pub fn freeNav(dwarf: *Dwarf, nav_index: InternPool.Nav.Index) void {
3685 _ = nav_index;3693 _ = nav_index;
3686}3694}
36873695
3688fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(AbbrevCode).Enum.tag_type {3696fn refAbbrevCode(dwarf: *Dwarf, abbrev_code: AbbrevCode) UpdateError!@typeInfo(AbbrevCode).@"enum".tag_type {
3689 assert(abbrev_code != .null);3697 assert(abbrev_code != .null);
3690 const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code));3698 const entry: Entry.Index = @enumFromInt(@intFromEnum(abbrev_code));
3691 if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code);3699 if (dwarf.debug_abbrev.section.getUnit(DebugAbbrev.unit).getEntry(entry).len > 0) return @intFromEnum(abbrev_code);
...@@ -4087,7 +4095,7 @@ pub fn resolveRelocs(dwarf: *Dwarf) RelocError!void {...@@ -4087,7 +4095,7 @@ pub fn resolveRelocs(dwarf: *Dwarf) RelocError!void {
4087}4095}
40884096
4089fn DeclValEnum(comptime T: type) type {4097fn DeclValEnum(comptime T: type) type {
4090 const decls = @typeInfo(T).Struct.decls;4098 const decls = @typeInfo(T).@"struct".decls;
4091 @setEvalBranchQuota(7 * decls.len);4099 @setEvalBranchQuota(7 * decls.len);
4092 var fields: [decls.len]std.builtin.Type.EnumField = undefined;4100 var fields: [decls.len]std.builtin.Type.EnumField = undefined;
4093 var fields_len = 0;4101 var fields_len = 0;
...@@ -4101,7 +4109,7 @@ fn DeclValEnum(comptime T: type) type {...@@ -4101,7 +4109,7 @@ fn DeclValEnum(comptime T: type) type {
4101 if (min_value == null or min_value.? > value) min_value = value;4109 if (min_value == null or min_value.? > value) min_value = value;
4102 if (max_value == null or max_value.? < value) max_value = value;4110 if (max_value == null or max_value.? < value) max_value = value;
4103 }4111 }
4104 return @Type(.{ .Enum = .{4112 return @Type(.{ .@"enum" = .{
4105 .tag_type = std.math.IntFittingRange(min_value orelse 0, max_value orelse 0),4113 .tag_type = std.math.IntFittingRange(min_value orelse 0, max_value orelse 0),
4106 .fields = fields[0..fields_len],4114 .fields = fields[0..fields_len],
4107 .decls = &.{},4115 .decls = &.{},
...@@ -4665,7 +4673,7 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index {...@@ -4665,7 +4673,7 @@ fn addCommonEntry(dwarf: *Dwarf, unit: Unit.Index) UpdateError!Entry.Index {
46654673
4666fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void {4674fn writeInt(dwarf: *Dwarf, buf: []u8, int: u64) void {
4667 switch (buf.len) {4675 switch (buf.len) {
4668 inline 0...8 => |len| std.mem.writeInt(@Type(.{ .Int = .{4676 inline 0...8 => |len| std.mem.writeInt(@Type(.{ .int = .{
4669 .signedness = .unsigned,4677 .signedness = .unsigned,
4670 .bits = len * 8,4678 .bits = len * 8,
4671 } }), buf[0..len], @intCast(int), dwarf.endian),4679 } }), buf[0..len], @intCast(int), dwarf.endian),
src/link/Elf/Atom.zig+1-1
...@@ -1008,7 +1008,7 @@ const AddExtraOpts = struct {...@@ -1008,7 +1008,7 @@ const AddExtraOpts = struct {
1008pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) void {1008pub fn addExtra(atom: *Atom, opts: AddExtraOpts, elf_file: *Elf) void {
1009 const file_ptr = atom.file(elf_file).?;1009 const file_ptr = atom.file(elf_file).?;
1010 var extras = file_ptr.atomExtra(atom.extra_index);1010 var extras = file_ptr.atomExtra(atom.extra_index);
1011 inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {1011 inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
1012 if (@field(opts, field.name)) |x| {1012 if (@field(opts, field.name)) |x| {
1013 @field(extras, field.name) = x;1013 @field(extras, field.name) = x;
1014 }1014 }
src/link/Elf/LdScript.zig+1-1
...@@ -108,7 +108,7 @@ const Command = enum {...@@ -108,7 +108,7 @@ const Command = enum {
108 as_needed,108 as_needed,
109109
110 fn fromString(s: []const u8) ?Command {110 fn fromString(s: []const u8) ?Command {
111 inline for (@typeInfo(Command).Enum.fields) |field| {111 inline for (@typeInfo(Command).@"enum".fields) |field| {
112 const upper_name = n: {112 const upper_name = n: {
113 comptime var buf: [field.name.len]u8 = undefined;113 comptime var buf: [field.name.len]u8 = undefined;
114 inline for (field.name, 0..) |c, i| {114 inline for (field.name, 0..) |c, i| {
src/link/Elf/LinkerDefined.zig+4-4
...@@ -394,14 +394,14 @@ fn addSymbolAssumeCapacity(self: *LinkerDefined) Symbol.Index {...@@ -394,14 +394,14 @@ fn addSymbolAssumeCapacity(self: *LinkerDefined) Symbol.Index {
394}394}
395395
396pub fn addSymbolExtra(self: *LinkerDefined, allocator: Allocator, extra: Symbol.Extra) !u32 {396pub fn addSymbolExtra(self: *LinkerDefined, allocator: Allocator, extra: Symbol.Extra) !u32 {
397 const fields = @typeInfo(Symbol.Extra).Struct.fields;397 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
398 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);398 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
399 return self.addSymbolExtraAssumeCapacity(extra);399 return self.addSymbolExtraAssumeCapacity(extra);
400}400}
401401
402pub fn addSymbolExtraAssumeCapacity(self: *LinkerDefined, extra: Symbol.Extra) u32 {402pub fn addSymbolExtraAssumeCapacity(self: *LinkerDefined, extra: Symbol.Extra) u32 {
403 const index = @as(u32, @intCast(self.symbols_extra.items.len));403 const index = @as(u32, @intCast(self.symbols_extra.items.len));
404 const fields = @typeInfo(Symbol.Extra).Struct.fields;404 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
405 inline for (fields) |field| {405 inline for (fields) |field| {
406 self.symbols_extra.appendAssumeCapacity(switch (field.type) {406 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
407 u32 => @field(extra, field.name),407 u32 => @field(extra, field.name),
...@@ -412,7 +412,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *LinkerDefined, extra: Symbol.Extra) u...@@ -412,7 +412,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *LinkerDefined, extra: Symbol.Extra) u
412}412}
413413
414pub fn symbolExtra(self: *LinkerDefined, index: u32) Symbol.Extra {414pub fn symbolExtra(self: *LinkerDefined, index: u32) Symbol.Extra {
415 const fields = @typeInfo(Symbol.Extra).Struct.fields;415 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
416 var i: usize = index;416 var i: usize = index;
417 var result: Symbol.Extra = undefined;417 var result: Symbol.Extra = undefined;
418 inline for (fields) |field| {418 inline for (fields) |field| {
...@@ -426,7 +426,7 @@ pub fn symbolExtra(self: *LinkerDefined, index: u32) Symbol.Extra {...@@ -426,7 +426,7 @@ pub fn symbolExtra(self: *LinkerDefined, index: u32) Symbol.Extra {
426}426}
427427
428pub fn setSymbolExtra(self: *LinkerDefined, index: u32, extra: Symbol.Extra) void {428pub fn setSymbolExtra(self: *LinkerDefined, index: u32, extra: Symbol.Extra) void {
429 const fields = @typeInfo(Symbol.Extra).Struct.fields;429 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
430 inline for (fields, 0..) |field, i| {430 inline for (fields, 0..) |field, i| {
431 self.symbols_extra.items[index + i] = switch (field.type) {431 self.symbols_extra.items[index + i] = switch (field.type) {
432 u32 => @field(extra, field.name),432 u32 => @field(extra, field.name),
src/link/Elf/Object.zig+8-8
...@@ -1215,14 +1215,14 @@ fn addSymbolAssumeCapacity(self: *Object) Symbol.Index {...@@ -1215,14 +1215,14 @@ fn addSymbolAssumeCapacity(self: *Object) Symbol.Index {
1215}1215}
12161216
1217pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 {1217pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 {
1218 const fields = @typeInfo(Symbol.Extra).Struct.fields;1218 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1219 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);1219 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
1220 return self.addSymbolExtraAssumeCapacity(extra);1220 return self.addSymbolExtraAssumeCapacity(extra);
1221}1221}
12221222
1223pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {1223pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {
1224 const index = @as(u32, @intCast(self.symbols_extra.items.len));1224 const index = @as(u32, @intCast(self.symbols_extra.items.len));
1225 const fields = @typeInfo(Symbol.Extra).Struct.fields;1225 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1226 inline for (fields) |field| {1226 inline for (fields) |field| {
1227 self.symbols_extra.appendAssumeCapacity(switch (field.type) {1227 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
1228 u32 => @field(extra, field.name),1228 u32 => @field(extra, field.name),
...@@ -1233,7 +1233,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {...@@ -1233,7 +1233,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {
1233}1233}
12341234
1235pub fn symbolExtra(self: *Object, index: u32) Symbol.Extra {1235pub fn symbolExtra(self: *Object, index: u32) Symbol.Extra {
1236 const fields = @typeInfo(Symbol.Extra).Struct.fields;1236 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1237 var i: usize = index;1237 var i: usize = index;
1238 var result: Symbol.Extra = undefined;1238 var result: Symbol.Extra = undefined;
1239 inline for (fields) |field| {1239 inline for (fields) |field| {
...@@ -1247,7 +1247,7 @@ pub fn symbolExtra(self: *Object, index: u32) Symbol.Extra {...@@ -1247,7 +1247,7 @@ pub fn symbolExtra(self: *Object, index: u32) Symbol.Extra {
1247}1247}
12481248
1249pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void {1249pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void {
1250 const fields = @typeInfo(Symbol.Extra).Struct.fields;1250 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1251 inline for (fields, 0..) |field, i| {1251 inline for (fields, 0..) |field, i| {
1252 self.symbols_extra.items[index + i] = switch (field.type) {1252 self.symbols_extra.items[index + i] = switch (field.type) {
1253 u32 => @field(extra, field.name),1253 u32 => @field(extra, field.name),
...@@ -1325,14 +1325,14 @@ pub fn atom(self: *Object, atom_index: Atom.Index) ?*Atom {...@@ -1325,14 +1325,14 @@ pub fn atom(self: *Object, atom_index: Atom.Index) ?*Atom {
1325}1325}
13261326
1327pub fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 {1327pub fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 {
1328 const fields = @typeInfo(Atom.Extra).Struct.fields;1328 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1329 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);1329 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);
1330 return self.addAtomExtraAssumeCapacity(extra);1330 return self.addAtomExtraAssumeCapacity(extra);
1331}1331}
13321332
1333pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {1333pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {
1334 const index = @as(u32, @intCast(self.atoms_extra.items.len));1334 const index = @as(u32, @intCast(self.atoms_extra.items.len));
1335 const fields = @typeInfo(Atom.Extra).Struct.fields;1335 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1336 inline for (fields) |field| {1336 inline for (fields) |field| {
1337 self.atoms_extra.appendAssumeCapacity(switch (field.type) {1337 self.atoms_extra.appendAssumeCapacity(switch (field.type) {
1338 u32 => @field(extra, field.name),1338 u32 => @field(extra, field.name),
...@@ -1343,7 +1343,7 @@ pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {...@@ -1343,7 +1343,7 @@ pub fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {
1343}1343}
13441344
1345pub fn atomExtra(self: *Object, index: u32) Atom.Extra {1345pub fn atomExtra(self: *Object, index: u32) Atom.Extra {
1346 const fields = @typeInfo(Atom.Extra).Struct.fields;1346 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1347 var i: usize = index;1347 var i: usize = index;
1348 var result: Atom.Extra = undefined;1348 var result: Atom.Extra = undefined;
1349 inline for (fields) |field| {1349 inline for (fields) |field| {
...@@ -1357,7 +1357,7 @@ pub fn atomExtra(self: *Object, index: u32) Atom.Extra {...@@ -1357,7 +1357,7 @@ pub fn atomExtra(self: *Object, index: u32) Atom.Extra {
1357}1357}
13581358
1359pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void {1359pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void {
1360 const fields = @typeInfo(Atom.Extra).Struct.fields;1360 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1361 inline for (fields, 0..) |field, i| {1361 inline for (fields, 0..) |field, i| {
1362 self.atoms_extra.items[index + i] = switch (field.type) {1362 self.atoms_extra.items[index + i] = switch (field.type) {
1363 u32 => @field(extra, field.name),1363 u32 => @field(extra, field.name),
src/link/Elf/SharedObject.zig+4-4
...@@ -423,14 +423,14 @@ fn addSymbolAssumeCapacity(self: *SharedObject) Symbol.Index {...@@ -423,14 +423,14 @@ fn addSymbolAssumeCapacity(self: *SharedObject) Symbol.Index {
423}423}
424424
425pub fn addSymbolExtra(self: *SharedObject, allocator: Allocator, extra: Symbol.Extra) !u32 {425pub fn addSymbolExtra(self: *SharedObject, allocator: Allocator, extra: Symbol.Extra) !u32 {
426 const fields = @typeInfo(Symbol.Extra).Struct.fields;426 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
427 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);427 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
428 return self.addSymbolExtraAssumeCapacity(extra);428 return self.addSymbolExtraAssumeCapacity(extra);
429}429}
430430
431pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u32 {431pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u32 {
432 const index = @as(u32, @intCast(self.symbols_extra.items.len));432 const index = @as(u32, @intCast(self.symbols_extra.items.len));
433 const fields = @typeInfo(Symbol.Extra).Struct.fields;433 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
434 inline for (fields) |field| {434 inline for (fields) |field| {
435 self.symbols_extra.appendAssumeCapacity(switch (field.type) {435 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
436 u32 => @field(extra, field.name),436 u32 => @field(extra, field.name),
...@@ -441,7 +441,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u3...@@ -441,7 +441,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *SharedObject, extra: Symbol.Extra) u3
441}441}
442442
443pub fn symbolExtra(self: *SharedObject, index: u32) Symbol.Extra {443pub fn symbolExtra(self: *SharedObject, index: u32) Symbol.Extra {
444 const fields = @typeInfo(Symbol.Extra).Struct.fields;444 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
445 var i: usize = index;445 var i: usize = index;
446 var result: Symbol.Extra = undefined;446 var result: Symbol.Extra = undefined;
447 inline for (fields) |field| {447 inline for (fields) |field| {
...@@ -455,7 +455,7 @@ pub fn symbolExtra(self: *SharedObject, index: u32) Symbol.Extra {...@@ -455,7 +455,7 @@ pub fn symbolExtra(self: *SharedObject, index: u32) Symbol.Extra {
455}455}
456456
457pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void {457pub fn setSymbolExtra(self: *SharedObject, index: u32, extra: Symbol.Extra) void {
458 const fields = @typeInfo(Symbol.Extra).Struct.fields;458 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
459 inline for (fields, 0..) |field, i| {459 inline for (fields, 0..) |field, i| {
460 self.symbols_extra.items[index + i] = switch (field.type) {460 self.symbols_extra.items[index + i] = switch (field.type) {
461 u32 => @field(extra, field.name),461 u32 => @field(extra, field.name),
src/link/Elf/Symbol.zig+1-1
...@@ -255,7 +255,7 @@ const AddExtraOpts = struct {...@@ -255,7 +255,7 @@ const AddExtraOpts = struct {
255255
256pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, elf_file: *Elf) void {256pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, elf_file: *Elf) void {
257 var extras = symbol.extra(elf_file);257 var extras = symbol.extra(elf_file);
258 inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {258 inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
259 if (@field(opts, field.name)) |x| {259 if (@field(opts, field.name)) |x| {
260 @field(extras, field.name) = x;260 @field(extras, field.name) = x;
261 }261 }
src/link/Elf/ZigObject.zig+8-8
...@@ -2034,14 +2034,14 @@ pub fn atom(self: *ZigObject, atom_index: Atom.Index) ?*Atom {...@@ -2034,14 +2034,14 @@ pub fn atom(self: *ZigObject, atom_index: Atom.Index) ?*Atom {
2034}2034}
20352035
2036fn addAtomExtra(self: *ZigObject, allocator: Allocator, extra: Atom.Extra) !u32 {2036fn addAtomExtra(self: *ZigObject, allocator: Allocator, extra: Atom.Extra) !u32 {
2037 const fields = @typeInfo(Atom.Extra).Struct.fields;2037 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2038 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);2038 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);
2039 return self.addAtomExtraAssumeCapacity(extra);2039 return self.addAtomExtraAssumeCapacity(extra);
2040}2040}
20412041
2042fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {2042fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {
2043 const index = @as(u32, @intCast(self.atoms_extra.items.len));2043 const index = @as(u32, @intCast(self.atoms_extra.items.len));
2044 const fields = @typeInfo(Atom.Extra).Struct.fields;2044 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2045 inline for (fields) |field| {2045 inline for (fields) |field| {
2046 self.atoms_extra.appendAssumeCapacity(switch (field.type) {2046 self.atoms_extra.appendAssumeCapacity(switch (field.type) {
2047 u32 => @field(extra, field.name),2047 u32 => @field(extra, field.name),
...@@ -2052,7 +2052,7 @@ fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {...@@ -2052,7 +2052,7 @@ fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {
2052}2052}
20532053
2054pub fn atomExtra(self: ZigObject, index: u32) Atom.Extra {2054pub fn atomExtra(self: ZigObject, index: u32) Atom.Extra {
2055 const fields = @typeInfo(Atom.Extra).Struct.fields;2055 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2056 var i: usize = index;2056 var i: usize = index;
2057 var result: Atom.Extra = undefined;2057 var result: Atom.Extra = undefined;
2058 inline for (fields) |field| {2058 inline for (fields) |field| {
...@@ -2067,7 +2067,7 @@ pub fn atomExtra(self: ZigObject, index: u32) Atom.Extra {...@@ -2067,7 +2067,7 @@ pub fn atomExtra(self: ZigObject, index: u32) Atom.Extra {
20672067
2068pub fn setAtomExtra(self: *ZigObject, index: u32, extra: Atom.Extra) void {2068pub fn setAtomExtra(self: *ZigObject, index: u32, extra: Atom.Extra) void {
2069 assert(index > 0);2069 assert(index > 0);
2070 const fields = @typeInfo(Atom.Extra).Struct.fields;2070 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2071 inline for (fields, 0..) |field, i| {2071 inline for (fields, 0..) |field, i| {
2072 self.atoms_extra.items[index + i] = switch (field.type) {2072 self.atoms_extra.items[index + i] = switch (field.type) {
2073 u32 => @field(extra, field.name),2073 u32 => @field(extra, field.name),
...@@ -2106,14 +2106,14 @@ fn addSymbolAssumeCapacity(self: *ZigObject) Symbol.Index {...@@ -2106,14 +2106,14 @@ fn addSymbolAssumeCapacity(self: *ZigObject) Symbol.Index {
2106}2106}
21072107
2108pub fn addSymbolExtra(self: *ZigObject, allocator: Allocator, extra: Symbol.Extra) !u32 {2108pub fn addSymbolExtra(self: *ZigObject, allocator: Allocator, extra: Symbol.Extra) !u32 {
2109 const fields = @typeInfo(Symbol.Extra).Struct.fields;2109 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2110 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);2110 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
2111 return self.addSymbolExtraAssumeCapacity(extra);2111 return self.addSymbolExtraAssumeCapacity(extra);
2112}2112}
21132113
2114pub fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {2114pub fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {
2115 const index = @as(u32, @intCast(self.symbols_extra.items.len));2115 const index = @as(u32, @intCast(self.symbols_extra.items.len));
2116 const fields = @typeInfo(Symbol.Extra).Struct.fields;2116 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2117 inline for (fields) |field| {2117 inline for (fields) |field| {
2118 self.symbols_extra.appendAssumeCapacity(switch (field.type) {2118 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
2119 u32 => @field(extra, field.name),2119 u32 => @field(extra, field.name),
...@@ -2124,7 +2124,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {...@@ -2124,7 +2124,7 @@ pub fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {
2124}2124}
21252125
2126pub fn symbolExtra(self: *ZigObject, index: u32) Symbol.Extra {2126pub fn symbolExtra(self: *ZigObject, index: u32) Symbol.Extra {
2127 const fields = @typeInfo(Symbol.Extra).Struct.fields;2127 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2128 var i: usize = index;2128 var i: usize = index;
2129 var result: Symbol.Extra = undefined;2129 var result: Symbol.Extra = undefined;
2130 inline for (fields) |field| {2130 inline for (fields) |field| {
...@@ -2138,7 +2138,7 @@ pub fn symbolExtra(self: *ZigObject, index: u32) Symbol.Extra {...@@ -2138,7 +2138,7 @@ pub fn symbolExtra(self: *ZigObject, index: u32) Symbol.Extra {
2138}2138}
21392139
2140pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void {2140pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void {
2141 const fields = @typeInfo(Symbol.Extra).Struct.fields;2141 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2142 inline for (fields, 0..) |field, i| {2142 inline for (fields, 0..) |field, i| {
2143 self.symbols_extra.items[index + i] = switch (field.type) {2143 self.symbols_extra.items[index + i] = switch (field.type) {
2144 u32 => @field(extra, field.name),2144 u32 => @field(extra, field.name),
src/link/MachO/Archive.zig+1-1
...@@ -90,7 +90,7 @@ pub fn writeHeader(...@@ -90,7 +90,7 @@ pub fn writeHeader(
90 .ar_fmag = undefined,90 .ar_fmag = undefined,
91 };91 };
92 @memset(mem.asBytes(&hdr), 0x20);92 @memset(mem.asBytes(&hdr), 0x20);
93 inline for (@typeInfo(ar_hdr).Struct.fields) |field| {93 inline for (@typeInfo(ar_hdr).@"struct".fields) |field| {
94 var stream = std.io.fixedBufferStream(&@field(hdr, field.name));94 var stream = std.io.fixedBufferStream(&@field(hdr, field.name));
95 stream.writer().print("0", .{}) catch unreachable;95 stream.writer().print("0", .{}) catch unreachable;
96 }96 }
src/link/MachO/Atom.zig+1-1
...@@ -129,7 +129,7 @@ const AddExtraOpts = struct {...@@ -129,7 +129,7 @@ const AddExtraOpts = struct {
129pub fn addExtra(atom: *Atom, opts: AddExtraOpts, macho_file: *MachO) void {129pub fn addExtra(atom: *Atom, opts: AddExtraOpts, macho_file: *MachO) void {
130 const file = atom.getFile(macho_file);130 const file = atom.getFile(macho_file);
131 var extra = file.getAtomExtra(atom.extra);131 var extra = file.getAtomExtra(atom.extra);
132 inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {132 inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
133 if (@field(opts, field.name)) |x| {133 if (@field(opts, field.name)) |x| {
134 @field(extra, field.name) = x;134 @field(extra, field.name) = x;
135 }135 }
src/link/MachO/Dylib.zig+4-4
...@@ -650,14 +650,14 @@ pub fn getSymbolRef(self: Dylib, index: Symbol.Index, macho_file: *MachO) MachO....@@ -650,14 +650,14 @@ pub fn getSymbolRef(self: Dylib, index: Symbol.Index, macho_file: *MachO) MachO.
650}650}
651651
652pub fn addSymbolExtra(self: *Dylib, allocator: Allocator, extra: Symbol.Extra) !u32 {652pub fn addSymbolExtra(self: *Dylib, allocator: Allocator, extra: Symbol.Extra) !u32 {
653 const fields = @typeInfo(Symbol.Extra).Struct.fields;653 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
654 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);654 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
655 return self.addSymbolExtraAssumeCapacity(extra);655 return self.addSymbolExtraAssumeCapacity(extra);
656}656}
657657
658fn addSymbolExtraAssumeCapacity(self: *Dylib, extra: Symbol.Extra) u32 {658fn addSymbolExtraAssumeCapacity(self: *Dylib, extra: Symbol.Extra) u32 {
659 const index = @as(u32, @intCast(self.symbols_extra.items.len));659 const index = @as(u32, @intCast(self.symbols_extra.items.len));
660 const fields = @typeInfo(Symbol.Extra).Struct.fields;660 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
661 inline for (fields) |field| {661 inline for (fields) |field| {
662 self.symbols_extra.appendAssumeCapacity(switch (field.type) {662 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
663 u32 => @field(extra, field.name),663 u32 => @field(extra, field.name),
...@@ -668,7 +668,7 @@ fn addSymbolExtraAssumeCapacity(self: *Dylib, extra: Symbol.Extra) u32 {...@@ -668,7 +668,7 @@ fn addSymbolExtraAssumeCapacity(self: *Dylib, extra: Symbol.Extra) u32 {
668}668}
669669
670pub fn getSymbolExtra(self: Dylib, index: u32) Symbol.Extra {670pub fn getSymbolExtra(self: Dylib, index: u32) Symbol.Extra {
671 const fields = @typeInfo(Symbol.Extra).Struct.fields;671 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
672 var i: usize = index;672 var i: usize = index;
673 var result: Symbol.Extra = undefined;673 var result: Symbol.Extra = undefined;
674 inline for (fields) |field| {674 inline for (fields) |field| {
...@@ -682,7 +682,7 @@ pub fn getSymbolExtra(self: Dylib, index: u32) Symbol.Extra {...@@ -682,7 +682,7 @@ pub fn getSymbolExtra(self: Dylib, index: u32) Symbol.Extra {
682}682}
683683
684pub fn setSymbolExtra(self: *Dylib, index: u32, extra: Symbol.Extra) void {684pub fn setSymbolExtra(self: *Dylib, index: u32, extra: Symbol.Extra) void {
685 const fields = @typeInfo(Symbol.Extra).Struct.fields;685 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
686 inline for (fields, 0..) |field, i| {686 inline for (fields, 0..) |field, i| {
687 self.symbols_extra.items[index + i] = switch (field.type) {687 self.symbols_extra.items[index + i] = switch (field.type) {
688 u32 => @field(extra, field.name),688 u32 => @field(extra, field.name),
src/link/MachO/InternalObject.zig+8-8
...@@ -669,14 +669,14 @@ pub fn getAtoms(self: InternalObject) []const Atom.Index {...@@ -669,14 +669,14 @@ pub fn getAtoms(self: InternalObject) []const Atom.Index {
669}669}
670670
671fn addAtomExtra(self: *InternalObject, allocator: Allocator, extra: Atom.Extra) !u32 {671fn addAtomExtra(self: *InternalObject, allocator: Allocator, extra: Atom.Extra) !u32 {
672 const fields = @typeInfo(Atom.Extra).Struct.fields;672 const fields = @typeInfo(Atom.Extra).@"struct".fields;
673 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);673 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);
674 return self.addAtomExtraAssumeCapacity(extra);674 return self.addAtomExtraAssumeCapacity(extra);
675}675}
676676
677fn addAtomExtraAssumeCapacity(self: *InternalObject, extra: Atom.Extra) u32 {677fn addAtomExtraAssumeCapacity(self: *InternalObject, extra: Atom.Extra) u32 {
678 const index = @as(u32, @intCast(self.atoms_extra.items.len));678 const index = @as(u32, @intCast(self.atoms_extra.items.len));
679 const fields = @typeInfo(Atom.Extra).Struct.fields;679 const fields = @typeInfo(Atom.Extra).@"struct".fields;
680 inline for (fields) |field| {680 inline for (fields) |field| {
681 self.atoms_extra.appendAssumeCapacity(switch (field.type) {681 self.atoms_extra.appendAssumeCapacity(switch (field.type) {
682 u32 => @field(extra, field.name),682 u32 => @field(extra, field.name),
...@@ -687,7 +687,7 @@ fn addAtomExtraAssumeCapacity(self: *InternalObject, extra: Atom.Extra) u32 {...@@ -687,7 +687,7 @@ fn addAtomExtraAssumeCapacity(self: *InternalObject, extra: Atom.Extra) u32 {
687}687}
688688
689pub fn getAtomExtra(self: InternalObject, index: u32) Atom.Extra {689pub fn getAtomExtra(self: InternalObject, index: u32) Atom.Extra {
690 const fields = @typeInfo(Atom.Extra).Struct.fields;690 const fields = @typeInfo(Atom.Extra).@"struct".fields;
691 var i: usize = index;691 var i: usize = index;
692 var result: Atom.Extra = undefined;692 var result: Atom.Extra = undefined;
693 inline for (fields) |field| {693 inline for (fields) |field| {
...@@ -702,7 +702,7 @@ pub fn getAtomExtra(self: InternalObject, index: u32) Atom.Extra {...@@ -702,7 +702,7 @@ pub fn getAtomExtra(self: InternalObject, index: u32) Atom.Extra {
702702
703pub fn setAtomExtra(self: *InternalObject, index: u32, extra: Atom.Extra) void {703pub fn setAtomExtra(self: *InternalObject, index: u32, extra: Atom.Extra) void {
704 assert(index > 0);704 assert(index > 0);
705 const fields = @typeInfo(Atom.Extra).Struct.fields;705 const fields = @typeInfo(Atom.Extra).@"struct".fields;
706 inline for (fields, 0..) |field, i| {706 inline for (fields, 0..) |field, i| {
707 self.atoms_extra.items[index + i] = switch (field.type) {707 self.atoms_extra.items[index + i] = switch (field.type) {
708 u32 => @field(extra, field.name),708 u32 => @field(extra, field.name),
...@@ -750,14 +750,14 @@ pub fn getSymbolRef(self: InternalObject, index: Symbol.Index, macho_file: *Mach...@@ -750,14 +750,14 @@ pub fn getSymbolRef(self: InternalObject, index: Symbol.Index, macho_file: *Mach
750}750}
751751
752pub fn addSymbolExtra(self: *InternalObject, allocator: Allocator, extra: Symbol.Extra) !u32 {752pub fn addSymbolExtra(self: *InternalObject, allocator: Allocator, extra: Symbol.Extra) !u32 {
753 const fields = @typeInfo(Symbol.Extra).Struct.fields;753 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
754 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);754 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
755 return self.addSymbolExtraAssumeCapacity(extra);755 return self.addSymbolExtraAssumeCapacity(extra);
756}756}
757757
758fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32 {758fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32 {
759 const index = @as(u32, @intCast(self.symbols_extra.items.len));759 const index = @as(u32, @intCast(self.symbols_extra.items.len));
760 const fields = @typeInfo(Symbol.Extra).Struct.fields;760 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
761 inline for (fields) |field| {761 inline for (fields) |field| {
762 self.symbols_extra.appendAssumeCapacity(switch (field.type) {762 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
763 u32 => @field(extra, field.name),763 u32 => @field(extra, field.name),
...@@ -768,7 +768,7 @@ fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32...@@ -768,7 +768,7 @@ fn addSymbolExtraAssumeCapacity(self: *InternalObject, extra: Symbol.Extra) u32
768}768}
769769
770pub fn getSymbolExtra(self: InternalObject, index: u32) Symbol.Extra {770pub fn getSymbolExtra(self: InternalObject, index: u32) Symbol.Extra {
771 const fields = @typeInfo(Symbol.Extra).Struct.fields;771 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
772 var i: usize = index;772 var i: usize = index;
773 var result: Symbol.Extra = undefined;773 var result: Symbol.Extra = undefined;
774 inline for (fields) |field| {774 inline for (fields) |field| {
...@@ -782,7 +782,7 @@ pub fn getSymbolExtra(self: InternalObject, index: u32) Symbol.Extra {...@@ -782,7 +782,7 @@ pub fn getSymbolExtra(self: InternalObject, index: u32) Symbol.Extra {
782}782}
783783
784pub fn setSymbolExtra(self: *InternalObject, index: u32, extra: Symbol.Extra) void {784pub fn setSymbolExtra(self: *InternalObject, index: u32, extra: Symbol.Extra) void {
785 const fields = @typeInfo(Symbol.Extra).Struct.fields;785 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
786 inline for (fields, 0..) |field, i| {786 inline for (fields, 0..) |field, i| {
787 self.symbols_extra.items[index + i] = switch (field.type) {787 self.symbols_extra.items[index + i] = switch (field.type) {
788 u32 => @field(extra, field.name),788 u32 => @field(extra, field.name),
src/link/MachO/Object.zig+8-8
...@@ -2386,14 +2386,14 @@ pub fn getAtoms(self: *Object) []const Atom.Index {...@@ -2386,14 +2386,14 @@ pub fn getAtoms(self: *Object) []const Atom.Index {
2386}2386}
23872387
2388fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 {2388fn addAtomExtra(self: *Object, allocator: Allocator, extra: Atom.Extra) !u32 {
2389 const fields = @typeInfo(Atom.Extra).Struct.fields;2389 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2390 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);2390 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);
2391 return self.addAtomExtraAssumeCapacity(extra);2391 return self.addAtomExtraAssumeCapacity(extra);
2392}2392}
23932393
2394fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {2394fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {
2395 const index = @as(u32, @intCast(self.atoms_extra.items.len));2395 const index = @as(u32, @intCast(self.atoms_extra.items.len));
2396 const fields = @typeInfo(Atom.Extra).Struct.fields;2396 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2397 inline for (fields) |field| {2397 inline for (fields) |field| {
2398 self.atoms_extra.appendAssumeCapacity(switch (field.type) {2398 self.atoms_extra.appendAssumeCapacity(switch (field.type) {
2399 u32 => @field(extra, field.name),2399 u32 => @field(extra, field.name),
...@@ -2404,7 +2404,7 @@ fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {...@@ -2404,7 +2404,7 @@ fn addAtomExtraAssumeCapacity(self: *Object, extra: Atom.Extra) u32 {
2404}2404}
24052405
2406pub fn getAtomExtra(self: Object, index: u32) Atom.Extra {2406pub fn getAtomExtra(self: Object, index: u32) Atom.Extra {
2407 const fields = @typeInfo(Atom.Extra).Struct.fields;2407 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2408 var i: usize = index;2408 var i: usize = index;
2409 var result: Atom.Extra = undefined;2409 var result: Atom.Extra = undefined;
2410 inline for (fields) |field| {2410 inline for (fields) |field| {
...@@ -2419,7 +2419,7 @@ pub fn getAtomExtra(self: Object, index: u32) Atom.Extra {...@@ -2419,7 +2419,7 @@ pub fn getAtomExtra(self: Object, index: u32) Atom.Extra {
24192419
2420pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void {2420pub fn setAtomExtra(self: *Object, index: u32, extra: Atom.Extra) void {
2421 assert(index > 0);2421 assert(index > 0);
2422 const fields = @typeInfo(Atom.Extra).Struct.fields;2422 const fields = @typeInfo(Atom.Extra).@"struct".fields;
2423 inline for (fields, 0..) |field, i| {2423 inline for (fields, 0..) |field, i| {
2424 self.atoms_extra.items[index + i] = switch (field.type) {2424 self.atoms_extra.items[index + i] = switch (field.type) {
2425 u32 => @field(extra, field.name),2425 u32 => @field(extra, field.name),
...@@ -2447,14 +2447,14 @@ pub fn getSymbolRef(self: Object, index: Symbol.Index, macho_file: *MachO) MachO...@@ -2447,14 +2447,14 @@ pub fn getSymbolRef(self: Object, index: Symbol.Index, macho_file: *MachO) MachO
2447}2447}
24482448
2449pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 {2449pub fn addSymbolExtra(self: *Object, allocator: Allocator, extra: Symbol.Extra) !u32 {
2450 const fields = @typeInfo(Symbol.Extra).Struct.fields;2450 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2451 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);2451 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
2452 return self.addSymbolExtraAssumeCapacity(extra);2452 return self.addSymbolExtraAssumeCapacity(extra);
2453}2453}
24542454
2455fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {2455fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {
2456 const index = @as(u32, @intCast(self.symbols_extra.items.len));2456 const index = @as(u32, @intCast(self.symbols_extra.items.len));
2457 const fields = @typeInfo(Symbol.Extra).Struct.fields;2457 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2458 inline for (fields) |field| {2458 inline for (fields) |field| {
2459 self.symbols_extra.appendAssumeCapacity(switch (field.type) {2459 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
2460 u32 => @field(extra, field.name),2460 u32 => @field(extra, field.name),
...@@ -2465,7 +2465,7 @@ fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {...@@ -2465,7 +2465,7 @@ fn addSymbolExtraAssumeCapacity(self: *Object, extra: Symbol.Extra) u32 {
2465}2465}
24662466
2467pub fn getSymbolExtra(self: Object, index: u32) Symbol.Extra {2467pub fn getSymbolExtra(self: Object, index: u32) Symbol.Extra {
2468 const fields = @typeInfo(Symbol.Extra).Struct.fields;2468 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2469 var i: usize = index;2469 var i: usize = index;
2470 var result: Symbol.Extra = undefined;2470 var result: Symbol.Extra = undefined;
2471 inline for (fields) |field| {2471 inline for (fields) |field| {
...@@ -2479,7 +2479,7 @@ pub fn getSymbolExtra(self: Object, index: u32) Symbol.Extra {...@@ -2479,7 +2479,7 @@ pub fn getSymbolExtra(self: Object, index: u32) Symbol.Extra {
2479}2479}
24802480
2481pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void {2481pub fn setSymbolExtra(self: *Object, index: u32, extra: Symbol.Extra) void {
2482 const fields = @typeInfo(Symbol.Extra).Struct.fields;2482 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
2483 inline for (fields, 0..) |field, i| {2483 inline for (fields, 0..) |field, i| {
2484 self.symbols_extra.items[index + i] = switch (field.type) {2484 self.symbols_extra.items[index + i] = switch (field.type) {
2485 u32 => @field(extra, field.name),2485 u32 => @field(extra, field.name),
src/link/MachO/Symbol.zig+1-1
...@@ -211,7 +211,7 @@ const AddExtraOpts = struct {...@@ -211,7 +211,7 @@ const AddExtraOpts = struct {
211211
212pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, macho_file: *MachO) void {212pub fn addExtra(symbol: *Symbol, opts: AddExtraOpts, macho_file: *MachO) void {
213 var extra = symbol.getExtra(macho_file);213 var extra = symbol.getExtra(macho_file);
214 inline for (@typeInfo(@TypeOf(opts)).Struct.fields) |field| {214 inline for (@typeInfo(@TypeOf(opts)).@"struct".fields) |field| {
215 if (@field(opts, field.name)) |x| {215 if (@field(opts, field.name)) |x| {
216 @field(extra, field.name) = x;216 @field(extra, field.name) = x;
217 }217 }
src/link/MachO/ZigObject.zig+8-8
...@@ -1581,14 +1581,14 @@ pub fn getAtoms(self: *ZigObject) []const Atom.Index {...@@ -1581,14 +1581,14 @@ pub fn getAtoms(self: *ZigObject) []const Atom.Index {
1581}1581}
15821582
1583fn addAtomExtra(self: *ZigObject, allocator: Allocator, extra: Atom.Extra) !u32 {1583fn addAtomExtra(self: *ZigObject, allocator: Allocator, extra: Atom.Extra) !u32 {
1584 const fields = @typeInfo(Atom.Extra).Struct.fields;1584 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1585 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);1585 try self.atoms_extra.ensureUnusedCapacity(allocator, fields.len);
1586 return self.addAtomExtraAssumeCapacity(extra);1586 return self.addAtomExtraAssumeCapacity(extra);
1587}1587}
15881588
1589fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {1589fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {
1590 const index = @as(u32, @intCast(self.atoms_extra.items.len));1590 const index = @as(u32, @intCast(self.atoms_extra.items.len));
1591 const fields = @typeInfo(Atom.Extra).Struct.fields;1591 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1592 inline for (fields) |field| {1592 inline for (fields) |field| {
1593 self.atoms_extra.appendAssumeCapacity(switch (field.type) {1593 self.atoms_extra.appendAssumeCapacity(switch (field.type) {
1594 u32 => @field(extra, field.name),1594 u32 => @field(extra, field.name),
...@@ -1599,7 +1599,7 @@ fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {...@@ -1599,7 +1599,7 @@ fn addAtomExtraAssumeCapacity(self: *ZigObject, extra: Atom.Extra) u32 {
1599}1599}
16001600
1601pub fn getAtomExtra(self: ZigObject, index: u32) Atom.Extra {1601pub fn getAtomExtra(self: ZigObject, index: u32) Atom.Extra {
1602 const fields = @typeInfo(Atom.Extra).Struct.fields;1602 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1603 var i: usize = index;1603 var i: usize = index;
1604 var result: Atom.Extra = undefined;1604 var result: Atom.Extra = undefined;
1605 inline for (fields) |field| {1605 inline for (fields) |field| {
...@@ -1614,7 +1614,7 @@ pub fn getAtomExtra(self: ZigObject, index: u32) Atom.Extra {...@@ -1614,7 +1614,7 @@ pub fn getAtomExtra(self: ZigObject, index: u32) Atom.Extra {
16141614
1615pub fn setAtomExtra(self: *ZigObject, index: u32, extra: Atom.Extra) void {1615pub fn setAtomExtra(self: *ZigObject, index: u32, extra: Atom.Extra) void {
1616 assert(index > 0);1616 assert(index > 0);
1617 const fields = @typeInfo(Atom.Extra).Struct.fields;1617 const fields = @typeInfo(Atom.Extra).@"struct".fields;
1618 inline for (fields, 0..) |field, i| {1618 inline for (fields, 0..) |field, i| {
1619 self.atoms_extra.items[index + i] = switch (field.type) {1619 self.atoms_extra.items[index + i] = switch (field.type) {
1620 u32 => @field(extra, field.name),1620 u32 => @field(extra, field.name),
...@@ -1642,14 +1642,14 @@ pub fn getSymbolRef(self: ZigObject, index: Symbol.Index, macho_file: *MachO) Ma...@@ -1642,14 +1642,14 @@ pub fn getSymbolRef(self: ZigObject, index: Symbol.Index, macho_file: *MachO) Ma
1642}1642}
16431643
1644pub fn addSymbolExtra(self: *ZigObject, allocator: Allocator, extra: Symbol.Extra) !u32 {1644pub fn addSymbolExtra(self: *ZigObject, allocator: Allocator, extra: Symbol.Extra) !u32 {
1645 const fields = @typeInfo(Symbol.Extra).Struct.fields;1645 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1646 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);1646 try self.symbols_extra.ensureUnusedCapacity(allocator, fields.len);
1647 return self.addSymbolExtraAssumeCapacity(extra);1647 return self.addSymbolExtraAssumeCapacity(extra);
1648}1648}
16491649
1650fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {1650fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {
1651 const index = @as(u32, @intCast(self.symbols_extra.items.len));1651 const index = @as(u32, @intCast(self.symbols_extra.items.len));
1652 const fields = @typeInfo(Symbol.Extra).Struct.fields;1652 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1653 inline for (fields) |field| {1653 inline for (fields) |field| {
1654 self.symbols_extra.appendAssumeCapacity(switch (field.type) {1654 self.symbols_extra.appendAssumeCapacity(switch (field.type) {
1655 u32 => @field(extra, field.name),1655 u32 => @field(extra, field.name),
...@@ -1660,7 +1660,7 @@ fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {...@@ -1660,7 +1660,7 @@ fn addSymbolExtraAssumeCapacity(self: *ZigObject, extra: Symbol.Extra) u32 {
1660}1660}
16611661
1662pub fn getSymbolExtra(self: ZigObject, index: u32) Symbol.Extra {1662pub fn getSymbolExtra(self: ZigObject, index: u32) Symbol.Extra {
1663 const fields = @typeInfo(Symbol.Extra).Struct.fields;1663 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1664 var i: usize = index;1664 var i: usize = index;
1665 var result: Symbol.Extra = undefined;1665 var result: Symbol.Extra = undefined;
1666 inline for (fields) |field| {1666 inline for (fields) |field| {
...@@ -1674,7 +1674,7 @@ pub fn getSymbolExtra(self: ZigObject, index: u32) Symbol.Extra {...@@ -1674,7 +1674,7 @@ pub fn getSymbolExtra(self: ZigObject, index: u32) Symbol.Extra {
1674}1674}
16751675
1676pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void {1676pub fn setSymbolExtra(self: *ZigObject, index: u32, extra: Symbol.Extra) void {
1677 const fields = @typeInfo(Symbol.Extra).Struct.fields;1677 const fields = @typeInfo(Symbol.Extra).@"struct".fields;
1678 inline for (fields, 0..) |field, i| {1678 inline for (fields, 0..) |field, i| {
1679 self.symbols_extra.items[index + i] = switch (field.type) {1679 self.symbols_extra.items[index + i] = switch (field.type) {
1680 u32 => @field(extra, field.name),1680 u32 => @field(extra, field.name),
src/link/Wasm.zig+6-6
...@@ -1169,7 +1169,7 @@ fn setupTLSRelocationsFunction(wasm: *Wasm) !void {...@@ -1169,7 +1169,7 @@ fn setupTLSRelocationsFunction(wasm: *Wasm) !void {
11691169
1170fn validateFeatures(1170fn validateFeatures(
1171 wasm: *const Wasm,1171 wasm: *const Wasm,
1172 to_emit: *[@typeInfo(types.Feature.Tag).Enum.fields.len]bool,1172 to_emit: *[@typeInfo(types.Feature.Tag).@"enum".fields.len]bool,
1173 emit_features_count: *u32,1173 emit_features_count: *u32,
1174) !void {1174) !void {
1175 const comp = wasm.base.comp;1175 const comp = wasm.base.comp;
...@@ -1177,7 +1177,7 @@ fn validateFeatures(...@@ -1177,7 +1177,7 @@ fn validateFeatures(
1177 const shared_memory = comp.config.shared_memory;1177 const shared_memory = comp.config.shared_memory;
1178 const cpu_features = target.cpu.features;1178 const cpu_features = target.cpu.features;
1179 const infer = cpu_features.isEmpty(); // when the user did not define any features, we infer them from linked objects.1179 const infer = cpu_features.isEmpty(); // when the user did not define any features, we infer them from linked objects.
1180 const known_features_count = @typeInfo(types.Feature.Tag).Enum.fields.len;1180 const known_features_count = @typeInfo(types.Feature.Tag).@"enum".fields.len;
11811181
1182 var allowed = [_]bool{false} ** known_features_count;1182 var allowed = [_]bool{false} ** known_features_count;
1183 var used = [_]u17{0} ** known_features_count;1183 var used = [_]u17{0} ** known_features_count;
...@@ -1192,7 +1192,7 @@ fn validateFeatures(...@@ -1192,7 +1192,7 @@ fn validateFeatures(
1192 // When the user has given an explicit list of features to enable,1192 // When the user has given an explicit list of features to enable,
1193 // we extract them and insert each into the 'allowed' list.1193 // we extract them and insert each into the 'allowed' list.
1194 if (!infer) {1194 if (!infer) {
1195 inline for (@typeInfo(std.Target.wasm.Feature).Enum.fields) |feature_field| {1195 inline for (@typeInfo(std.Target.wasm.Feature).@"enum".fields) |feature_field| {
1196 if (cpu_features.isEnabled(feature_field.value)) {1196 if (cpu_features.isEnabled(feature_field.value)) {
1197 allowed[feature_field.value] = true;1197 allowed[feature_field.value] = true;
1198 emit_features_count.* += 1;1198 emit_features_count.* += 1;
...@@ -2576,7 +2576,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no...@@ -2576,7 +2576,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
2576 if (wasm.base.hasErrors()) return error.FlushFailure;2576 if (wasm.base.hasErrors()) return error.FlushFailure;
25772577
2578 var emit_features_count: u32 = 0;2578 var emit_features_count: u32 = 0;
2579 var enabled_features: [@typeInfo(types.Feature.Tag).Enum.fields.len]bool = undefined;2579 var enabled_features: [@typeInfo(types.Feature.Tag).@"enum".fields.len]bool = undefined;
2580 try wasm.validateFeatures(&enabled_features, &emit_features_count);2580 try wasm.validateFeatures(&enabled_features, &emit_features_count);
2581 try wasm.resolveSymbolsInArchives();2581 try wasm.resolveSymbolsInArchives();
2582 if (wasm.base.hasErrors()) return error.FlushFailure;2582 if (wasm.base.hasErrors()) return error.FlushFailure;
...@@ -2610,7 +2610,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no...@@ -2610,7 +2610,7 @@ pub fn flushModule(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_no
2610/// Writes the WebAssembly in-memory module to the file2610/// Writes the WebAssembly in-memory module to the file
2611fn writeToFile(2611fn writeToFile(
2612 wasm: *Wasm,2612 wasm: *Wasm,
2613 enabled_features: [@typeInfo(types.Feature.Tag).Enum.fields.len]bool,2613 enabled_features: [@typeInfo(types.Feature.Tag).@"enum".fields.len]bool,
2614 feature_count: u32,2614 feature_count: u32,
2615 arena: Allocator,2615 arena: Allocator,
2616) !void {2616) !void {
...@@ -3867,7 +3867,7 @@ fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void {...@@ -3867,7 +3867,7 @@ fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void {
38673867
3868pub fn getUleb128Size(uint_value: anytype) u32 {3868pub fn getUleb128Size(uint_value: anytype) u32 {
3869 const T = @TypeOf(uint_value);3869 const T = @TypeOf(uint_value);
3870 const U = if (@typeInfo(T).Int.bits < 8) u8 else T;3870 const U = if (@typeInfo(T).int.bits < 8) u8 else T;
3871 var value = @as(U, @intCast(uint_value));3871 var value = @as(U, @intCast(uint_value));
38723872
3873 var size: u32 = 0;3873 var size: u32 = 0;
src/link/Wasm/Object.zig+2-2
...@@ -871,7 +871,7 @@ fn ElementType(comptime ptr: type) type {...@@ -871,7 +871,7 @@ fn ElementType(comptime ptr: type) type {
871/// signedness of the given type `T`.871/// signedness of the given type `T`.
872/// Asserts `T` is an integer.872/// Asserts `T` is an integer.
873fn readLeb(comptime T: type, reader: anytype) !T {873fn readLeb(comptime T: type, reader: anytype) !T {
874 return switch (@typeInfo(T).Int.signedness) {874 return switch (@typeInfo(T).int.signedness) {
875 .signed => try leb.readIleb128(T, reader),875 .signed => try leb.readIleb128(T, reader),
876 .unsigned => try leb.readUleb128(T, reader),876 .unsigned => try leb.readUleb128(T, reader),
877 };877 };
...@@ -881,7 +881,7 @@ fn readLeb(comptime T: type, reader: anytype) !T {...@@ -881,7 +881,7 @@ fn readLeb(comptime T: type, reader: anytype) !T {
881/// Asserts `T` is an enum881/// Asserts `T` is an enum
882fn readEnum(comptime T: type, reader: anytype) !T {882fn readEnum(comptime T: type, reader: anytype) !T {
883 switch (@typeInfo(T)) {883 switch (@typeInfo(T)) {
884 .Enum => |enum_type| return @as(T, @enumFromInt(try readLeb(enum_type.tag_type, reader))),884 .@"enum" => |enum_type| return @as(T, @enumFromInt(try readLeb(enum_type.tag_type, reader))),
885 else => @compileError("T must be an enum. Instead was given type " ++ @typeName(T)),885 else => @compileError("T must be an enum. Instead was given type " ++ @typeName(T)),
886 }886 }
887}887}
src/link/Wasm/ZigObject.zig+1-1
...@@ -805,7 +805,7 @@ pub fn getUavVAddr(...@@ -805,7 +805,7 @@ pub fn getUavVAddr(
805 const is_wasm32 = target.cpu.arch == .wasm32;805 const is_wasm32 = target.cpu.arch == .wasm32;
806 const zcu = wasm_file.base.comp.zcu.?;806 const zcu = wasm_file.base.comp.zcu.?;
807 const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav));807 const ty = Type.fromInterned(zcu.intern_pool.typeOf(uav));
808 if (ty.zigTypeTag(zcu) == .Fn) {808 if (ty.zigTypeTag(zcu) == .@"fn") {
809 std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations809 std.debug.assert(reloc_info.addend == 0); // addend not allowed for function relocations
810 try parent_atom.relocs.append(gpa, .{810 try parent_atom.relocs.append(gpa, .{
811 .index = target_symbol_index,811 .index = target_symbol_index,
src/link/riscv.zig+1-1
...@@ -12,7 +12,7 @@ pub fn writeSetSub6(comptime op: enum { set, sub }, code: *[1]u8, addend: anytyp...@@ -12,7 +12,7 @@ pub fn writeSetSub6(comptime op: enum { set, sub }, code: *[1]u8, addend: anytyp
12pub fn writeAddend(12pub fn writeAddend(
13 comptime Int: type,13 comptime Int: type,
14 comptime op: enum { add, sub },14 comptime op: enum { add, sub },
15 code: *[@typeInfo(Int).Int.bits / 8]u8,15 code: *[@typeInfo(Int).int.bits / 8]u8,
16 value: anytype,16 value: anytype,
17) void {17) void {
18 var V: Int = mem.readInt(Int, code, .little);18 var V: Int = mem.readInt(Int, code, .little);
src/link/tapi/yaml.zig+28-28
...@@ -204,13 +204,13 @@ pub const Value = union(enum) {...@@ -204,13 +204,13 @@ pub const Value = union(enum) {
204204
205 fn encode(arena: Allocator, input: anytype) YamlError!?Value {205 fn encode(arena: Allocator, input: anytype) YamlError!?Value {
206 switch (@typeInfo(@TypeOf(input))) {206 switch (@typeInfo(@TypeOf(input))) {
207 .ComptimeInt,207 .comptime_int,
208 .Int,208 .int,
209 => return Value{ .int = math.cast(i64, input) orelse return error.Overflow },209 => return Value{ .int = math.cast(i64, input) orelse return error.Overflow },
210210
211 .Float => return Value{ .float = math.lossyCast(f64, input) },211 .float => return Value{ .float = math.lossyCast(f64, input) },
212212
213 .Struct => |info| if (info.is_tuple) {213 .@"struct" => |info| if (info.is_tuple) {
214 var list = std.ArrayList(Value).init(arena);214 var list = std.ArrayList(Value).init(arena);
215 errdefer list.deinit();215 errdefer list.deinit();
216 try list.ensureTotalCapacityPrecise(info.fields.len);216 try list.ensureTotalCapacityPrecise(info.fields.len);
...@@ -237,7 +237,7 @@ pub const Value = union(enum) {...@@ -237,7 +237,7 @@ pub const Value = union(enum) {
237 return Value{ .map = map };237 return Value{ .map = map };
238 },238 },
239239
240 .Union => |info| if (info.tag_type) |tag_type| {240 .@"union" => |info| if (info.tag_type) |tag_type| {
241 inline for (info.fields) |field| {241 inline for (info.fields) |field| {
242 if (@field(tag_type, field.name) == input) {242 if (@field(tag_type, field.name) == input) {
243 return try encode(arena, @field(input, field.name));243 return try encode(arena, @field(input, field.name));
...@@ -245,11 +245,11 @@ pub const Value = union(enum) {...@@ -245,11 +245,11 @@ pub const Value = union(enum) {
245 } else unreachable;245 } else unreachable;
246 } else return error.UntaggedUnion,246 } else return error.UntaggedUnion,
247247
248 .Array => return encode(arena, &input),248 .array => return encode(arena, &input),
249249
250 .Pointer => |info| switch (info.size) {250 .pointer => |info| switch (info.size) {
251 .One => switch (@typeInfo(info.child)) {251 .One => switch (@typeInfo(info.child)) {
252 .Array => |child_info| {252 .array => |child_info| {
253 const Slice = []const child_info.child;253 const Slice = []const child_info.child;
254 return encode(arena, @as(Slice, input));254 return encode(arena, @as(Slice, input));
255 },255 },
...@@ -284,9 +284,9 @@ pub const Value = union(enum) {...@@ -284,9 +284,9 @@ pub const Value = union(enum) {
284284
285 // TODO we should probably have an option to encode `null` and also285 // TODO we should probably have an option to encode `null` and also
286 // allow for some default value too.286 // allow for some default value too.
287 .Optional => return if (input) |val| encode(arena, val) else null,287 .optional => return if (input) |val| encode(arena, val) else null,
288288
289 .Null => return null,289 .null => return null,
290290
291 else => {291 else => {
292 @compileError("Unhandled type: {s}" ++ @typeName(@TypeOf(input)));292 @compileError("Unhandled type: {s}" ++ @typeName(@TypeOf(input)));
...@@ -339,7 +339,7 @@ pub const Yaml = struct {...@@ -339,7 +339,7 @@ pub const Yaml = struct {
339339
340 pub fn parse(self: *Yaml, comptime T: type) Error!T {340 pub fn parse(self: *Yaml, comptime T: type) Error!T {
341 if (self.docs.items.len == 0) {341 if (self.docs.items.len == 0) {
342 if (@typeInfo(T) == .Void) return {};342 if (@typeInfo(T) == .void) return {};
343 return error.TypeMismatch;343 return error.TypeMismatch;
344 }344 }
345345
...@@ -348,14 +348,14 @@ pub const Yaml = struct {...@@ -348,14 +348,14 @@ pub const Yaml = struct {
348 }348 }
349349
350 switch (@typeInfo(T)) {350 switch (@typeInfo(T)) {
351 .Array => |info| {351 .array => |info| {
352 var parsed: T = undefined;352 var parsed: T = undefined;
353 for (self.docs.items, 0..) |doc, i| {353 for (self.docs.items, 0..) |doc, i| {
354 parsed[i] = try self.parseValue(info.child, doc);354 parsed[i] = try self.parseValue(info.child, doc);
355 }355 }
356 return parsed;356 return parsed;
357 },357 },
358 .Pointer => |info| {358 .pointer => |info| {
359 switch (info.size) {359 switch (info.size) {
360 .Slice => {360 .Slice => {
361 var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);361 var parsed = try self.arena.allocator().alloc(info.child, self.docs.items.len);
...@@ -367,35 +367,35 @@ pub const Yaml = struct {...@@ -367,35 +367,35 @@ pub const Yaml = struct {
367 else => return error.TypeMismatch,367 else => return error.TypeMismatch,
368 }368 }
369 },369 },
370 .Union => return error.Unimplemented,370 .@"union" => return error.Unimplemented,
371 else => return error.TypeMismatch,371 else => return error.TypeMismatch,
372 }372 }
373 }373 }
374374
375 fn parseValue(self: *Yaml, comptime T: type, value: Value) Error!T {375 fn parseValue(self: *Yaml, comptime T: type, value: Value) Error!T {
376 return switch (@typeInfo(T)) {376 return switch (@typeInfo(T)) {
377 .Int => math.cast(T, try value.asInt()) orelse return error.Overflow,377 .int => math.cast(T, try value.asInt()) orelse return error.Overflow,
378 .Float => if (value.asFloat()) |float| {378 .float => if (value.asFloat()) |float| {
379 return math.lossyCast(T, float);379 return math.lossyCast(T, float);
380 } else |_| {380 } else |_| {
381 return math.lossyCast(T, try value.asInt());381 return math.lossyCast(T, try value.asInt());
382 },382 },
383 .Struct => self.parseStruct(T, try value.asMap()),383 .@"struct" => self.parseStruct(T, try value.asMap()),
384 .Union => self.parseUnion(T, value),384 .@"union" => self.parseUnion(T, value),
385 .Array => self.parseArray(T, try value.asList()),385 .array => self.parseArray(T, try value.asList()),
386 .Pointer => if (value.asList()) |list| {386 .pointer => if (value.asList()) |list| {
387 return self.parsePointer(T, .{ .list = list });387 return self.parsePointer(T, .{ .list = list });
388 } else |_| {388 } else |_| {
389 return self.parsePointer(T, .{ .string = try value.asString() });389 return self.parsePointer(T, .{ .string = try value.asString() });
390 },390 },
391 .Void => error.TypeMismatch,391 .void => error.TypeMismatch,
392 .Optional => unreachable,392 .optional => unreachable,
393 else => error.Unimplemented,393 else => error.Unimplemented,
394 };394 };
395 }395 }
396396
397 fn parseUnion(self: *Yaml, comptime T: type, value: Value) Error!T {397 fn parseUnion(self: *Yaml, comptime T: type, value: Value) Error!T {
398 const union_info = @typeInfo(T).Union;398 const union_info = @typeInfo(T).@"union";
399399
400 if (union_info.tag_type) |_| {400 if (union_info.tag_type) |_| {
401 inline for (union_info.fields) |field| {401 inline for (union_info.fields) |field| {
...@@ -412,12 +412,12 @@ pub const Yaml = struct {...@@ -412,12 +412,12 @@ pub const Yaml = struct {
412412
413 fn parseOptional(self: *Yaml, comptime T: type, value: ?Value) Error!T {413 fn parseOptional(self: *Yaml, comptime T: type, value: ?Value) Error!T {
414 const unwrapped = value orelse return null;414 const unwrapped = value orelse return null;
415 const opt_info = @typeInfo(T).Optional;415 const opt_info = @typeInfo(T).optional;
416 return @as(T, try self.parseValue(opt_info.child, unwrapped));416 return @as(T, try self.parseValue(opt_info.child, unwrapped));
417 }417 }
418418
419 fn parseStruct(self: *Yaml, comptime T: type, map: Map) Error!T {419 fn parseStruct(self: *Yaml, comptime T: type, map: Map) Error!T {
420 const struct_info = @typeInfo(T).Struct;420 const struct_info = @typeInfo(T).@"struct";
421 var parsed: T = undefined;421 var parsed: T = undefined;
422422
423 inline for (struct_info.fields) |field| {423 inline for (struct_info.fields) |field| {
...@@ -426,7 +426,7 @@ pub const Yaml = struct {...@@ -426,7 +426,7 @@ pub const Yaml = struct {
426 break :blk map.get(field_name);426 break :blk map.get(field_name);
427 };427 };
428428
429 if (@typeInfo(field.type) == .Optional) {429 if (@typeInfo(field.type) == .optional) {
430 @field(parsed, field.name) = try self.parseOptional(field.type, value);430 @field(parsed, field.name) = try self.parseOptional(field.type, value);
431 continue;431 continue;
432 }432 }
...@@ -442,7 +442,7 @@ pub const Yaml = struct {...@@ -442,7 +442,7 @@ pub const Yaml = struct {
442 }442 }
443443
444 fn parsePointer(self: *Yaml, comptime T: type, value: Value) Error!T {444 fn parsePointer(self: *Yaml, comptime T: type, value: Value) Error!T {
445 const ptr_info = @typeInfo(T).Pointer;445 const ptr_info = @typeInfo(T).pointer;
446 const arena = self.arena.allocator();446 const arena = self.arena.allocator();
447447
448 switch (ptr_info.size) {448 switch (ptr_info.size) {
...@@ -462,7 +462,7 @@ pub const Yaml = struct {...@@ -462,7 +462,7 @@ pub const Yaml = struct {
462 }462 }
463463
464 fn parseArray(self: *Yaml, comptime T: type, list: List) Error!T {464 fn parseArray(self: *Yaml, comptime T: type, list: List) Error!T {
465 const array_info = @typeInfo(T).Array;465 const array_info = @typeInfo(T).array;
466 if (array_info.len != list.len) return error.ArraySizeMismatch;466 if (array_info.len != list.len) return error.ArraySizeMismatch;
467467
468 var parsed: T = undefined;468 var parsed: T = undefined;
src/main.zig+2-2
...@@ -130,7 +130,7 @@ var log_scopes: std.ArrayListUnmanaged([]const u8) = .{};...@@ -130,7 +130,7 @@ var log_scopes: std.ArrayListUnmanaged([]const u8) = .{};
130130
131pub fn log(131pub fn log(
132 comptime level: std.log.Level,132 comptime level: std.log.Level,
133 comptime scope: @TypeOf(.EnumLiteral),133 comptime scope: @Type(.enum_literal),
134 comptime format: []const u8,134 comptime format: []const u8,
135 args: anytype,135 args: anytype,
136) void {136) void {
...@@ -5315,7 +5315,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -5315,7 +5315,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
5315 var any_errors = false;5315 var any_errors = false;
5316 while (it.next()) |hash| {5316 while (it.next()) |hash| {
5317 if (hash.len == 0) continue;5317 if (hash.len == 0) continue;
5318 const digest_len = @typeInfo(Package.Manifest.MultiHashHexDigest).Array.len;5318 const digest_len = @typeInfo(Package.Manifest.MultiHashHexDigest).array.len;
5319 if (hash.len != digest_len) {5319 if (hash.len != digest_len) {
5320 std.log.err("invalid digest (length {d} instead of {d}): '{s}'", .{5320 std.log.err("invalid digest (length {d} instead of {d}): '{s}'", .{
5321 hash.len, digest_len, hash,5321 hash.len, digest_len, hash,
src/mutable_value.zig+12-12
...@@ -210,19 +210,19 @@ pub const MutableValue = union(enum) {...@@ -210,19 +210,19 @@ pub const MutableValue = union(enum) {
210 },210 },
211 },211 },
212 .undef => |ty_ip| switch (Type.fromInterned(ty_ip).zigTypeTag(zcu)) {212 .undef => |ty_ip| switch (Type.fromInterned(ty_ip).zigTypeTag(zcu)) {
213 .Struct, .Array, .Vector => |type_tag| {213 .@"struct", .array, .vector => |type_tag| {
214 const ty = Type.fromInterned(ty_ip);214 const ty = Type.fromInterned(ty_ip);
215 const opt_sent = ty.sentinel(zcu);215 const opt_sent = ty.sentinel(zcu);
216 if (type_tag == .Struct or opt_sent != null or !allow_repeated) {216 if (type_tag == .@"struct" or opt_sent != null or !allow_repeated) {
217 const len_no_sent = ip.aggregateTypeLen(ty_ip);217 const len_no_sent = ip.aggregateTypeLen(ty_ip);
218 const elems = try arena.alloc(MutableValue, @intCast(len_no_sent + @intFromBool(opt_sent != null)));218 const elems = try arena.alloc(MutableValue, @intCast(len_no_sent + @intFromBool(opt_sent != null)));
219 switch (type_tag) {219 switch (type_tag) {
220 .Array, .Vector => {220 .array, .vector => {
221 const elem_ty = ip.childType(ty_ip);221 const elem_ty = ip.childType(ty_ip);
222 const undef_elem = try pt.intern(.{ .undef = elem_ty });222 const undef_elem = try pt.intern(.{ .undef = elem_ty });
223 @memset(elems[0..@intCast(len_no_sent)], .{ .interned = undef_elem });223 @memset(elems[0..@intCast(len_no_sent)], .{ .interned = undef_elem });
224 },224 },
225 .Struct => for (elems[0..@intCast(len_no_sent)], 0..) |*mut_elem, i| {225 .@"struct" => for (elems[0..@intCast(len_no_sent)], 0..) |*mut_elem, i| {
226 const field_ty = ty.fieldType(i, zcu).toIntern();226 const field_ty = ty.fieldType(i, zcu).toIntern();
227 mut_elem.* = .{ .interned = try pt.intern(.{ .undef = field_ty }) };227 mut_elem.* = .{ .interned = try pt.intern(.{ .undef = field_ty }) };
228 },228 },
...@@ -244,7 +244,7 @@ pub const MutableValue = union(enum) {...@@ -244,7 +244,7 @@ pub const MutableValue = union(enum) {
244 } };244 } };
245 }245 }
246 },246 },
247 .Union => {247 .@"union" => {
248 const payload = try arena.create(MutableValue);248 const payload = try arena.create(MutableValue);
249 const backing_ty = try Type.fromInterned(ty_ip).unionBackingType(pt);249 const backing_ty = try Type.fromInterned(ty_ip).unionBackingType(pt);
250 payload.* = .{ .interned = try pt.intern(.{ .undef = backing_ty.toIntern() }) };250 payload.* = .{ .interned = try pt.intern(.{ .undef = backing_ty.toIntern() }) };
...@@ -254,7 +254,7 @@ pub const MutableValue = union(enum) {...@@ -254,7 +254,7 @@ pub const MutableValue = union(enum) {
254 .payload = payload,254 .payload = payload,
255 } };255 } };
256 },256 },
257 .Pointer => {257 .pointer => {
258 const ptr_ty = ip.indexToKey(ty_ip).ptr_type;258 const ptr_ty = ip.indexToKey(ty_ip).ptr_type;
259 if (ptr_ty.flags.size != .Slice) return;259 if (ptr_ty.flags.size != .Slice) return;
260 const ptr = try arena.create(MutableValue);260 const ptr = try arena.create(MutableValue);
...@@ -375,7 +375,7 @@ pub const MutableValue = union(enum) {...@@ -375,7 +375,7 @@ pub const MutableValue = union(enum) {
375 if (field_val.eqlTrivial(r.child.*)) return;375 if (field_val.eqlTrivial(r.child.*)) return;
376 // We must switch to either the `aggregate` or the `bytes` representation.376 // We must switch to either the `aggregate` or the `bytes` representation.
377 const len_inc_sent = ip.aggregateTypeLenIncludingSentinel(r.ty);377 const len_inc_sent = ip.aggregateTypeLenIncludingSentinel(r.ty);
378 if (Type.fromInterned(r.ty).zigTypeTag(zcu) != .Struct and378 if (Type.fromInterned(r.ty).zigTypeTag(zcu) != .@"struct" and
379 is_trivial_int and379 is_trivial_int and
380 Type.fromInterned(r.ty).childType(zcu).toIntern() == .u8_type and380 Type.fromInterned(r.ty).childType(zcu).toIntern() == .u8_type and
381 r.child.isTrivialInt(zcu))381 r.child.isTrivialInt(zcu))
...@@ -402,7 +402,7 @@ pub const MutableValue = union(enum) {...@@ -402,7 +402,7 @@ pub const MutableValue = union(enum) {
402 },402 },
403 .aggregate => |a| {403 .aggregate => |a| {
404 a.elems[field_idx] = field_val;404 a.elems[field_idx] = field_val;
405 const is_struct = Type.fromInterned(a.ty).zigTypeTag(zcu) == .Struct;405 const is_struct = Type.fromInterned(a.ty).zigTypeTag(zcu) == .@"struct";
406 // Attempt to switch to a more efficient representation.406 // Attempt to switch to a more efficient representation.
407 const is_repeated = for (a.elems) |e| {407 const is_repeated = for (a.elems) |e| {
408 if (!e.eqlTrivial(field_val)) break false;408 if (!e.eqlTrivial(field_val)) break false;
...@@ -457,9 +457,9 @@ pub const MutableValue = union(enum) {...@@ -457,9 +457,9 @@ pub const MutableValue = union(enum) {
457 .interned => |ip_index| {457 .interned => |ip_index| {
458 const ty = Type.fromInterned(pt.zcu.intern_pool.typeOf(ip_index));458 const ty = Type.fromInterned(pt.zcu.intern_pool.typeOf(ip_index));
459 switch (ty.zigTypeTag(pt.zcu)) {459 switch (ty.zigTypeTag(pt.zcu)) {
460 .Array, .Vector => return .{ .interned = (try Value.fromInterned(ip_index).elemValue(pt, field_idx)).toIntern() },460 .array, .vector => return .{ .interned = (try Value.fromInterned(ip_index).elemValue(pt, field_idx)).toIntern() },
461 .Struct, .Union => return .{ .interned = (try Value.fromInterned(ip_index).fieldValue(pt, field_idx)).toIntern() },461 .@"struct", .@"union" => return .{ .interned = (try Value.fromInterned(ip_index).fieldValue(pt, field_idx)).toIntern() },
462 .Pointer => {462 .pointer => {
463 assert(ty.isSlice(pt.zcu));463 assert(ty.isSlice(pt.zcu));
464 return switch (field_idx) {464 return switch (field_idx) {
465 Value.slice_ptr_index => .{ .interned = Value.fromInterned(ip_index).slicePtr(pt.zcu).toIntern() },465 Value.slice_ptr_index => .{ .interned = Value.fromInterned(ip_index).slicePtr(pt.zcu).toIntern() },
...@@ -551,7 +551,7 @@ pub const MutableValue = union(enum) {...@@ -551,7 +551,7 @@ pub const MutableValue = union(enum) {
551 /// Used for deciding when to switch aggregate representations without fully551 /// Used for deciding when to switch aggregate representations without fully
552 /// interning many values.552 /// interning many values.
553 fn eqlTrivial(a: MutableValue, b: MutableValue) bool {553 fn eqlTrivial(a: MutableValue, b: MutableValue) bool {
554 const Tag = @typeInfo(MutableValue).Union.tag_type.?;554 const Tag = @typeInfo(MutableValue).@"union".tag_type.?;
555 if (@as(Tag, a) != @as(Tag, b)) return false;555 if (@as(Tag, a) != @as(Tag, b)) return false;
556 return switch (a) {556 return switch (a) {
557 .interned => |a_ip| a_ip == b.interned,557 .interned => |a_ip| a_ip == b.interned,
src/print_env.zig+1-1
...@@ -47,7 +47,7 @@ pub fn cmdEnv(arena: Allocator, args: []const []const u8, stdout: std.fs.File.Wr...@@ -47,7 +47,7 @@ pub fn cmdEnv(arena: Allocator, args: []const []const u8, stdout: std.fs.File.Wr
4747
48 try jws.objectField("env");48 try jws.objectField("env");
49 try jws.beginObject();49 try jws.beginObject();
50 inline for (@typeInfo(std.zig.EnvVar).Enum.fields) |field| {50 inline for (@typeInfo(std.zig.EnvVar).@"enum".fields) |field| {
51 try jws.objectField(field.name);51 try jws.objectField(field.name);
52 try jws.write(try @field(std.zig.EnvVar, field.name).get(arena));52 try jws.write(try @field(std.zig.EnvVar, field.name).get(arena));
53 }53 }
src/print_value.zig+6-6
...@@ -207,7 +207,7 @@ fn printAggregate(...@@ -207,7 +207,7 @@ fn printAggregate(
207 const ip = &zcu.intern_pool;207 const ip = &zcu.intern_pool;
208 const ty = Type.fromInterned(aggregate.ty);208 const ty = Type.fromInterned(aggregate.ty);
209 switch (ty.zigTypeTag(zcu)) {209 switch (ty.zigTypeTag(zcu)) {
210 .Struct => if (!ty.isTuple(zcu)) {210 .@"struct" => if (!ty.isTuple(zcu)) {
211 if (is_ref) try writer.writeByte('&');211 if (is_ref) try writer.writeByte('&');
212 if (ty.structFieldCount(zcu) == 0) {212 if (ty.structFieldCount(zcu) == 0) {
213 return writer.writeAll(".{}");213 return writer.writeAll(".{}");
...@@ -223,7 +223,7 @@ fn printAggregate(...@@ -223,7 +223,7 @@ fn printAggregate(
223 try writer.writeAll(" }");223 try writer.writeAll(" }");
224 return;224 return;
225 },225 },
226 .Array => {226 .array => {
227 switch (aggregate.storage) {227 switch (aggregate.storage) {
228 .bytes => |bytes| string: {228 .bytes => |bytes| string: {
229 const len = ty.arrayLenIncludingSentinel(zcu);229 const len = ty.arrayLenIncludingSentinel(zcu);
...@@ -253,7 +253,7 @@ fn printAggregate(...@@ -253,7 +253,7 @@ fn printAggregate(
253 else => {},253 else => {},
254 }254 }
255 },255 },
256 .Vector => if (ty.arrayLen(zcu) == 0) {256 .vector => if (ty.arrayLen(zcu) == 0) {
257 if (is_ref) try writer.writeByte('&');257 if (is_ref) try writer.writeByte('&');
258 return writer.writeAll(".{}");258 return writer.writeAll(".{}");
259 },259 },
...@@ -362,17 +362,17 @@ fn printPtrDerivation(...@@ -362,17 +362,17 @@ fn printPtrDerivation(
362 try printPtrDerivation(field.parent.*, writer, level, pt, have_sema, sema);362 try printPtrDerivation(field.parent.*, writer, level, pt, have_sema, sema);
363 const agg_ty = (try field.parent.ptrType(pt)).childType(zcu);363 const agg_ty = (try field.parent.ptrType(pt)).childType(zcu);
364 switch (agg_ty.zigTypeTag(zcu)) {364 switch (agg_ty.zigTypeTag(zcu)) {
365 .Struct => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| {365 .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| {
366 try writer.print(".{i}", .{field_name.fmt(ip)});366 try writer.print(".{i}", .{field_name.fmt(ip)});
367 } else {367 } else {
368 try writer.print("[{d}]", .{field.field_idx});368 try writer.print("[{d}]", .{field.field_idx});
369 },369 },
370 .Union => {370 .@"union" => {
371 const tag_ty = agg_ty.unionTagTypeHypothetical(zcu);371 const tag_ty = agg_ty.unionTagTypeHypothetical(zcu);
372 const field_name = tag_ty.enumFieldName(field.field_idx, zcu);372 const field_name = tag_ty.enumFieldName(field.field_idx, zcu);
373 try writer.print(".{i}", .{field_name.fmt(ip)});373 try writer.print(".{i}", .{field_name.fmt(ip)});
374 },374 },
375 .Pointer => switch (field.field_idx) {375 .pointer => switch (field.field_idx) {
376 Value.slice_ptr_index => try writer.writeAll(".ptr"),376 Value.slice_ptr_index => try writer.writeAll(".ptr"),
377 Value.slice_len_index => try writer.writeAll(".len"),377 Value.slice_len_index => try writer.writeAll(".len"),
378 else => unreachable,378 else => unreachable,
src/print_zir.zig+3-3
...@@ -907,7 +907,7 @@ const Writer = struct {...@@ -907,7 +907,7 @@ const Writer = struct {
907907
908 fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {908 fn writeFieldParentPtr(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
909 const extra = self.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data;909 const extra = self.code.extraData(Zir.Inst.FieldParentPtr, extended.operand).data;
910 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;910 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
911 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));911 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
912 if (flags.align_cast) try stream.writeAll("align_cast, ");912 if (flags.align_cast) try stream.writeAll("align_cast, ");
913 if (flags.addrspace_cast) try stream.writeAll("addrspace_cast, ");913 if (flags.addrspace_cast) try stream.writeAll("addrspace_cast, ");
...@@ -1065,7 +1065,7 @@ const Writer = struct {...@@ -1065,7 +1065,7 @@ const Writer = struct {
1065 }1065 }
10661066
1067 fn writePtrCastFull(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {1067 fn writePtrCastFull(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
1068 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;1068 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
1069 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));1069 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
1070 const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data;1070 const extra = self.code.extraData(Zir.Inst.BinNode, extended.operand).data;
1071 if (flags.ptr_cast) try stream.writeAll("ptr_cast, ");1071 if (flags.ptr_cast) try stream.writeAll("ptr_cast, ");
...@@ -1081,7 +1081,7 @@ const Writer = struct {...@@ -1081,7 +1081,7 @@ const Writer = struct {
1081 }1081 }
10821082
1083 fn writePtrCastNoDest(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {1083 fn writePtrCastNoDest(self: *Writer, stream: anytype, extended: Zir.Inst.Extended.InstData) !void {
1084 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).Struct.backing_integer.?;1084 const FlagsInt = @typeInfo(Zir.Inst.FullPtrCastFlags).@"struct".backing_integer.?;
1085 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));1085 const flags: Zir.Inst.FullPtrCastFlags = @bitCast(@as(FlagsInt, @truncate(extended.small)));
1086 const extra = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;1086 const extra = self.code.extraData(Zir.Inst.UnNode, extended.operand).data;
1087 if (flags.const_cast) try stream.writeAll("const_cast, ");1087 if (flags.const_cast) try stream.writeAll("const_cast, ");
src/translate_c.zig+4-4
...@@ -161,7 +161,7 @@ pub fn translate(...@@ -161,7 +161,7 @@ pub fn translate(
161 context.pattern_list.deinit(gpa);161 context.pattern_list.deinit(gpa);
162 }162 }
163163
164 inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| {164 inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| {
165 const builtin = try Tag.pub_var_simple.create(arena, .{165 const builtin = try Tag.pub_var_simple.create(arena, .{
166 .name = decl.name,166 .name = decl.name,
167 .init = try Tag.import_c_builtin.create(arena, decl.name),167 .init = try Tag.import_c_builtin.create(arena, decl.name),
...@@ -1324,7 +1324,7 @@ fn makeShuffleMask(c: *Context, scope: *Scope, expr: *const clang.ShuffleVectorE...@@ -1324,7 +1324,7 @@ fn makeShuffleMask(c: *Context, scope: *Scope, expr: *const clang.ShuffleVectorE
1324fn vectorTypeInfo(arena: mem.Allocator, vec_node: Node, field: []const u8) TransError!Node {1324fn vectorTypeInfo(arena: mem.Allocator, vec_node: Node, field: []const u8) TransError!Node {
1325 const typeof_call = try Tag.typeof.create(arena, vec_node);1325 const typeof_call = try Tag.typeof.create(arena, vec_node);
1326 const typeinfo_call = try Tag.typeinfo.create(arena, typeof_call);1326 const typeinfo_call = try Tag.typeinfo.create(arena, typeof_call);
1327 const vector_type_info = try Tag.field_access.create(arena, .{ .lhs = typeinfo_call, .field_name = "Vector" });1327 const vector_type_info = try Tag.field_access.create(arena, .{ .lhs = typeinfo_call, .field_name = "vector" });
1328 return Tag.field_access.create(arena, .{ .lhs = vector_type_info, .field_name = field });1328 return Tag.field_access.create(arena, .{ .lhs = vector_type_info, .field_name = field });
1329}1329}
13301330
...@@ -2008,7 +2008,7 @@ fn transImplicitCastExpr(...@@ -2008,7 +2008,7 @@ fn transImplicitCastExpr(
2008}2008}
20092009
2010fn isBuiltinDefined(name: []const u8) bool {2010fn isBuiltinDefined(name: []const u8) bool {
2011 inline for (@typeInfo(std.zig.c_builtins).Struct.decls) |decl| {2011 inline for (@typeInfo(std.zig.c_builtins).@"struct".decls) |decl| {
2012 if (std.mem.eql(u8, name, decl.name)) return true;2012 if (std.mem.eql(u8, name, decl.name)) return true;
2013 }2013 }
2014 return false;2014 return false;
...@@ -4655,7 +4655,7 @@ fn transCreateNodeAPInt(c: *Context, int: *const clang.APSInt) !Node {...@@ -4655,7 +4655,7 @@ fn transCreateNodeAPInt(c: *Context, int: *const clang.APSInt) !Node {
46554655
4656fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float }) !Node {4656fn transCreateNodeNumber(c: *Context, num: anytype, num_kind: enum { int, float }) !Node {
4657 const fmt_s = switch (@typeInfo(@TypeOf(num))) {4657 const fmt_s = switch (@typeInfo(@TypeOf(num))) {
4658 .Int, .ComptimeInt => "{d}",4658 .int, .comptime_int => "{d}",
4659 else => "{s}",4659 else => "{s}",
4660 };4660 };
4661 const str = try std.fmt.allocPrint(c.arena, fmt_s, .{num});4661 const str = try std.fmt.allocPrint(c.arena, fmt_s, .{num});
test/behavior/abs.zig+1-1
...@@ -104,7 +104,7 @@ test "@abs big int <= 128 bits" {...@@ -104,7 +104,7 @@ test "@abs big int <= 128 bits" {
104 try testAbsUnsignedBigInt();104 try testAbsUnsignedBigInt();
105}105}
106106
107fn abs(comptime T: type, a: T) std.meta.Int(.unsigned, @typeInfo(T).Int.bits) {107fn abs(comptime T: type, a: T) std.meta.Int(.unsigned, @typeInfo(T).int.bits) {
108 return @abs(a);108 return @abs(a);
109}109}
110110
test/behavior/align.zig+1-1
...@@ -7,7 +7,7 @@ const assert = std.debug.assert;...@@ -7,7 +7,7 @@ const assert = std.debug.assert;
7var foo: u8 align(4) = 100;7var foo: u8 align(4) = 100;
88
9test "global variable alignment" {9test "global variable alignment" {
10 comptime assert(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);10 comptime assert(@typeInfo(@TypeOf(&foo)).pointer.alignment == 4);
11 comptime assert(@TypeOf(&foo) == *align(4) u8);11 comptime assert(@TypeOf(&foo) == *align(4) u8);
12 {12 {
13 const slice = @as(*align(4) [1]u8, &foo)[0..];13 const slice = @as(*align(4) [1]u8, &foo)[0..];
test/behavior/async_fn.zig+3-3
...@@ -391,7 +391,7 @@ test "async fn with inferred error set" {...@@ -391,7 +391,7 @@ test "async fn with inferred error set" {
391 var frame: [1]@Frame(middle) = undefined;391 var frame: [1]@Frame(middle) = undefined;
392 var fn_ptr = middle;392 var fn_ptr = middle;
393 _ = &fn_ptr;393 _ = &fn_ptr;
394 var result: @typeInfo(@typeInfo(@TypeOf(fn_ptr)).Fn.return_type.?).ErrorUnion.error_set!void = undefined;394 var result: @typeInfo(@typeInfo(@TypeOf(fn_ptr)).@"fn".return_type.?).error_union.error_set!void = undefined;
395 _ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, fn_ptr, .{});395 _ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, fn_ptr, .{});
396 resume global_frame;396 resume global_frame;
397 try std.testing.expectError(error.Fail, result);397 try std.testing.expectError(error.Fail, result);
...@@ -1088,7 +1088,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {...@@ -1088,7 +1088,7 @@ test "@asyncCall with comptime-known function, but not awaited directly" {
10881088
1089 fn doTheTest() !void {1089 fn doTheTest() !void {
1090 var frame: [1]@Frame(middle) = undefined;1090 var frame: [1]@Frame(middle) = undefined;
1091 var result: @typeInfo(@typeInfo(@TypeOf(middle)).Fn.return_type.?).ErrorUnion.error_set!void = undefined;1091 var result: @typeInfo(@typeInfo(@TypeOf(middle)).@"fn".return_type.?).error_union.error_set!void = undefined;
1092 _ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, middle, .{});1092 _ = @asyncCall(std.mem.sliceAsBytes(frame[0..]), &result, middle, .{});
1093 resume global_frame;1093 resume global_frame;
1094 try std.testing.expectError(error.Fail, result);1094 try std.testing.expectError(error.Fail, result);
...@@ -1166,7 +1166,7 @@ test "@TypeOf an async function call of generic fn with error union type" {...@@ -1166,7 +1166,7 @@ test "@TypeOf an async function call of generic fn with error union type" {
1166 const S = struct {1166 const S = struct {
1167 fn func(comptime x: anytype) anyerror!i32 {1167 fn func(comptime x: anytype) anyerror!i32 {
1168 const T = @TypeOf(async func(x));1168 const T = @TypeOf(async func(x));
1169 comptime assert(T == @typeInfo(@TypeOf(@frame())).Pointer.child);1169 comptime assert(T == @typeInfo(@TypeOf(@frame())).pointer.child);
1170 return undefined;1170 return undefined;
1171 }1171 }
1172 };1172 };
test/behavior/atomics.zig+1-1
...@@ -414,7 +414,7 @@ fn testAtomicsWithType(comptime T: type, a: T, b: T) !void {...@@ -414,7 +414,7 @@ fn testAtomicsWithType(comptime T: type, a: T, b: T) !void {
414}414}
415415
416fn testAtomicsWithPackedStruct(comptime T: type, a: T, b: T) !void {416fn testAtomicsWithPackedStruct(comptime T: type, a: T, b: T) !void {
417 const BackingInt = @typeInfo(T).Struct.backing_integer.?;417 const BackingInt = @typeInfo(T).@"struct".backing_integer.?;
418 var x: T = b;418 var x: T = b;
419 @atomicStore(T, &x, a, .seq_cst);419 @atomicStore(T, &x, a, .seq_cst);
420 try expect(@as(BackingInt, @bitCast(x)) == @as(BackingInt, @bitCast(a)));420 try expect(@as(BackingInt, @bitCast(x)) == @as(BackingInt, @bitCast(a)));
test/behavior/basic.zig+5-5
...@@ -1193,7 +1193,7 @@ test "pointer to struct literal with runtime field is constant" {...@@ -1193,7 +1193,7 @@ test "pointer to struct literal with runtime field is constant" {
1193 var runtime_zero: usize = 0;1193 var runtime_zero: usize = 0;
1194 _ = &runtime_zero;1194 _ = &runtime_zero;
1195 const ptr = &S{ .data = runtime_zero };1195 const ptr = &S{ .data = runtime_zero };
1196 try expect(@typeInfo(@TypeOf(ptr)).Pointer.is_const);1196 try expect(@typeInfo(@TypeOf(ptr)).pointer.is_const);
1197}1197}
11981198
1199fn testSignedCmp(comptime T: type) !void {1199fn testSignedCmp(comptime T: type) !void {
...@@ -1289,7 +1289,7 @@ test "reference to inferred local variable works as expected" {...@@ -1289,7 +1289,7 @@ test "reference to inferred local variable works as expected" {
12891289
1290test "@Type returned from block" {1290test "@Type returned from block" {
1291 const T = comptime b: {1291 const T = comptime b: {
1292 break :b @Type(.{ .Int = .{1292 break :b @Type(.{ .int = .{
1293 .signedness = .unsigned,1293 .signedness = .unsigned,
1294 .bits = 8,1294 .bits = 8,
1295 } });1295 } });
...@@ -1304,7 +1304,7 @@ test "comptime variable initialized with addresses of literals" {...@@ -1304,7 +1304,7 @@ test "comptime variable initialized with addresses of literals" {
1304 };1304 };
1305 _ = &st;1305 _ = &st;
13061306
1307 inline for (@typeInfo(@TypeOf(st)).Struct.fields) |field| {1307 inline for (@typeInfo(@TypeOf(st)).@"struct".fields) |field| {
1308 _ = field;1308 _ = field;
1309 }1309 }
1310}1310}
...@@ -1321,12 +1321,12 @@ test "proper value is returned from labeled block" {...@@ -1321,12 +1321,12 @@ test "proper value is returned from labeled block" {
1321 const S = struct {1321 const S = struct {
1322 fn hash(v: *u32, key: anytype) void {1322 fn hash(v: *u32, key: anytype) void {
1323 const Key = @TypeOf(key);1323 const Key = @TypeOf(key);
1324 if (@typeInfo(Key) == .ErrorSet) {1324 if (@typeInfo(Key) == .error_set) {
1325 v.* += 1;1325 v.* += 1;
1326 return;1326 return;
1327 }1327 }
1328 switch (@typeInfo(Key)) {1328 switch (@typeInfo(Key)) {
1329 .ErrorUnion => blk: {1329 .error_union => blk: {
1330 const payload = key catch |err| {1330 const payload = key catch |err| {
1331 hash(v, err);1331 hash(v, err);
1332 break :blk;1332 break :blk;
test/behavior/bit_shifting.zig+3-3
...@@ -3,7 +3,7 @@ const expect = std.testing.expect;...@@ -3,7 +3,7 @@ const expect = std.testing.expect;
3const builtin = @import("builtin");3const builtin = @import("builtin");
44
5fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {5fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {
6 const key_bits = @typeInfo(Key).Int.bits;6 const key_bits = @typeInfo(Key).int.bits;
7 std.debug.assert(Key == std.meta.Int(.unsigned, key_bits));7 std.debug.assert(Key == std.meta.Int(.unsigned, key_bits));
8 std.debug.assert(key_bits >= mask_bit_count);8 std.debug.assert(key_bits >= mask_bit_count);
9 const shard_key_bits = mask_bit_count;9 const shard_key_bits = mask_bit_count;
...@@ -120,11 +120,11 @@ test "Saturating Shift Left where lhs is of a computed type" {...@@ -120,11 +120,11 @@ test "Saturating Shift Left where lhs is of a computed type" {
120120
121 const S = struct {121 const S = struct {
122 fn getIntShiftType(comptime T: type) type {122 fn getIntShiftType(comptime T: type) type {
123 var unsigned_shift_type = @typeInfo(std.math.Log2Int(T)).Int;123 var unsigned_shift_type = @typeInfo(std.math.Log2Int(T)).int;
124 unsigned_shift_type.signedness = .signed;124 unsigned_shift_type.signedness = .signed;
125125
126 return @Type(.{126 return @Type(.{
127 .Int = unsigned_shift_type,127 .int = unsigned_shift_type,
128 });128 });
129 }129 }
130130
test/behavior/bitcast.zig+2-2
...@@ -361,7 +361,7 @@ test "comptime @bitCast packed struct to int and back" {...@@ -361,7 +361,7 @@ test "comptime @bitCast packed struct to int and back" {
361 vectori: @Vector(2, u8) = .{ 127, 42 },361 vectori: @Vector(2, u8) = .{ 127, 42 },
362 vectorf: @Vector(2, f16) = .{ 3.14, 2.71 },362 vectorf: @Vector(2, f16) = .{ 3.14, 2.71 },
363 };363 };
364 const Int = @typeInfo(S).Struct.backing_integer.?;364 const Int = @typeInfo(S).@"struct".backing_integer.?;
365365
366 // S -> Int366 // S -> Int
367 var s: S = .{};367 var s: S = .{};
...@@ -373,7 +373,7 @@ test "comptime @bitCast packed struct to int and back" {...@@ -373,7 +373,7 @@ test "comptime @bitCast packed struct to int and back" {
373 _ = &i;373 _ = &i;
374 const rt_cast = @as(S, @bitCast(i));374 const rt_cast = @as(S, @bitCast(i));
375 const ct_cast = comptime @as(S, @bitCast(@as(Int, 0)));375 const ct_cast = comptime @as(S, @bitCast(@as(Int, 0)));
376 inline for (@typeInfo(S).Struct.fields) |field| {376 inline for (@typeInfo(S).@"struct".fields) |field| {
377 try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name));377 try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name));
378 }378 }
379}379}
test/behavior/call.zig+3-3
...@@ -374,7 +374,7 @@ test "Enum constructed by @Type passed as generic argument" {...@@ -374,7 +374,7 @@ test "Enum constructed by @Type passed as generic argument" {
374 try expect(@intFromEnum(a) == b);374 try expect(@intFromEnum(a) == b);
375 }375 }
376 };376 };
377 inline for (@typeInfo(S.E).Enum.fields, 0..) |_, i| {377 inline for (@typeInfo(S.E).@"enum".fields, 0..) |_, i| {
378 try S.foo(@as(S.E, @enumFromInt(i)), i);378 try S.foo(@as(S.E, @enumFromInt(i)), i);
379 }379 }
380}380}
...@@ -578,11 +578,11 @@ test "generic function pointer can be called" {...@@ -578,11 +578,11 @@ test "generic function pointer can be called" {
578test "value returned from comptime function is comptime known" {578test "value returned from comptime function is comptime known" {
579 const S = struct {579 const S = struct {
580 fn fields(comptime T: type) switch (@typeInfo(T)) {580 fn fields(comptime T: type) switch (@typeInfo(T)) {
581 .Struct => []const std.builtin.Type.StructField,581 .@"struct" => []const std.builtin.Type.StructField,
582 else => unreachable,582 else => unreachable,
583 } {583 } {
584 return switch (@typeInfo(T)) {584 return switch (@typeInfo(T)) {
585 .Struct => |info| info.fields,585 .@"struct" => |info| info.fields,
586 else => unreachable,586 else => unreachable,
587 };587 };
588 }588 }
test/behavior/cast.zig+44-44
...@@ -704,20 +704,20 @@ test "peer type resolution: error set supersets" {...@@ -704,20 +704,20 @@ test "peer type resolution: error set supersets" {
704 {704 {
705 const ty = @TypeOf(a, b);705 const ty = @TypeOf(a, b);
706 const error_set_info = @typeInfo(ty);706 const error_set_info = @typeInfo(ty);
707 try expect(error_set_info == .ErrorSet);707 try expect(error_set_info == .error_set);
708 try expect(error_set_info.ErrorSet.?.len == 2);708 try expect(error_set_info.error_set.?.len == 2);
709 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));709 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
710 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));710 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
711 }711 }
712712
713 // B superset of A713 // B superset of A
714 {714 {
715 const ty = @TypeOf(b, a);715 const ty = @TypeOf(b, a);
716 const error_set_info = @typeInfo(ty);716 const error_set_info = @typeInfo(ty);
717 try expect(error_set_info == .ErrorSet);717 try expect(error_set_info == .error_set);
718 try expect(error_set_info.ErrorSet.?.len == 2);718 try expect(error_set_info.error_set.?.len == 2);
719 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));719 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
720 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));720 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
721 }721 }
722}722}
723723
...@@ -732,21 +732,21 @@ test "peer type resolution: disjoint error sets" {...@@ -732,21 +732,21 @@ test "peer type resolution: disjoint error sets" {
732 {732 {
733 const ty = @TypeOf(a, b);733 const ty = @TypeOf(a, b);
734 const error_set_info = @typeInfo(ty);734 const error_set_info = @typeInfo(ty);
735 try expect(error_set_info == .ErrorSet);735 try expect(error_set_info == .error_set);
736 try expect(error_set_info.ErrorSet.?.len == 3);736 try expect(error_set_info.error_set.?.len == 3);
737 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));737 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
738 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));738 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
739 try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three"));739 try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three"));
740 }740 }
741741
742 {742 {
743 const ty = @TypeOf(b, a);743 const ty = @TypeOf(b, a);
744 const error_set_info = @typeInfo(ty);744 const error_set_info = @typeInfo(ty);
745 try expect(error_set_info == .ErrorSet);745 try expect(error_set_info == .error_set);
746 try expect(error_set_info.ErrorSet.?.len == 3);746 try expect(error_set_info.error_set.?.len == 3);
747 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));747 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
748 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));748 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
749 try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three"));749 try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three"));
750 }750 }
751}751}
752752
...@@ -762,25 +762,25 @@ test "peer type resolution: error union and error set" {...@@ -762,25 +762,25 @@ test "peer type resolution: error union and error set" {
762 {762 {
763 const ty = @TypeOf(a, b);763 const ty = @TypeOf(a, b);
764 const info = @typeInfo(ty);764 const info = @typeInfo(ty);
765 try expect(info == .ErrorUnion);765 try expect(info == .error_union);
766766
767 const error_set_info = @typeInfo(info.ErrorUnion.error_set);767 const error_set_info = @typeInfo(info.error_union.error_set);
768 try expect(error_set_info.ErrorSet.?.len == 3);768 try expect(error_set_info.error_set.?.len == 3);
769 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));769 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
770 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));770 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
771 try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three"));771 try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three"));
772 }772 }
773773
774 {774 {
775 const ty = @TypeOf(b, a);775 const ty = @TypeOf(b, a);
776 const info = @typeInfo(ty);776 const info = @typeInfo(ty);
777 try expect(info == .ErrorUnion);777 try expect(info == .error_union);
778778
779 const error_set_info = @typeInfo(info.ErrorUnion.error_set);779 const error_set_info = @typeInfo(info.error_union.error_set);
780 try expect(error_set_info.ErrorSet.?.len == 3);780 try expect(error_set_info.error_set.?.len == 3);
781 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));781 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
782 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));782 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
783 try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three"));783 try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three"));
784 }784 }
785}785}
786786
...@@ -795,25 +795,25 @@ test "peer type resolution: error union after non-error" {...@@ -795,25 +795,25 @@ test "peer type resolution: error union after non-error" {
795 {795 {
796 const ty = @TypeOf(a, b);796 const ty = @TypeOf(a, b);
797 const info = @typeInfo(ty);797 const info = @typeInfo(ty);
798 try expect(info == .ErrorUnion);798 try expect(info == .error_union);
799 try expect(info.ErrorUnion.payload == u32);799 try expect(info.error_union.payload == u32);
800800
801 const error_set_info = @typeInfo(info.ErrorUnion.error_set);801 const error_set_info = @typeInfo(info.error_union.error_set);
802 try expect(error_set_info.ErrorSet.?.len == 2);802 try expect(error_set_info.error_set.?.len == 2);
803 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));803 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
804 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));804 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
805 }805 }
806806
807 {807 {
808 const ty = @TypeOf(b, a);808 const ty = @TypeOf(b, a);
809 const info = @typeInfo(ty);809 const info = @typeInfo(ty);
810 try expect(info == .ErrorUnion);810 try expect(info == .error_union);
811 try expect(info.ErrorUnion.payload == u32);811 try expect(info.error_union.payload == u32);
812812
813 const error_set_info = @typeInfo(info.ErrorUnion.error_set);813 const error_set_info = @typeInfo(info.error_union.error_set);
814 try expect(error_set_info.ErrorSet.?.len == 2);814 try expect(error_set_info.error_set.?.len == 2);
815 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));815 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
816 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));816 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
817 }817 }
818}818}
819819
...@@ -1484,7 +1484,7 @@ test "coerce between pointers of compatible differently-named floats" {...@@ -1484,7 +1484,7 @@ test "coerce between pointers of compatible differently-named floats" {
1484 return error.SkipZigTest;1484 return error.SkipZigTest;
1485 }1485 }
14861486
1487 const F = switch (@typeInfo(c_longdouble).Float.bits) {1487 const F = switch (@typeInfo(c_longdouble).float.bits) {
1488 16 => f16,1488 16 => f16,
1489 32 => f32,1489 32 => f32,
1490 64 => f64,1490 64 => f64,
...@@ -2151,7 +2151,7 @@ test "peer type resolution: tuples with comptime fields" {...@@ -2151,7 +2151,7 @@ test "peer type resolution: tuples with comptime fields" {
2151 const ti1 = @typeInfo(@TypeOf(a, b));2151 const ti1 = @typeInfo(@TypeOf(a, b));
2152 const ti2 = @typeInfo(@TypeOf(b, a));2152 const ti2 = @typeInfo(@TypeOf(b, a));
2153 inline for (.{ ti1, ti2 }) |ti| {2153 inline for (.{ ti1, ti2 }) |ti| {
2154 const s = ti.Struct;2154 const s = ti.@"struct";
2155 comptime assert(s.is_tuple);2155 comptime assert(s.is_tuple);
2156 comptime assert(s.fields.len == 2);2156 comptime assert(s.fields.len == 2);
2157 comptime assert(s.fields[0].type == u32);2157 comptime assert(s.fields[0].type == u32);
test/behavior/comptime_memory.zig+1-1
...@@ -119,7 +119,7 @@ fn shuffle(ptr: usize, comptime From: type, comptime To: type) usize {...@@ -119,7 +119,7 @@ fn shuffle(ptr: usize, comptime From: type, comptime To: type) usize {
119 const pResult = @as(*align(1) [array_len]To, @ptrCast(&result));119 const pResult = @as(*align(1) [array_len]To, @ptrCast(&result));
120 var i: usize = 0;120 var i: usize = 0;
121 while (i < array_len) : (i += 1) {121 while (i < array_len) : (i += 1) {
122 inline for (@typeInfo(To).Struct.fields) |f| {122 inline for (@typeInfo(To).@"struct".fields) |f| {
123 @field(pResult[i], f.name) = @field(pSource[i], f.name);123 @field(pResult[i], f.name) = @field(pSource[i], f.name);
124 }124 }
125 }125 }
test/behavior/empty_tuple_fields.zig+6-6
...@@ -9,9 +9,9 @@ test "empty file level struct" {...@@ -9,9 +9,9 @@ test "empty file level struct" {
99
10 const T = @import("empty_file_level_struct.zig");10 const T = @import("empty_file_level_struct.zig");
11 const info = @typeInfo(T);11 const info = @typeInfo(T);
12 try std.testing.expectEqual(@as(usize, 1), info.Struct.fields.len);12 try std.testing.expectEqual(@as(usize, 1), info.@"struct".fields.len);
13 try std.testing.expectEqualStrings("0", info.Struct.fields[0].name);13 try std.testing.expectEqualStrings("0", info.@"struct".fields[0].name);
14 try std.testing.expect(@typeInfo(info.Struct.fields[0].type) == .Struct);14 try std.testing.expect(@typeInfo(info.@"struct".fields[0].type) == .@"struct");
15}15}
1616
17test "empty file level union" {17test "empty file level union" {
...@@ -22,7 +22,7 @@ test "empty file level union" {...@@ -22,7 +22,7 @@ test "empty file level union" {
2222
23 const T = @import("empty_file_level_union.zig");23 const T = @import("empty_file_level_union.zig");
24 const info = @typeInfo(T);24 const info = @typeInfo(T);
25 try std.testing.expectEqual(@as(usize, 1), info.Struct.fields.len);25 try std.testing.expectEqual(@as(usize, 1), info.@"struct".fields.len);
26 try std.testing.expectEqualStrings("0", info.Struct.fields[0].name);26 try std.testing.expectEqualStrings("0", info.@"struct".fields[0].name);
27 try std.testing.expect(@typeInfo(info.Struct.fields[0].type) == .Union);27 try std.testing.expect(@typeInfo(info.@"struct".fields[0].type) == .@"union");
28}28}
test/behavior/enum.zig+8-8
...@@ -647,12 +647,12 @@ test "non-exhaustive enum" {...@@ -647,12 +647,12 @@ test "non-exhaustive enum" {
647 else => true,647 else => true,
648 });648 });
649649
650 try expect(@typeInfo(E).Enum.fields.len == 2);650 try expect(@typeInfo(E).@"enum".fields.len == 2);
651 e = @as(E, @enumFromInt(12));651 e = @as(E, @enumFromInt(12));
652 try expect(@intFromEnum(e) == 12);652 try expect(@intFromEnum(e) == 12);
653 e = @as(E, @enumFromInt(y));653 e = @as(E, @enumFromInt(y));
654 try expect(@intFromEnum(e) == 52);654 try expect(@intFromEnum(e) == 52);
655 try expect(@typeInfo(E).Enum.is_exhaustive == false);655 try expect(@typeInfo(E).@"enum".is_exhaustive == false);
656 }656 }
657 };657 };
658 try S.doTheTest(52);658 try S.doTheTest(52);
...@@ -671,8 +671,8 @@ test "empty non-exhaustive enum" {...@@ -671,8 +671,8 @@ test "empty non-exhaustive enum" {
671 });671 });
672 try expect(@intFromEnum(e) == y);672 try expect(@intFromEnum(e) == y);
673673
674 try expect(@typeInfo(E).Enum.fields.len == 0);674 try expect(@typeInfo(E).@"enum".fields.len == 0);
675 try expect(@typeInfo(E).Enum.is_exhaustive == false);675 try expect(@typeInfo(E).@"enum".is_exhaustive == false);
676 }676 }
677 };677 };
678 try S.doTheTest(42);678 try S.doTheTest(42);
...@@ -708,8 +708,8 @@ test "single field non-exhaustive enum" {...@@ -708,8 +708,8 @@ test "single field non-exhaustive enum" {
708 });708 });
709709
710 try expect(@intFromEnum(@as(E, @enumFromInt(y))) == y);710 try expect(@intFromEnum(@as(E, @enumFromInt(y))) == y);
711 try expect(@typeInfo(E).Enum.fields.len == 1);711 try expect(@typeInfo(E).@"enum".fields.len == 1);
712 try expect(@typeInfo(E).Enum.is_exhaustive == false);712 try expect(@typeInfo(E).@"enum".is_exhaustive == false);
713 }713 }
714 };714 };
715 try S.doTheTest(23);715 try S.doTheTest(23);
...@@ -1253,9 +1253,9 @@ test "Non-exhaustive enum backed by comptime_int" {...@@ -1253,9 +1253,9 @@ test "Non-exhaustive enum backed by comptime_int" {
1253test "matching captures causes enum equivalence" {1253test "matching captures causes enum equivalence" {
1254 const S = struct {1254 const S = struct {
1255 fn Nonexhaustive(comptime I: type) type {1255 fn Nonexhaustive(comptime I: type) type {
1256 const UTag = @Type(.{ .Int = .{1256 const UTag = @Type(.{ .int = .{
1257 .signedness = .unsigned,1257 .signedness = .unsigned,
1258 .bits = @typeInfo(I).Int.bits,1258 .bits = @typeInfo(I).int.bits,
1259 } });1259 } });
1260 return enum(UTag) { _ };1260 return enum(UTag) { _ };
1261 }1261 }
test/behavior/error.zig+8-8
...@@ -188,9 +188,9 @@ test "error union type " {...@@ -188,9 +188,9 @@ test "error union type " {
188fn testErrorUnionType() !void {188fn testErrorUnionType() !void {
189 const x: anyerror!i32 = 1234;189 const x: anyerror!i32 = 1234;
190 if (x) |value| try expect(value == 1234) else |_| unreachable;190 if (x) |value| try expect(value == 1234) else |_| unreachable;
191 try expect(@typeInfo(@TypeOf(x)) == .ErrorUnion);191 try expect(@typeInfo(@TypeOf(x)) == .error_union);
192 try expect(@typeInfo(@typeInfo(@TypeOf(x)).ErrorUnion.error_set) == .ErrorSet);192 try expect(@typeInfo(@typeInfo(@TypeOf(x)).error_union.error_set) == .error_set);
193 try expect(@typeInfo(@TypeOf(x)).ErrorUnion.error_set == anyerror);193 try expect(@typeInfo(@TypeOf(x)).error_union.error_set == anyerror);
194}194}
195195
196test "error set type" {196test "error set type" {
...@@ -204,7 +204,7 @@ const MyErrSet = error{...@@ -204,7 +204,7 @@ const MyErrSet = error{
204};204};
205205
206fn testErrorSetType() !void {206fn testErrorSetType() !void {
207 try expect(@typeInfo(MyErrSet).ErrorSet.?.len == 2);207 try expect(@typeInfo(MyErrSet).error_set.?.len == 2);
208208
209 const a: MyErrSet!i32 = 5678;209 const a: MyErrSet!i32 = 5678;
210 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;210 const b: MyErrSet!i32 = MyErrSet.OutOfMemory;
...@@ -653,9 +653,9 @@ test "inferred error set equality" {...@@ -653,9 +653,9 @@ test "inferred error set equality" {
653 fn quux() anyerror!void {}653 fn quux() anyerror!void {}
654 };654 };
655655
656 const FooError = @typeInfo(@typeInfo(@TypeOf(S.foo)).Fn.return_type.?).ErrorUnion.error_set;656 const FooError = @typeInfo(@typeInfo(@TypeOf(S.foo)).@"fn".return_type.?).error_union.error_set;
657 const BarError = @typeInfo(@typeInfo(@TypeOf(S.bar)).Fn.return_type.?).ErrorUnion.error_set;657 const BarError = @typeInfo(@typeInfo(@TypeOf(S.bar)).@"fn".return_type.?).error_union.error_set;
658 const BazError = @typeInfo(@typeInfo(@TypeOf(S.baz)).Fn.return_type.?).ErrorUnion.error_set;658 const BazError = @typeInfo(@typeInfo(@TypeOf(S.baz)).@"fn".return_type.?).error_union.error_set;
659659
660 try expect(BarError != error{Bad});660 try expect(BarError != error{Bad});
661661
...@@ -1040,7 +1040,7 @@ test "generic type constructed from inferred error set of unresolved function" {...@@ -1040,7 +1040,7 @@ test "generic type constructed from inferred error set of unresolved function" {
1040 _ = bytes;1040 _ = bytes;
1041 return 0;1041 return 0;
1042 }1042 }
1043 const T = std.io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).Fn.return_type.?).ErrorUnion.error_set, write);1043 const T = std.io.Writer(void, @typeInfo(@typeInfo(@TypeOf(write)).@"fn".return_type.?).error_union.error_set, write);
1044 fn writer() T {1044 fn writer() T {
1045 return .{ .context = {} };1045 return .{ .context = {} };
1046 }1046 }
test/behavior/eval.zig+2-2
...@@ -538,7 +538,7 @@ test "@tagName of @typeInfo" {...@@ -538,7 +538,7 @@ test "@tagName of @typeInfo" {
538 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO538 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
539539
540 const str = @tagName(@typeInfo(u8));540 const str = @tagName(@typeInfo(u8));
541 try expect(std.mem.eql(u8, str, "Int"));541 try expect(std.mem.eql(u8, str, "int"));
542}542}
543543
544test "static eval list init" {544test "static eval list init" {
...@@ -951,7 +951,7 @@ test "const local with comptime init through array init" {...@@ -951,7 +951,7 @@ test "const local with comptime init through array init" {
951951
952 const S = struct {952 const S = struct {
953 fn declarations(comptime T: type) []const std.builtin.Type.Declaration {953 fn declarations(comptime T: type) []const std.builtin.Type.Declaration {
954 return @typeInfo(T).Enum.decls;954 return @typeInfo(T).@"enum".decls;
955 }955 }
956 };956 };
957957
test/behavior/export_self_referential_type_info.zig+1-1
...@@ -1 +1 @@...@@ -1 +1 @@
1export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).Struct.is_tuple);1export const self_referential_type_info: c_int = @intFromBool(@typeInfo(@This()).@"struct".is_tuple);
test/behavior/fn.zig+5-5
...@@ -393,7 +393,7 @@ test "ability to give comptime types and non comptime types to same parameter" {...@@ -393,7 +393,7 @@ test "ability to give comptime types and non comptime types to same parameter" {
393 }393 }
394394
395 fn foo(arg: anytype) i32 {395 fn foo(arg: anytype) i32 {
396 if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20;396 if (@typeInfo(@TypeOf(arg)) == .type and arg == i32) return 20;
397 return 9 + arg;397 return 9 + arg;
398 }398 }
399 };399 };
...@@ -406,8 +406,8 @@ test "function with inferred error set but returning no error" {...@@ -406,8 +406,8 @@ test "function with inferred error set but returning no error" {
406 fn foo() !void {}406 fn foo() !void {}
407 };407 };
408408
409 const return_ty = @typeInfo(@TypeOf(S.foo)).Fn.return_type.?;409 const return_ty = @typeInfo(@TypeOf(S.foo)).@"fn".return_type.?;
410 try expectEqual(0, @typeInfo(@typeInfo(return_ty).ErrorUnion.error_set).ErrorSet.?.len);410 try expectEqual(0, @typeInfo(@typeInfo(return_ty).error_union.error_set).error_set.?.len);
411}411}
412412
413test "import passed byref to function in return type" {413test "import passed byref to function in return type" {
...@@ -567,10 +567,10 @@ test "lazy values passed to anytype parameter" {...@@ -567,10 +567,10 @@ test "lazy values passed to anytype parameter" {
567567
568test "pass and return comptime-only types" {568test "pass and return comptime-only types" {
569 const S = struct {569 const S = struct {
570 fn returnNull(comptime x: @Type(.Null)) @Type(.Null) {570 fn returnNull(comptime x: @Type(.null)) @Type(.null) {
571 return x;571 return x;
572 }572 }
573 fn returnUndefined(comptime x: @Type(.Undefined)) @Type(.Undefined) {573 fn returnUndefined(comptime x: @Type(.undefined)) @Type(.undefined) {
574 return x;574 return x;
575 }575 }
576 };576 };
test/behavior/generics.zig+6-6
...@@ -179,7 +179,7 @@ test "generic fn keeps non-generic parameter types" {...@@ -179,7 +179,7 @@ test "generic fn keeps non-generic parameter types" {
179179
180 const S = struct {180 const S = struct {
181 fn f(comptime T: type, s: []T) !void {181 fn f(comptime T: type, s: []T) !void {
182 try expect(A != @typeInfo(@TypeOf(s)).Pointer.alignment);182 try expect(A != @typeInfo(@TypeOf(s)).pointer.alignment);
183 }183 }
184 };184 };
185185
...@@ -258,17 +258,17 @@ test "generic function instantiation turns into comptime call" {...@@ -258,17 +258,17 @@ test "generic function instantiation turns into comptime call" {
258 }258 }
259259
260 pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {260 pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
261 .Enum => std.builtin.Type.EnumField,261 .@"enum" => std.builtin.Type.EnumField,
262 else => void,262 else => void,
263 } {263 } {
264 return @typeInfo(T).Enum.fields[@intFromEnum(field)];264 return @typeInfo(T).@"enum".fields[@intFromEnum(field)];
265 }265 }
266266
267 pub fn FieldEnum(comptime T: type) type {267 pub fn FieldEnum(comptime T: type) type {
268 _ = T;268 _ = T;
269 var enumFields: [1]std.builtin.Type.EnumField = .{.{ .name = "A", .value = 0 }};269 var enumFields: [1]std.builtin.Type.EnumField = .{.{ .name = "A", .value = 0 }};
270 return @Type(.{270 return @Type(.{
271 .Enum = .{271 .@"enum" = .{
272 .tag_type = u0,272 .tag_type = u0,
273 .fields = &enumFields,273 .fields = &enumFields,
274 .decls = &.{},274 .decls = &.{},
...@@ -363,7 +363,7 @@ test "nested generic function" {...@@ -363,7 +363,7 @@ test "nested generic function" {
363363
364 fn g(_: *const fn (anytype) void) void {}364 fn g(_: *const fn (anytype) void) void {}
365 };365 };
366 try expect(@typeInfo(@TypeOf(S.g)).Fn.is_generic);366 try expect(@typeInfo(@TypeOf(S.g)).@"fn".is_generic);
367 try S.foo(u32, S.bar, 123);367 try S.foo(u32, S.bar, 123);
368}368}
369369
...@@ -549,7 +549,7 @@ test "call generic function with from function called by the generic function" {...@@ -549,7 +549,7 @@ test "call generic function with from function called by the generic function" {
549 const ArgSerializer = struct {549 const ArgSerializer = struct {
550 fn isCommand(comptime T: type) bool {550 fn isCommand(comptime T: type) bool {
551 const tid = @typeInfo(T);551 const tid = @typeInfo(T);
552 return (tid == .Struct or tid == .Enum or tid == .Union) and552 return (tid == .@"struct" or tid == .@"enum" or tid == .@"union") and
553 @hasDecl(T, "Redis") and @hasDecl(T.Redis, "Command");553 @hasDecl(T, "Redis") and @hasDecl(T.Redis, "Command");
554 }554 }
555 fn serializeCommand(command: anytype) void {555 fn serializeCommand(command: anytype) void {
test/behavior/math.zig+4-4
...@@ -135,8 +135,8 @@ fn testOneClzVector(...@@ -135,8 +135,8 @@ fn testOneClzVector(
135}135}
136136
137fn expectVectorsEqual(a: anytype, b: anytype) !void {137fn expectVectorsEqual(a: anytype, b: anytype) !void {
138 const len_a = @typeInfo(@TypeOf(a)).Vector.len;138 const len_a = @typeInfo(@TypeOf(a)).vector.len;
139 const len_b = @typeInfo(@TypeOf(b)).Vector.len;139 const len_b = @typeInfo(@TypeOf(b)).vector.len;
140 try expect(len_a == len_b);140 try expect(len_a == len_b);
141141
142 var i: usize = 0;142 var i: usize = 0;
...@@ -1683,12 +1683,12 @@ test "signed zeros are represented properly" {...@@ -1683,12 +1683,12 @@ test "signed zeros are represented properly" {
1683 }1683 }
16841684
1685 fn testOne(comptime T: type) !void {1685 fn testOne(comptime T: type) !void {
1686 const ST = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);1686 const ST = std.meta.Int(.unsigned, @typeInfo(T).float.bits);
1687 var as_fp_val = -@as(T, 0.0);1687 var as_fp_val = -@as(T, 0.0);
1688 _ = &as_fp_val;1688 _ = &as_fp_val;
1689 const as_uint_val: ST = @bitCast(as_fp_val);1689 const as_uint_val: ST = @bitCast(as_fp_val);
1690 // Ensure the sign bit is set.1690 // Ensure the sign bit is set.
1691 try expect(as_uint_val >> (@typeInfo(T).Float.bits - 1) == 1);1691 try expect(as_uint_val >> (@typeInfo(T).float.bits - 1) == 1);
1692 }1692 }
1693 };1693 };
16941694
test/behavior/packed-struct.zig+2-2
...@@ -1186,9 +1186,9 @@ test "packed struct field pointer aligned properly" {...@@ -1186,9 +1186,9 @@ test "packed struct field pointer aligned properly" {
1186 };1186 };
11871187
1188 var f1: *align(16) Foo = @alignCast(@as(*align(1) Foo, @ptrCast(&Foo.buffer[0])));1188 var f1: *align(16) Foo = @alignCast(@as(*align(1) Foo, @ptrCast(&Foo.buffer[0])));
1189 try expect(@typeInfo(@TypeOf(f1)).Pointer.alignment == 16);1189 try expect(@typeInfo(@TypeOf(f1)).pointer.alignment == 16);
1190 try expect(@intFromPtr(f1) == @intFromPtr(&f1.a));1190 try expect(@intFromPtr(f1) == @intFromPtr(&f1.a));
1191 try expect(@typeInfo(@TypeOf(&f1.a)).Pointer.alignment == 16);1191 try expect(@typeInfo(@TypeOf(&f1.a)).pointer.alignment == 16);
1192}1192}
11931193
1194test "load flag from packed struct in union" {1194test "load flag from packed struct in union" {
test/behavior/pointers.zig+18-18
...@@ -266,8 +266,8 @@ test "allowzero pointer and slice" {...@@ -266,8 +266,8 @@ test "allowzero pointer and slice" {
266 comptime assert(@TypeOf(slice) == []allowzero i32);266 comptime assert(@TypeOf(slice) == []allowzero i32);
267 try expect(@intFromPtr(&slice[5]) == 20);267 try expect(@intFromPtr(&slice[5]) == 20);
268268
269 comptime assert(@typeInfo(@TypeOf(ptr)).Pointer.is_allowzero);269 comptime assert(@typeInfo(@TypeOf(ptr)).pointer.is_allowzero);
270 comptime assert(@typeInfo(@TypeOf(slice)).Pointer.is_allowzero);270 comptime assert(@typeInfo(@TypeOf(slice)).pointer.is_allowzero);
271}271}
272272
273test "assign null directly to C pointer and test null equality" {273test "assign null directly to C pointer and test null equality" {
...@@ -441,15 +441,15 @@ test "pointer-integer arithmetic affects the alignment" {...@@ -441,15 +441,15 @@ test "pointer-integer arithmetic affects the alignment" {
441 var x: usize = 1;441 var x: usize = 1;
442 _ = .{ &ptr, &x };442 _ = .{ &ptr, &x };
443443
444 try expect(@typeInfo(@TypeOf(ptr)).Pointer.alignment == 8);444 try expect(@typeInfo(@TypeOf(ptr)).pointer.alignment == 8);
445 const ptr1 = ptr + 1; // 1 * 4 = 4 -> lcd(4,8) = 4445 const ptr1 = ptr + 1; // 1 * 4 = 4 -> lcd(4,8) = 4
446 try expect(@typeInfo(@TypeOf(ptr1)).Pointer.alignment == 4);446 try expect(@typeInfo(@TypeOf(ptr1)).pointer.alignment == 4);
447 const ptr2 = ptr + 4; // 4 * 4 = 16 -> lcd(16,8) = 8447 const ptr2 = ptr + 4; // 4 * 4 = 16 -> lcd(16,8) = 8
448 try expect(@typeInfo(@TypeOf(ptr2)).Pointer.alignment == 8);448 try expect(@typeInfo(@TypeOf(ptr2)).pointer.alignment == 8);
449 const ptr3 = ptr + 0; // no-op449 const ptr3 = ptr + 0; // no-op
450 try expect(@typeInfo(@TypeOf(ptr3)).Pointer.alignment == 8);450 try expect(@typeInfo(@TypeOf(ptr3)).pointer.alignment == 8);
451 const ptr4 = ptr + x; // runtime-known addend451 const ptr4 = ptr + x; // runtime-known addend
452 try expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4);452 try expect(@typeInfo(@TypeOf(ptr4)).pointer.alignment == 4);
453 }453 }
454 {454 {
455 var ptr: [*]align(8) [3]u8 = undefined;455 var ptr: [*]align(8) [3]u8 = undefined;
...@@ -457,13 +457,13 @@ test "pointer-integer arithmetic affects the alignment" {...@@ -457,13 +457,13 @@ test "pointer-integer arithmetic affects the alignment" {
457 _ = .{ &ptr, &x };457 _ = .{ &ptr, &x };
458458
459 const ptr1 = ptr + 17; // 3 * 17 = 51459 const ptr1 = ptr + 17; // 3 * 17 = 51
460 try expect(@typeInfo(@TypeOf(ptr1)).Pointer.alignment == 1);460 try expect(@typeInfo(@TypeOf(ptr1)).pointer.alignment == 1);
461 const ptr2 = ptr + x; // runtime-known addend461 const ptr2 = ptr + x; // runtime-known addend
462 try expect(@typeInfo(@TypeOf(ptr2)).Pointer.alignment == 1);462 try expect(@typeInfo(@TypeOf(ptr2)).pointer.alignment == 1);
463 const ptr3 = ptr + 8; // 3 * 8 = 24 -> lcd(8,24) = 8463 const ptr3 = ptr + 8; // 3 * 8 = 24 -> lcd(8,24) = 8
464 try expect(@typeInfo(@TypeOf(ptr3)).Pointer.alignment == 8);464 try expect(@typeInfo(@TypeOf(ptr3)).pointer.alignment == 8);
465 const ptr4 = ptr + 4; // 3 * 4 = 12 -> lcd(8,12) = 4465 const ptr4 = ptr + 4; // 3 * 4 = 12 -> lcd(8,12) = 4
466 try expect(@typeInfo(@TypeOf(ptr4)).Pointer.alignment == 4);466 try expect(@typeInfo(@TypeOf(ptr4)).pointer.alignment == 4);
467 }467 }
468}468}
469469
...@@ -560,7 +560,7 @@ test "pointer to constant decl preserves alignment" {...@@ -560,7 +560,7 @@ test "pointer to constant decl preserves alignment" {
560 const aligned align(8) = @This(){ .a = 3, .b = 4 };560 const aligned align(8) = @This(){ .a = 3, .b = 4 };
561 };561 };
562562
563 const alignment = @typeInfo(@TypeOf(&S.aligned)).Pointer.alignment;563 const alignment = @typeInfo(@TypeOf(&S.aligned)).pointer.alignment;
564 try std.testing.expect(alignment == 8);564 try std.testing.expect(alignment == 8);
565}565}
566566
...@@ -641,24 +641,24 @@ const Box2 = struct {...@@ -641,24 +641,24 @@ const Box2 = struct {
641641
642fn mutable() !void {642fn mutable() !void {
643 var box0: Box0 = .{ .items = undefined };643 var box0: Box0 = .{ .items = undefined };
644 try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).Pointer.is_const == false);644 try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).pointer.is_const == false);
645645
646 var box1: Box1 = .{ .items = undefined };646 var box1: Box1 = .{ .items = undefined };
647 try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).Pointer.is_const == false);647 try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).pointer.is_const == false);
648648
649 var box2: Box2 = .{ .items = undefined };649 var box2: Box2 = .{ .items = undefined };
650 try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).Pointer.is_const == false);650 try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).pointer.is_const == false);
651}651}
652652
653fn constant() !void {653fn constant() !void {
654 const box0: Box0 = .{ .items = undefined };654 const box0: Box0 = .{ .items = undefined };
655 try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).Pointer.is_const == true);655 try std.testing.expect(@typeInfo(@TypeOf(box0.items[0..])).pointer.is_const == true);
656656
657 const box1: Box1 = .{ .items = undefined };657 const box1: Box1 = .{ .items = undefined };
658 try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).Pointer.is_const == true);658 try std.testing.expect(@typeInfo(@TypeOf(box1.items[0..])).pointer.is_const == true);
659659
660 const box2: Box2 = .{ .items = undefined };660 const box2: Box2 = .{ .items = undefined };
661 try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).Pointer.is_const == true);661 try std.testing.expect(@typeInfo(@TypeOf(box2.items[0..])).pointer.is_const == true);
662}662}
663663
664test "pointer-to-array constness for zero-size elements, var" {664test "pointer-to-array constness for zero-size elements, var" {
test/behavior/reflection.zig+1-1
...@@ -6,7 +6,7 @@ const reflection = @This();...@@ -6,7 +6,7 @@ const reflection = @This();
66
7test "reflection: function return type, var args, and param types" {7test "reflection: function return type, var args, and param types" {
8 comptime {8 comptime {
9 const info = @typeInfo(@TypeOf(dummy)).Fn;9 const info = @typeInfo(@TypeOf(dummy)).@"fn";
10 try expect(info.return_type.? == i32);10 try expect(info.return_type.? == i32);
11 try expect(!info.is_var_args);11 try expect(!info.is_var_args);
12 try expect(info.params.len == 3);12 try expect(info.params.len == 3);
test/behavior/slice.zig+3-3
...@@ -329,9 +329,9 @@ test "empty array to slice" {...@@ -329,9 +329,9 @@ test "empty array to slice" {
329 const align_1: []align(1) u8 = empty;329 const align_1: []align(1) u8 = empty;
330 const align_4: []align(4) u8 = empty;330 const align_4: []align(4) u8 = empty;
331 const align_16: []align(16) u8 = empty;331 const align_16: []align(16) u8 = empty;
332 try expect(1 == @typeInfo(@TypeOf(align_1)).Pointer.alignment);332 try expect(1 == @typeInfo(@TypeOf(align_1)).pointer.alignment);
333 try expect(4 == @typeInfo(@TypeOf(align_4)).Pointer.alignment);333 try expect(4 == @typeInfo(@TypeOf(align_4)).pointer.alignment);
334 try expect(16 == @typeInfo(@TypeOf(align_16)).Pointer.alignment);334 try expect(16 == @typeInfo(@TypeOf(align_16)).pointer.alignment);
335 }335 }
336 };336 };
337337
test/behavior/struct.zig+3-3
...@@ -1738,7 +1738,7 @@ test "packed struct field in anonymous struct" {...@@ -1738,7 +1738,7 @@ test "packed struct field in anonymous struct" {
1738 try std.testing.expect(countFields(.{ .t = T{} }) == 1);1738 try std.testing.expect(countFields(.{ .t = T{} }) == 1);
1739}1739}
1740fn countFields(v: anytype) usize {1740fn countFields(v: anytype) usize {
1741 return @typeInfo(@TypeOf(v)).Struct.fields.len;1741 return @typeInfo(@TypeOf(v)).@"struct".fields.len;
1742}1742}
17431743
1744test "struct init with no result pointer sets field result types" {1744test "struct init with no result pointer sets field result types" {
...@@ -2144,9 +2144,9 @@ test "struct containing optional pointer to array of @This()" {...@@ -2144,9 +2144,9 @@ test "struct containing optional pointer to array of @This()" {
2144test "matching captures causes struct equivalence" {2144test "matching captures causes struct equivalence" {
2145 const S = struct {2145 const S = struct {
2146 fn UnsignedWrapper(comptime I: type) type {2146 fn UnsignedWrapper(comptime I: type) type {
2147 const bits = @typeInfo(I).Int.bits;2147 const bits = @typeInfo(I).int.bits;
2148 return struct {2148 return struct {
2149 x: @Type(.{ .Int = .{2149 x: @Type(.{ .int = .{
2150 .signedness = .unsigned,2150 .signedness = .unsigned,
2151 .bits = bits,2151 .bits = bits,
2152 } }),2152 } }),
test/behavior/tuple.zig+6-6
...@@ -32,16 +32,16 @@ test "tuple multiplication" {...@@ -32,16 +32,16 @@ test "tuple multiplication" {
32 fn doTheTest() !void {32 fn doTheTest() !void {
33 {33 {
34 const t = .{} ** 4;34 const t = .{} ** 4;
35 try expect(@typeInfo(@TypeOf(t)).Struct.fields.len == 0);35 try expect(@typeInfo(@TypeOf(t)).@"struct".fields.len == 0);
36 }36 }
37 {37 {
38 const t = .{'a'} ** 4;38 const t = .{'a'} ** 4;
39 try expect(@typeInfo(@TypeOf(t)).Struct.fields.len == 4);39 try expect(@typeInfo(@TypeOf(t)).@"struct".fields.len == 4);
40 inline for (t) |x| try expect(x == 'a');40 inline for (t) |x| try expect(x == 'a');
41 }41 }
42 {42 {
43 const t = .{ 1, 2, 3 } ** 4;43 const t = .{ 1, 2, 3 } ** 4;
44 try expect(@typeInfo(@TypeOf(t)).Struct.fields.len == 12);44 try expect(@typeInfo(@TypeOf(t)).@"struct".fields.len == 12);
45 inline for (t, 0..) |x, i| try expect(x == 1 + i % 3);45 inline for (t, 0..) |x, i| try expect(x == 1 + i % 3);
46 }46 }
47 }47 }
...@@ -133,7 +133,7 @@ test "array-like initializer for tuple types" {...@@ -133,7 +133,7 @@ test "array-like initializer for tuple types" {
133 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO133 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
134134
135 const T = @Type(.{135 const T = @Type(.{
136 .Struct = .{136 .@"struct" = .{
137 .is_tuple = true,137 .is_tuple = true,
138 .layout = .auto,138 .layout = .auto,
139 .decls = &.{},139 .decls = &.{},
...@@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" {...@@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" {
323 const State = struct {323 const State = struct {
324 const Self = @This();324 const Self = @This();
325 data: @Type(.{325 data: @Type(.{
326 .Struct = .{326 .@"struct" = .{
327 .is_tuple = true,327 .is_tuple = true,
328 .layout = .auto,328 .layout = .auto,
329 .decls = &.{},329 .decls = &.{},
...@@ -474,7 +474,7 @@ test "coerce anon tuple to tuple" {...@@ -474,7 +474,7 @@ test "coerce anon tuple to tuple" {
474}474}
475475
476test "empty tuple type" {476test "empty tuple type" {
477 const S = @Type(.{ .Struct = .{477 const S = @Type(.{ .@"struct" = .{
478 .layout = .auto,478 .layout = .auto,
479 .fields = &.{},479 .fields = &.{},
480 .decls = &.{},480 .decls = &.{},
test/behavior/tuple_declarations.zig+1-1
...@@ -10,7 +10,7 @@ test "tuple declaration type info" {...@@ -10,7 +10,7 @@ test "tuple declaration type info" {
1010
11 {11 {
12 const T = struct { comptime u32 align(2) = 1, []const u8 };12 const T = struct { comptime u32 align(2) = 1, []const u8 };
13 const info = @typeInfo(T).Struct;13 const info = @typeInfo(T).@"struct";
1414
15 try expect(info.layout == .auto);15 try expect(info.layout == .auto);
16 try expect(info.backing_integer == null);16 try expect(info.backing_integer == null);
test/behavior/type.zig+59-59
...@@ -11,32 +11,32 @@ fn testTypes(comptime types: []const type) !void {...@@ -11,32 +11,32 @@ fn testTypes(comptime types: []const type) !void {
11}11}
1212
13test "Type.MetaType" {13test "Type.MetaType" {
14 try testing.expect(type == @Type(.{ .Type = {} }));14 try testing.expect(type == @Type(.{ .type = {} }));
15 try testTypes(&[_]type{type});15 try testTypes(&[_]type{type});
16}16}
1717
18test "Type.Void" {18test "Type.Void" {
19 try testing.expect(void == @Type(.{ .Void = {} }));19 try testing.expect(void == @Type(.{ .void = {} }));
20 try testTypes(&[_]type{void});20 try testTypes(&[_]type{void});
21}21}
2222
23test "Type.Bool" {23test "Type.Bool" {
24 try testing.expect(bool == @Type(.{ .Bool = {} }));24 try testing.expect(bool == @Type(.{ .bool = {} }));
25 try testTypes(&[_]type{bool});25 try testTypes(&[_]type{bool});
26}26}
2727
28test "Type.NoReturn" {28test "Type.NoReturn" {
29 try testing.expect(noreturn == @Type(.{ .NoReturn = {} }));29 try testing.expect(noreturn == @Type(.{ .noreturn = {} }));
30 try testTypes(&[_]type{noreturn});30 try testTypes(&[_]type{noreturn});
31}31}
3232
33test "Type.Int" {33test "Type.Int" {
34 try testing.expect(u1 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 1 } }));34 try testing.expect(u1 == @Type(.{ .int = .{ .signedness = .unsigned, .bits = 1 } }));
35 try testing.expect(i1 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 1 } }));35 try testing.expect(i1 == @Type(.{ .int = .{ .signedness = .signed, .bits = 1 } }));
36 try testing.expect(u8 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 8 } }));36 try testing.expect(u8 == @Type(.{ .int = .{ .signedness = .unsigned, .bits = 8 } }));
37 try testing.expect(i8 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 8 } }));37 try testing.expect(i8 == @Type(.{ .int = .{ .signedness = .signed, .bits = 8 } }));
38 try testing.expect(u64 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 64 } }));38 try testing.expect(u64 == @Type(.{ .int = .{ .signedness = .unsigned, .bits = 64 } }));
39 try testing.expect(i64 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 64 } }));39 try testing.expect(i64 == @Type(.{ .int = .{ .signedness = .signed, .bits = 64 } }));
40 try testTypes(&[_]type{ u8, u32, i64 });40 try testTypes(&[_]type{ u8, u32, i64 });
41}41}
4242
...@@ -105,31 +105,31 @@ test "Type.Pointer" {...@@ -105,31 +105,31 @@ test "Type.Pointer" {
105}105}
106106
107test "Type.Float" {107test "Type.Float" {
108 try testing.expect(f16 == @Type(.{ .Float = .{ .bits = 16 } }));108 try testing.expect(f16 == @Type(.{ .float = .{ .bits = 16 } }));
109 try testing.expect(f32 == @Type(.{ .Float = .{ .bits = 32 } }));109 try testing.expect(f32 == @Type(.{ .float = .{ .bits = 32 } }));
110 try testing.expect(f64 == @Type(.{ .Float = .{ .bits = 64 } }));110 try testing.expect(f64 == @Type(.{ .float = .{ .bits = 64 } }));
111 try testing.expect(f80 == @Type(.{ .Float = .{ .bits = 80 } }));111 try testing.expect(f80 == @Type(.{ .float = .{ .bits = 80 } }));
112 try testing.expect(f128 == @Type(.{ .Float = .{ .bits = 128 } }));112 try testing.expect(f128 == @Type(.{ .float = .{ .bits = 128 } }));
113 try testTypes(&[_]type{ f16, f32, f64, f80, f128 });113 try testTypes(&[_]type{ f16, f32, f64, f80, f128 });
114}114}
115115
116test "Type.Array" {116test "Type.Array" {
117 try testing.expect([123]u8 == @Type(.{117 try testing.expect([123]u8 == @Type(.{
118 .Array = .{118 .array = .{
119 .len = 123,119 .len = 123,
120 .child = u8,120 .child = u8,
121 .sentinel = null,121 .sentinel = null,
122 },122 },
123 }));123 }));
124 try testing.expect([2]u32 == @Type(.{124 try testing.expect([2]u32 == @Type(.{
125 .Array = .{125 .array = .{
126 .len = 2,126 .len = 2,
127 .child = u32,127 .child = u32,
128 .sentinel = null,128 .sentinel = null,
129 },129 },
130 }));130 }));
131 try testing.expect([2:0]u32 == @Type(.{131 try testing.expect([2:0]u32 == @Type(.{
132 .Array = .{132 .array = .{
133 .len = 2,133 .len = 2,
134 .child = u32,134 .child = u32,
135 .sentinel = &@as(u32, 0),135 .sentinel = &@as(u32, 0),
...@@ -140,7 +140,7 @@ test "Type.Array" {...@@ -140,7 +140,7 @@ test "Type.Array" {
140140
141test "@Type create slice with null sentinel" {141test "@Type create slice with null sentinel" {
142 const Slice = @Type(.{142 const Slice = @Type(.{
143 .Pointer = .{143 .pointer = .{
144 .size = .Slice,144 .size = .Slice,
145 .is_const = true,145 .is_const = true,
146 .is_volatile = false,146 .is_volatile = false,
...@@ -205,7 +205,7 @@ test "Type.Opaque" {...@@ -205,7 +205,7 @@ test "Type.Opaque" {
205 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO205 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
206206
207 const Opaque = @Type(.{207 const Opaque = @Type(.{
208 .Opaque = .{208 .@"opaque" = .{
209 .decls = &.{},209 .decls = &.{},
210 },210 },
211 });211 });
...@@ -213,7 +213,7 @@ test "Type.Opaque" {...@@ -213,7 +213,7 @@ test "Type.Opaque" {
213 try testing.expectEqualSlices(213 try testing.expectEqualSlices(
214 Type.Declaration,214 Type.Declaration,
215 &.{},215 &.{},
216 @typeInfo(Opaque).Opaque.decls,216 @typeInfo(Opaque).@"opaque".decls,
217 );217 );
218}218}
219219
...@@ -246,7 +246,7 @@ fn add(a: i32, b: i32) i32 {...@@ -246,7 +246,7 @@ fn add(a: i32, b: i32) i32 {
246}246}
247247
248test "Type.ErrorSet" {248test "Type.ErrorSet" {
249 try testing.expect(@Type(.{ .ErrorSet = null }) == anyerror);249 try testing.expect(@Type(.{ .error_set = null }) == anyerror);
250250
251 // error sets don't compare equal so just check if they compile251 // error sets don't compare equal so just check if they compile
252 inline for (.{ error{}, error{A}, error{ A, B, C } }) |T| {252 inline for (.{ error{}, error{A}, error{ A, B, C } }) |T| {
...@@ -262,7 +262,7 @@ test "Type.Struct" {...@@ -262,7 +262,7 @@ test "Type.Struct" {
262 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO262 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
263263
264 const A = @Type(@typeInfo(struct { x: u8, y: u32 }));264 const A = @Type(@typeInfo(struct { x: u8, y: u32 }));
265 const infoA = @typeInfo(A).Struct;265 const infoA = @typeInfo(A).@"struct";
266 try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout);266 try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout);
267 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);267 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);
268 try testing.expectEqual(u8, infoA.fields[0].type);268 try testing.expectEqual(u8, infoA.fields[0].type);
...@@ -280,7 +280,7 @@ test "Type.Struct" {...@@ -280,7 +280,7 @@ test "Type.Struct" {
280 try testing.expectEqual(@as(u32, 2), a.y);280 try testing.expectEqual(@as(u32, 2), a.y);
281281
282 const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 }));282 const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 }));
283 const infoB = @typeInfo(B).Struct;283 const infoB = @typeInfo(B).@"struct";
284 try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout);284 try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout);
285 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);285 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);
286 try testing.expectEqual(u8, infoB.fields[0].type);286 try testing.expectEqual(u8, infoB.fields[0].type);
...@@ -292,7 +292,7 @@ test "Type.Struct" {...@@ -292,7 +292,7 @@ test "Type.Struct" {
292 try testing.expectEqual(@as(bool, false), infoB.is_tuple);292 try testing.expectEqual(@as(bool, false), infoB.is_tuple);
293293
294 const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 }));294 const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 }));
295 const infoC = @typeInfo(C).Struct;295 const infoC = @typeInfo(C).@"struct";
296 try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout);296 try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout);
297 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);297 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);
298 try testing.expectEqual(u8, infoC.fields[0].type);298 try testing.expectEqual(u8, infoC.fields[0].type);
...@@ -305,7 +305,7 @@ test "Type.Struct" {...@@ -305,7 +305,7 @@ test "Type.Struct" {
305305
306 // anon structs306 // anon structs
307 const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 })));307 const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 })));
308 const infoD = @typeInfo(D).Struct;308 const infoD = @typeInfo(D).@"struct";
309 try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout);309 try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout);
310 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);310 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);
311 try testing.expectEqual(comptime_int, infoD.fields[0].type);311 try testing.expectEqual(comptime_int, infoD.fields[0].type);
...@@ -318,7 +318,7 @@ test "Type.Struct" {...@@ -318,7 +318,7 @@ test "Type.Struct" {
318318
319 // tuples319 // tuples
320 const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 })));320 const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 })));
321 const infoE = @typeInfo(E).Struct;321 const infoE = @typeInfo(E).@"struct";
322 try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout);322 try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout);
323 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);323 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);
324 try testing.expectEqual(comptime_int, infoE.fields[0].type);324 try testing.expectEqual(comptime_int, infoE.fields[0].type);
...@@ -331,14 +331,14 @@ test "Type.Struct" {...@@ -331,14 +331,14 @@ test "Type.Struct" {
331331
332 // empty struct332 // empty struct
333 const F = @Type(@typeInfo(struct {}));333 const F = @Type(@typeInfo(struct {}));
334 const infoF = @typeInfo(F).Struct;334 const infoF = @typeInfo(F).@"struct";
335 try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout);335 try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout);
336 try testing.expect(infoF.fields.len == 0);336 try testing.expect(infoF.fields.len == 0);
337 try testing.expectEqual(@as(bool, false), infoF.is_tuple);337 try testing.expectEqual(@as(bool, false), infoF.is_tuple);
338338
339 // empty tuple339 // empty tuple
340 const G = @Type(@typeInfo(@TypeOf(.{})));340 const G = @Type(@typeInfo(@TypeOf(.{})));
341 const infoG = @typeInfo(G).Struct;341 const infoG = @typeInfo(G).@"struct";
342 try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout);342 try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout);
343 try testing.expect(infoG.fields.len == 0);343 try testing.expect(infoG.fields.len == 0);
344 try testing.expectEqual(@as(bool, true), infoG.is_tuple);344 try testing.expectEqual(@as(bool, true), infoG.is_tuple);
...@@ -349,7 +349,7 @@ test "Type.Enum" {...@@ -349,7 +349,7 @@ test "Type.Enum" {
349 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO349 if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
350350
351 const Foo = @Type(.{351 const Foo = @Type(.{
352 .Enum = .{352 .@"enum" = .{
353 .tag_type = u8,353 .tag_type = u8,
354 .fields = &.{354 .fields = &.{
355 .{ .name = "a", .value = 1 },355 .{ .name = "a", .value = 1 },
...@@ -359,11 +359,11 @@ test "Type.Enum" {...@@ -359,11 +359,11 @@ test "Type.Enum" {
359 .is_exhaustive = true,359 .is_exhaustive = true,
360 },360 },
361 });361 });
362 try testing.expectEqual(true, @typeInfo(Foo).Enum.is_exhaustive);362 try testing.expectEqual(true, @typeInfo(Foo).@"enum".is_exhaustive);
363 try testing.expectEqual(@as(u8, 1), @intFromEnum(Foo.a));363 try testing.expectEqual(@as(u8, 1), @intFromEnum(Foo.a));
364 try testing.expectEqual(@as(u8, 5), @intFromEnum(Foo.b));364 try testing.expectEqual(@as(u8, 5), @intFromEnum(Foo.b));
365 const Bar = @Type(.{365 const Bar = @Type(.{
366 .Enum = .{366 .@"enum" = .{
367 .tag_type = u32,367 .tag_type = u32,
368 .fields = &.{368 .fields = &.{
369 .{ .name = "a", .value = 1 },369 .{ .name = "a", .value = 1 },
...@@ -373,7 +373,7 @@ test "Type.Enum" {...@@ -373,7 +373,7 @@ test "Type.Enum" {
373 .is_exhaustive = false,373 .is_exhaustive = false,
374 },374 },
375 });375 });
376 try testing.expectEqual(false, @typeInfo(Bar).Enum.is_exhaustive);376 try testing.expectEqual(false, @typeInfo(Bar).@"enum".is_exhaustive);
377 try testing.expectEqual(@as(u32, 1), @intFromEnum(Bar.a));377 try testing.expectEqual(@as(u32, 1), @intFromEnum(Bar.a));
378 try testing.expectEqual(@as(u32, 5), @intFromEnum(Bar.b));378 try testing.expectEqual(@as(u32, 5), @intFromEnum(Bar.b));
379 try testing.expectEqual(@as(u32, 6), @intFromEnum(@as(Bar, @enumFromInt(6))));379 try testing.expectEqual(@as(u32, 6), @intFromEnum(@as(Bar, @enumFromInt(6))));
...@@ -385,7 +385,7 @@ test "Type.Union" {...@@ -385,7 +385,7 @@ test "Type.Union" {
385 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;385 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
386386
387 const Untagged = @Type(.{387 const Untagged = @Type(.{
388 .Union = .{388 .@"union" = .{
389 .layout = .@"extern",389 .layout = .@"extern",
390 .tag_type = null,390 .tag_type = null,
391 .fields = &.{391 .fields = &.{
...@@ -401,7 +401,7 @@ test "Type.Union" {...@@ -401,7 +401,7 @@ test "Type.Union" {
401 try testing.expectEqual(@as(i32, 3), untagged.int);401 try testing.expectEqual(@as(i32, 3), untagged.int);
402402
403 const PackedUntagged = @Type(.{403 const PackedUntagged = @Type(.{
404 .Union = .{404 .@"union" = .{
405 .layout = .@"packed",405 .layout = .@"packed",
406 .tag_type = null,406 .tag_type = null,
407 .fields = &.{407 .fields = &.{
...@@ -417,7 +417,7 @@ test "Type.Union" {...@@ -417,7 +417,7 @@ test "Type.Union" {
417 try testing.expectEqual(~@as(u32, 0), packed_untagged.unsigned);417 try testing.expectEqual(~@as(u32, 0), packed_untagged.unsigned);
418418
419 const Tag = @Type(.{419 const Tag = @Type(.{
420 .Enum = .{420 .@"enum" = .{
421 .tag_type = u1,421 .tag_type = u1,
422 .fields = &.{422 .fields = &.{
423 .{ .name = "signed", .value = 0 },423 .{ .name = "signed", .value = 0 },
...@@ -428,7 +428,7 @@ test "Type.Union" {...@@ -428,7 +428,7 @@ test "Type.Union" {
428 },428 },
429 });429 });
430 const Tagged = @Type(.{430 const Tagged = @Type(.{
431 .Union = .{431 .@"union" = .{
432 .layout = .auto,432 .layout = .auto,
433 .tag_type = Tag,433 .tag_type = Tag,
434 .fields = &.{434 .fields = &.{
...@@ -446,7 +446,7 @@ test "Type.Union" {...@@ -446,7 +446,7 @@ test "Type.Union" {
446446
447test "Type.Union from Type.Enum" {447test "Type.Union from Type.Enum" {
448 const Tag = @Type(.{448 const Tag = @Type(.{
449 .Enum = .{449 .@"enum" = .{
450 .tag_type = u0,450 .tag_type = u0,
451 .fields = &.{451 .fields = &.{
452 .{ .name = "working_as_expected", .value = 0 },452 .{ .name = "working_as_expected", .value = 0 },
...@@ -456,7 +456,7 @@ test "Type.Union from Type.Enum" {...@@ -456,7 +456,7 @@ test "Type.Union from Type.Enum" {
456 },456 },
457 });457 });
458 const T = @Type(.{458 const T = @Type(.{
459 .Union = .{459 .@"union" = .{
460 .layout = .auto,460 .layout = .auto,
461 .tag_type = Tag,461 .tag_type = Tag,
462 .fields = &.{462 .fields = &.{
...@@ -465,13 +465,13 @@ test "Type.Union from Type.Enum" {...@@ -465,13 +465,13 @@ test "Type.Union from Type.Enum" {
465 .decls = &.{},465 .decls = &.{},
466 },466 },
467 });467 });
468 _ = @typeInfo(T).Union;468 _ = @typeInfo(T).@"union";
469}469}
470470
471test "Type.Union from regular enum" {471test "Type.Union from regular enum" {
472 const E = enum { working_as_expected };472 const E = enum { working_as_expected };
473 const T = @Type(.{473 const T = @Type(.{
474 .Union = .{474 .@"union" = .{
475 .layout = .auto,475 .layout = .auto,
476 .tag_type = E,476 .tag_type = E,
477 .fields = &.{477 .fields = &.{
...@@ -480,13 +480,13 @@ test "Type.Union from regular enum" {...@@ -480,13 +480,13 @@ test "Type.Union from regular enum" {
480 .decls = &.{},480 .decls = &.{},
481 },481 },
482 });482 });
483 _ = @typeInfo(T).Union;483 _ = @typeInfo(T).@"union";
484}484}
485485
486test "Type.Union from empty regular enum" {486test "Type.Union from empty regular enum" {
487 const E = enum {};487 const E = enum {};
488 const U = @Type(.{488 const U = @Type(.{
489 .Union = .{489 .@"union" = .{
490 .layout = .auto,490 .layout = .auto,
491 .tag_type = E,491 .tag_type = E,
492 .fields = &.{},492 .fields = &.{},
...@@ -498,7 +498,7 @@ test "Type.Union from empty regular enum" {...@@ -498,7 +498,7 @@ test "Type.Union from empty regular enum" {
498498
499test "Type.Union from empty Type.Enum" {499test "Type.Union from empty Type.Enum" {
500 const E = @Type(.{500 const E = @Type(.{
501 .Enum = .{501 .@"enum" = .{
502 .tag_type = u0,502 .tag_type = u0,
503 .fields = &.{},503 .fields = &.{},
504 .decls = &.{},504 .decls = &.{},
...@@ -506,7 +506,7 @@ test "Type.Union from empty Type.Enum" {...@@ -506,7 +506,7 @@ test "Type.Union from empty Type.Enum" {
506 },506 },
507 });507 });
508 const U = @Type(.{508 const U = @Type(.{
509 .Union = .{509 .@"union" = .{
510 .layout = .auto,510 .layout = .auto,
511 .tag_type = E,511 .tag_type = E,
512 .fields = &.{},512 .fields = &.{},
...@@ -525,7 +525,7 @@ test "Type.Fn" {...@@ -525,7 +525,7 @@ test "Type.Fn" {
525 const T = fn (c_int, some_ptr) callconv(.C) void;525 const T = fn (c_int, some_ptr) callconv(.C) void;
526526
527 {527 {
528 const fn_info = std.builtin.Type{ .Fn = .{528 const fn_info = std.builtin.Type{ .@"fn" = .{
529 .calling_convention = .C,529 .calling_convention = .C,
530 .is_generic = false,530 .is_generic = false,
531 .is_var_args = false,531 .is_var_args = false,
...@@ -551,7 +551,7 @@ test "reified struct field name from optional payload" {...@@ -551,7 +551,7 @@ test "reified struct field name from optional payload" {
551 comptime {551 comptime {
552 const m_name: ?[1:0]u8 = "a".*;552 const m_name: ?[1:0]u8 = "a".*;
553 if (m_name) |*name| {553 if (m_name) |*name| {
554 const T = @Type(.{ .Struct = .{554 const T = @Type(.{ .@"struct" = .{
555 .layout = .auto,555 .layout = .auto,
556 .fields = &.{.{556 .fields = &.{.{
557 .name = name,557 .name = name,
...@@ -573,7 +573,7 @@ test "reified union uses @alignOf" {...@@ -573,7 +573,7 @@ test "reified union uses @alignOf" {
573 const S = struct {573 const S = struct {
574 fn CreateUnion(comptime T: type) type {574 fn CreateUnion(comptime T: type) type {
575 return @Type(.{575 return @Type(.{
576 .Union = .{576 .@"union" = .{
577 .layout = .auto,577 .layout = .auto,
578 .tag_type = null,578 .tag_type = null,
579 .fields = &[_]std.builtin.Type.UnionField{579 .fields = &[_]std.builtin.Type.UnionField{
...@@ -595,7 +595,7 @@ test "reified struct uses @alignOf" {...@@ -595,7 +595,7 @@ test "reified struct uses @alignOf" {
595 const S = struct {595 const S = struct {
596 fn NamespacedGlobals(comptime modules: anytype) type {596 fn NamespacedGlobals(comptime modules: anytype) type {
597 return @Type(.{597 return @Type(.{
598 .Struct = .{598 .@"struct" = .{
599 .layout = .auto,599 .layout = .auto,
600 .is_tuple = false,600 .is_tuple = false,
601 .fields = &.{601 .fields = &.{
...@@ -627,7 +627,7 @@ test "reified error set initialized with field pointer" {...@@ -627,7 +627,7 @@ test "reified error set initialized with field pointer" {
627 },627 },
628 };628 };
629 const Foo = @Type(.{629 const Foo = @Type(.{
630 .ErrorSet = &info.args,630 .error_set = &info.args,
631 });631 });
632 };632 };
633 try testing.expect(S.Foo == error{bar});633 try testing.expect(S.Foo == error{bar});
...@@ -640,7 +640,7 @@ test "reified function type params initialized with field pointer" {...@@ -640,7 +640,7 @@ test "reified function type params initialized with field pointer" {
640 },640 },
641 };641 };
642 const Bar = @Type(.{642 const Bar = @Type(.{
643 .Fn = .{643 .@"fn" = .{
644 .calling_convention = .Unspecified,644 .calling_convention = .Unspecified,
645 .is_generic = false,645 .is_generic = false,
646 .is_var_args = false,646 .is_var_args = false,
...@@ -649,14 +649,14 @@ test "reified function type params initialized with field pointer" {...@@ -649,14 +649,14 @@ test "reified function type params initialized with field pointer" {
649 },649 },
650 });650 });
651 };651 };
652 try testing.expect(@typeInfo(S.Bar) == .Fn);652 try testing.expect(@typeInfo(S.Bar) == .@"fn");
653}653}
654654
655test "empty struct assigned to reified struct field" {655test "empty struct assigned to reified struct field" {
656 const S = struct {656 const S = struct {
657 fn NamespacedComponents(comptime modules: anytype) type {657 fn NamespacedComponents(comptime modules: anytype) type {
658 return @Type(.{658 return @Type(.{
659 .Struct = .{659 .@"struct" = .{
660 .layout = .auto,660 .layout = .auto,
661 .is_tuple = false,661 .is_tuple = false,
662 .fields = &.{.{662 .fields = &.{.{
...@@ -689,7 +689,7 @@ test "@Type should resolve its children types" {...@@ -689,7 +689,7 @@ test "@Type should resolve its children types" {
689 const dense = enum(u2) { a, b, c, d };689 const dense = enum(u2) { a, b, c, d };
690690
691 comptime var sparse_info = @typeInfo(anyerror!sparse);691 comptime var sparse_info = @typeInfo(anyerror!sparse);
692 sparse_info.ErrorUnion.payload = dense;692 sparse_info.error_union.payload = dense;
693 const B = @Type(sparse_info);693 const B = @Type(sparse_info);
694 try testing.expectEqual(anyerror!dense, B);694 try testing.expectEqual(anyerror!dense, B);
695}695}
...@@ -718,7 +718,7 @@ test "struct field names sliced at comptime from larger string" {...@@ -718,7 +718,7 @@ test "struct field names sliced at comptime from larger string" {
718 }718 }
719719
720 const T = @Type(.{720 const T = @Type(.{
721 .Struct = .{721 .@"struct" = .{
722 .layout = .auto,722 .layout = .auto,
723 .is_tuple = false,723 .is_tuple = false,
724 .fields = fields,724 .fields = fields,
...@@ -726,7 +726,7 @@ test "struct field names sliced at comptime from larger string" {...@@ -726,7 +726,7 @@ test "struct field names sliced at comptime from larger string" {
726 },726 },
727 });727 });
728728
729 const gen_fields = @typeInfo(T).Struct.fields;729 const gen_fields = @typeInfo(T).@"struct".fields;
730 try testing.expectEqual(3, gen_fields.len);730 try testing.expectEqual(3, gen_fields.len);
731 try testing.expectEqualStrings("f1", gen_fields[0].name);731 try testing.expectEqualStrings("f1", gen_fields[0].name);
732 try testing.expectEqualStrings("f2", gen_fields[1].name);732 try testing.expectEqualStrings("f2", gen_fields[1].name);
...@@ -737,9 +737,9 @@ test "struct field names sliced at comptime from larger string" {...@@ -737,9 +737,9 @@ test "struct field names sliced at comptime from larger string" {
737test "matching captures causes opaque equivalence" {737test "matching captures causes opaque equivalence" {
738 const S = struct {738 const S = struct {
739 fn UnsignedId(comptime I: type) type {739 fn UnsignedId(comptime I: type) type {
740 const U = @Type(.{ .Int = .{740 const U = @Type(.{ .int = .{
741 .signedness = .unsigned,741 .signedness = .unsigned,
742 .bits = @typeInfo(I).Int.bits,742 .bits = @typeInfo(I).int.bits,
743 } });743 } });
744 return opaque {744 return opaque {
745 fn id(x: U) U {745 fn id(x: U) U {
...@@ -765,7 +765,7 @@ test "reify enum where fields refers to part of array" {...@@ -765,7 +765,7 @@ test "reify enum where fields refers to part of array" {
765 .{ .name = "bar", .value = 1 },765 .{ .name = "bar", .value = 1 },
766 undefined,766 undefined,
767 };767 };
768 const E = @Type(.{ .Enum = .{768 const E = @Type(.{ .@"enum" = .{
769 .tag_type = u8,769 .tag_type = u8,
770 .fields = fields[0..2],770 .fields = fields[0..2],
771 .decls = &.{},771 .decls = &.{},
test/behavior/type_info.zig+175-175
...@@ -16,13 +16,13 @@ test "type info: integer, floating point type info" {...@@ -16,13 +16,13 @@ test "type info: integer, floating point type info" {
1616
17fn testIntFloat() !void {17fn testIntFloat() !void {
18 const u8_info = @typeInfo(u8);18 const u8_info = @typeInfo(u8);
19 try expect(u8_info == .Int);19 try expect(u8_info == .int);
20 try expect(u8_info.Int.signedness == .unsigned);20 try expect(u8_info.int.signedness == .unsigned);
21 try expect(u8_info.Int.bits == 8);21 try expect(u8_info.int.bits == 8);
2222
23 const f64_info = @typeInfo(f64);23 const f64_info = @typeInfo(f64);
24 try expect(f64_info == .Float);24 try expect(f64_info == .float);
25 try expect(f64_info.Float.bits == 64);25 try expect(f64_info.float.bits == 64);
26}26}
2727
28test "type info: optional type info" {28test "type info: optional type info" {
...@@ -32,8 +32,8 @@ test "type info: optional type info" {...@@ -32,8 +32,8 @@ test "type info: optional type info" {
3232
33fn testOptional() !void {33fn testOptional() !void {
34 const null_info = @typeInfo(?void);34 const null_info = @typeInfo(?void);
35 try expect(null_info == .Optional);35 try expect(null_info == .optional);
36 try expect(null_info.Optional.child == void);36 try expect(null_info.optional.child == void);
37}37}
3838
39test "type info: C pointer type info" {39test "type info: C pointer type info" {
...@@ -43,19 +43,19 @@ test "type info: C pointer type info" {...@@ -43,19 +43,19 @@ test "type info: C pointer type info" {
4343
44fn testCPtr() !void {44fn testCPtr() !void {
45 const ptr_info = @typeInfo([*c]align(4) const i8);45 const ptr_info = @typeInfo([*c]align(4) const i8);
46 try expect(ptr_info == .Pointer);46 try expect(ptr_info == .pointer);
47 try expect(ptr_info.Pointer.size == .C);47 try expect(ptr_info.pointer.size == .C);
48 try expect(ptr_info.Pointer.is_const);48 try expect(ptr_info.pointer.is_const);
49 try expect(!ptr_info.Pointer.is_volatile);49 try expect(!ptr_info.pointer.is_volatile);
50 try expect(ptr_info.Pointer.alignment == 4);50 try expect(ptr_info.pointer.alignment == 4);
51 try expect(ptr_info.Pointer.child == i8);51 try expect(ptr_info.pointer.child == i8);
52}52}
5353
54test "type info: value is correctly copied" {54test "type info: value is correctly copied" {
55 comptime {55 comptime {
56 var ptrInfo = @typeInfo([]u32);56 var ptrInfo = @typeInfo([]u32);
57 ptrInfo.Pointer.size = .One;57 ptrInfo.pointer.size = .One;
58 try expect(@typeInfo([]u32).Pointer.size == .Slice);58 try expect(@typeInfo([]u32).pointer.size == .Slice);
59 }59 }
60}60}
6161
...@@ -65,10 +65,10 @@ test "type info: tag type, void info" {...@@ -65,10 +65,10 @@ test "type info: tag type, void info" {
65}65}
6666
67fn testBasic() !void {67fn testBasic() !void {
68 try expect(@typeInfo(Type).Union.tag_type == TypeId);68 try expect(@typeInfo(Type).@"union".tag_type == TypeId);
69 const void_info = @typeInfo(void);69 const void_info = @typeInfo(void);
70 try expect(void_info == TypeId.Void);70 try expect(void_info == TypeId.void);
71 try expect(void_info.Void == {});71 try expect(void_info.void == {});
72}72}
7373
74test "type info: pointer type info" {74test "type info: pointer type info" {
...@@ -78,13 +78,13 @@ test "type info: pointer type info" {...@@ -78,13 +78,13 @@ test "type info: pointer type info" {
7878
79fn testPointer() !void {79fn testPointer() !void {
80 const u32_ptr_info = @typeInfo(*u32);80 const u32_ptr_info = @typeInfo(*u32);
81 try expect(u32_ptr_info == .Pointer);81 try expect(u32_ptr_info == .pointer);
82 try expect(u32_ptr_info.Pointer.size == .One);82 try expect(u32_ptr_info.pointer.size == .One);
83 try expect(u32_ptr_info.Pointer.is_const == false);83 try expect(u32_ptr_info.pointer.is_const == false);
84 try expect(u32_ptr_info.Pointer.is_volatile == false);84 try expect(u32_ptr_info.pointer.is_volatile == false);
85 try expect(u32_ptr_info.Pointer.alignment == @alignOf(u32));85 try expect(u32_ptr_info.pointer.alignment == @alignOf(u32));
86 try expect(u32_ptr_info.Pointer.child == u32);86 try expect(u32_ptr_info.pointer.child == u32);
87 try expect(u32_ptr_info.Pointer.sentinel == null);87 try expect(u32_ptr_info.pointer.sentinel == null);
88}88}
8989
90test "type info: unknown length pointer type info" {90test "type info: unknown length pointer type info" {
...@@ -94,13 +94,13 @@ test "type info: unknown length pointer type info" {...@@ -94,13 +94,13 @@ test "type info: unknown length pointer type info" {
9494
95fn testUnknownLenPtr() !void {95fn testUnknownLenPtr() !void {
96 const u32_ptr_info = @typeInfo([*]const volatile f64);96 const u32_ptr_info = @typeInfo([*]const volatile f64);
97 try expect(u32_ptr_info == .Pointer);97 try expect(u32_ptr_info == .pointer);
98 try expect(u32_ptr_info.Pointer.size == .Many);98 try expect(u32_ptr_info.pointer.size == .Many);
99 try expect(u32_ptr_info.Pointer.is_const == true);99 try expect(u32_ptr_info.pointer.is_const == true);
100 try expect(u32_ptr_info.Pointer.is_volatile == true);100 try expect(u32_ptr_info.pointer.is_volatile == true);
101 try expect(u32_ptr_info.Pointer.sentinel == null);101 try expect(u32_ptr_info.pointer.sentinel == null);
102 try expect(u32_ptr_info.Pointer.alignment == @alignOf(f64));102 try expect(u32_ptr_info.pointer.alignment == @alignOf(f64));
103 try expect(u32_ptr_info.Pointer.child == f64);103 try expect(u32_ptr_info.pointer.child == f64);
104}104}
105105
106test "type info: null terminated pointer type info" {106test "type info: null terminated pointer type info" {
...@@ -110,13 +110,13 @@ test "type info: null terminated pointer type info" {...@@ -110,13 +110,13 @@ test "type info: null terminated pointer type info" {
110110
111fn testNullTerminatedPtr() !void {111fn testNullTerminatedPtr() !void {
112 const ptr_info = @typeInfo([*:0]u8);112 const ptr_info = @typeInfo([*:0]u8);
113 try expect(ptr_info == .Pointer);113 try expect(ptr_info == .pointer);
114 try expect(ptr_info.Pointer.size == .Many);114 try expect(ptr_info.pointer.size == .Many);
115 try expect(ptr_info.Pointer.is_const == false);115 try expect(ptr_info.pointer.is_const == false);
116 try expect(ptr_info.Pointer.is_volatile == false);116 try expect(ptr_info.pointer.is_volatile == false);
117 try expect(@as(*const u8, @ptrCast(ptr_info.Pointer.sentinel.?)).* == 0);117 try expect(@as(*const u8, @ptrCast(ptr_info.pointer.sentinel.?)).* == 0);
118118
119 try expect(@typeInfo([:0]u8).Pointer.sentinel != null);119 try expect(@typeInfo([:0]u8).pointer.sentinel != null);
120}120}
121121
122test "type info: slice type info" {122test "type info: slice type info" {
...@@ -126,12 +126,12 @@ test "type info: slice type info" {...@@ -126,12 +126,12 @@ test "type info: slice type info" {
126126
127fn testSlice() !void {127fn testSlice() !void {
128 const u32_slice_info = @typeInfo([]u32);128 const u32_slice_info = @typeInfo([]u32);
129 try expect(u32_slice_info == .Pointer);129 try expect(u32_slice_info == .pointer);
130 try expect(u32_slice_info.Pointer.size == .Slice);130 try expect(u32_slice_info.pointer.size == .Slice);
131 try expect(u32_slice_info.Pointer.is_const == false);131 try expect(u32_slice_info.pointer.is_const == false);
132 try expect(u32_slice_info.Pointer.is_volatile == false);132 try expect(u32_slice_info.pointer.is_volatile == false);
133 try expect(u32_slice_info.Pointer.alignment == 4);133 try expect(u32_slice_info.pointer.alignment == 4);
134 try expect(u32_slice_info.Pointer.child == u32);134 try expect(u32_slice_info.pointer.child == u32);
135}135}
136136
137test "type info: array type info" {137test "type info: array type info" {
...@@ -142,18 +142,18 @@ test "type info: array type info" {...@@ -142,18 +142,18 @@ test "type info: array type info" {
142fn testArray() !void {142fn testArray() !void {
143 {143 {
144 const info = @typeInfo([42]u8);144 const info = @typeInfo([42]u8);
145 try expect(info == .Array);145 try expect(info == .array);
146 try expect(info.Array.len == 42);146 try expect(info.array.len == 42);
147 try expect(info.Array.child == u8);147 try expect(info.array.child == u8);
148 try expect(info.Array.sentinel == null);148 try expect(info.array.sentinel == null);
149 }149 }
150150
151 {151 {
152 const info = @typeInfo([10:0]u8);152 const info = @typeInfo([10:0]u8);
153 try expect(info.Array.len == 10);153 try expect(info.array.len == 10);
154 try expect(info.Array.child == u8);154 try expect(info.array.child == u8);
155 try expect(@as(*const u8, @ptrCast(info.Array.sentinel.?)).* == @as(u8, 0));155 try expect(@as(*const u8, @ptrCast(info.array.sentinel.?)).* == @as(u8, 0));
156 try expect(@sizeOf([10:0]u8) == info.Array.len + 1);156 try expect(@sizeOf([10:0]u8) == info.array.len + 1);
157 }157 }
158}158}
159159
...@@ -174,18 +174,18 @@ fn testErrorSet() !void {...@@ -174,18 +174,18 @@ fn testErrorSet() !void {
174 };174 };
175175
176 const error_set_info = @typeInfo(TestErrorSet);176 const error_set_info = @typeInfo(TestErrorSet);
177 try expect(error_set_info == .ErrorSet);177 try expect(error_set_info == .error_set);
178 try expect(error_set_info.ErrorSet.?.len == 3);178 try expect(error_set_info.error_set.?.len == 3);
179 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "First"));179 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "First"));
180180
181 const error_union_info = @typeInfo(TestErrorSet!usize);181 const error_union_info = @typeInfo(TestErrorSet!usize);
182 try expect(error_union_info == .ErrorUnion);182 try expect(error_union_info == .error_union);
183 try expect(error_union_info.ErrorUnion.error_set == TestErrorSet);183 try expect(error_union_info.error_union.error_set == TestErrorSet);
184 try expect(error_union_info.ErrorUnion.payload == usize);184 try expect(error_union_info.error_union.payload == usize);
185185
186 const global_info = @typeInfo(anyerror);186 const global_info = @typeInfo(anyerror);
187 try expect(global_info == .ErrorSet);187 try expect(global_info == .error_set);
188 try expect(global_info.ErrorSet == null);188 try expect(global_info.error_set == null);
189}189}
190190
191test "type info: error set single value" {191test "type info: error set single value" {
...@@ -196,9 +196,9 @@ test "type info: error set single value" {...@@ -196,9 +196,9 @@ test "type info: error set single value" {
196 const TestSet = error.One;196 const TestSet = error.One;
197197
198 const error_set_info = @typeInfo(@TypeOf(TestSet));198 const error_set_info = @typeInfo(@TypeOf(TestSet));
199 try expect(error_set_info == .ErrorSet);199 try expect(error_set_info == .error_set);
200 try expect(error_set_info.ErrorSet.?.len == 1);200 try expect(error_set_info.error_set.?.len == 1);
201 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));201 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
202}202}
203203
204test "type info: error set merged" {204test "type info: error set merged" {
...@@ -209,11 +209,11 @@ test "type info: error set merged" {...@@ -209,11 +209,11 @@ test "type info: error set merged" {
209 const TestSet = error{ One, Two } || error{Three};209 const TestSet = error{ One, Two } || error{Three};
210210
211 const error_set_info = @typeInfo(TestSet);211 const error_set_info = @typeInfo(TestSet);
212 try expect(error_set_info == .ErrorSet);212 try expect(error_set_info == .error_set);
213 try expect(error_set_info.ErrorSet.?.len == 3);213 try expect(error_set_info.error_set.?.len == 3);
214 try expect(mem.eql(u8, error_set_info.ErrorSet.?[0].name, "One"));214 try expect(mem.eql(u8, error_set_info.error_set.?[0].name, "One"));
215 try expect(mem.eql(u8, error_set_info.ErrorSet.?[1].name, "Two"));215 try expect(mem.eql(u8, error_set_info.error_set.?[1].name, "Two"));
216 try expect(mem.eql(u8, error_set_info.ErrorSet.?[2].name, "Three"));216 try expect(mem.eql(u8, error_set_info.error_set.?[2].name, "Three"));
217}217}
218218
219test "type info: enum info" {219test "type info: enum info" {
...@@ -234,12 +234,12 @@ fn testEnum() !void {...@@ -234,12 +234,12 @@ fn testEnum() !void {
234 };234 };
235235
236 const os_info = @typeInfo(Os);236 const os_info = @typeInfo(Os);
237 try expect(os_info == .Enum);237 try expect(os_info == .@"enum");
238 try expect(os_info.Enum.fields.len == 4);238 try expect(os_info.@"enum".fields.len == 4);
239 try expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos"));239 try expect(mem.eql(u8, os_info.@"enum".fields[1].name, "Macos"));
240 try expect(os_info.Enum.fields[3].value == 3);240 try expect(os_info.@"enum".fields[3].value == 3);
241 try expect(os_info.Enum.tag_type == u2);241 try expect(os_info.@"enum".tag_type == u2);
242 try expect(os_info.Enum.decls.len == 0);242 try expect(os_info.@"enum".decls.len == 0);
243}243}
244244
245test "type info: union info" {245test "type info: union info" {
...@@ -249,12 +249,12 @@ test "type info: union info" {...@@ -249,12 +249,12 @@ test "type info: union info" {
249249
250fn testUnion() !void {250fn testUnion() !void {
251 const typeinfo_info = @typeInfo(Type);251 const typeinfo_info = @typeInfo(Type);
252 try expect(typeinfo_info == .Union);252 try expect(typeinfo_info == .@"union");
253 try expect(typeinfo_info.Union.layout == .auto);253 try expect(typeinfo_info.@"union".layout == .auto);
254 try expect(typeinfo_info.Union.tag_type.? == TypeId);254 try expect(typeinfo_info.@"union".tag_type.? == TypeId);
255 try expect(typeinfo_info.Union.fields.len == 24);255 try expect(typeinfo_info.@"union".fields.len == 24);
256 try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int));256 try expect(typeinfo_info.@"union".fields[4].type == @TypeOf(@typeInfo(u8).int));
257 try expect(typeinfo_info.Union.decls.len == 21);257 try expect(typeinfo_info.@"union".decls.len == 21);
258258
259 const TestNoTagUnion = union {259 const TestNoTagUnion = union {
260 Foo: void,260 Foo: void,
...@@ -262,22 +262,22 @@ fn testUnion() !void {...@@ -262,22 +262,22 @@ fn testUnion() !void {
262 };262 };
263263
264 const notag_union_info = @typeInfo(TestNoTagUnion);264 const notag_union_info = @typeInfo(TestNoTagUnion);
265 try expect(notag_union_info == .Union);265 try expect(notag_union_info == .@"union");
266 try expect(notag_union_info.Union.tag_type == null);266 try expect(notag_union_info.@"union".tag_type == null);
267 try expect(notag_union_info.Union.layout == .auto);267 try expect(notag_union_info.@"union".layout == .auto);
268 try expect(notag_union_info.Union.fields.len == 2);268 try expect(notag_union_info.@"union".fields.len == 2);
269 try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void));269 try expect(notag_union_info.@"union".fields[0].alignment == @alignOf(void));
270 try expect(notag_union_info.Union.fields[1].type == u32);270 try expect(notag_union_info.@"union".fields[1].type == u32);
271 try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32));271 try expect(notag_union_info.@"union".fields[1].alignment == @alignOf(u32));
272272
273 const TestExternUnion = extern union {273 const TestExternUnion = extern union {
274 foo: *anyopaque,274 foo: *anyopaque,
275 };275 };
276276
277 const extern_union_info = @typeInfo(TestExternUnion);277 const extern_union_info = @typeInfo(TestExternUnion);
278 try expect(extern_union_info.Union.layout == .@"extern");278 try expect(extern_union_info.@"union".layout == .@"extern");
279 try expect(extern_union_info.Union.tag_type == null);279 try expect(extern_union_info.@"union".tag_type == null);
280 try expect(extern_union_info.Union.fields[0].type == *anyopaque);280 try expect(extern_union_info.@"union".fields[0].type == *anyopaque);
281}281}
282282
283test "type info: struct info" {283test "type info: struct info" {
...@@ -289,11 +289,11 @@ test "type info: struct info" {...@@ -289,11 +289,11 @@ test "type info: struct info" {
289289
290fn testStruct() !void {290fn testStruct() !void {
291 const unpacked_struct_info = @typeInfo(TestStruct);291 const unpacked_struct_info = @typeInfo(TestStruct);
292 try expect(unpacked_struct_info.Struct.is_tuple == false);292 try expect(unpacked_struct_info.@"struct".is_tuple == false);
293 try expect(unpacked_struct_info.Struct.backing_integer == null);293 try expect(unpacked_struct_info.@"struct".backing_integer == null);
294 try expect(unpacked_struct_info.Struct.fields[0].alignment == @alignOf(u32));294 try expect(unpacked_struct_info.@"struct".fields[0].alignment == @alignOf(u32));
295 try expect(@as(*align(1) const u32, @ptrCast(unpacked_struct_info.Struct.fields[0].default_value.?)).* == 4);295 try expect(@as(*align(1) const u32, @ptrCast(unpacked_struct_info.@"struct".fields[0].default_value.?)).* == 4);
296 try expect(mem.eql(u8, "foobar", @as(*align(1) const *const [6:0]u8, @ptrCast(unpacked_struct_info.Struct.fields[1].default_value.?)).*));296 try expect(mem.eql(u8, "foobar", @as(*align(1) const *const [6:0]u8, @ptrCast(unpacked_struct_info.@"struct".fields[1].default_value.?)).*));
297}297}
298298
299const TestStruct = struct {299const TestStruct = struct {
...@@ -308,17 +308,17 @@ test "type info: packed struct info" {...@@ -308,17 +308,17 @@ test "type info: packed struct info" {
308308
309fn testPackedStruct() !void {309fn testPackedStruct() !void {
310 const struct_info = @typeInfo(TestPackedStruct);310 const struct_info = @typeInfo(TestPackedStruct);
311 try expect(struct_info == .Struct);311 try expect(struct_info == .@"struct");
312 try expect(struct_info.Struct.is_tuple == false);312 try expect(struct_info.@"struct".is_tuple == false);
313 try expect(struct_info.Struct.layout == .@"packed");313 try expect(struct_info.@"struct".layout == .@"packed");
314 try expect(struct_info.Struct.backing_integer == u128);314 try expect(struct_info.@"struct".backing_integer == u128);
315 try expect(struct_info.Struct.fields.len == 4);315 try expect(struct_info.@"struct".fields.len == 4);
316 try expect(struct_info.Struct.fields[0].alignment == 0);316 try expect(struct_info.@"struct".fields[0].alignment == 0);
317 try expect(struct_info.Struct.fields[2].type == f32);317 try expect(struct_info.@"struct".fields[2].type == f32);
318 try expect(struct_info.Struct.fields[2].default_value == null);318 try expect(struct_info.@"struct".fields[2].default_value == null);
319 try expect(@as(*align(1) const u32, @ptrCast(struct_info.Struct.fields[3].default_value.?)).* == 4);319 try expect(@as(*align(1) const u32, @ptrCast(struct_info.@"struct".fields[3].default_value.?)).* == 4);
320 try expect(struct_info.Struct.fields[3].alignment == 0);320 try expect(struct_info.@"struct".fields[3].alignment == 0);
321 try expect(struct_info.Struct.decls.len == 1);321 try expect(struct_info.@"struct".decls.len == 1);
322}322}
323323
324const TestPackedStruct = packed struct {324const TestPackedStruct = packed struct {
...@@ -345,7 +345,7 @@ fn testOpaque() !void {...@@ -345,7 +345,7 @@ fn testOpaque() !void {
345 };345 };
346346
347 const foo_info = @typeInfo(Foo);347 const foo_info = @typeInfo(Foo);
348 try expect(foo_info.Opaque.decls.len == 2);348 try expect(foo_info.@"opaque".decls.len == 2);
349}349}
350350
351test "type info: function type info" {351test "type info: function type info" {
...@@ -358,36 +358,36 @@ test "type info: function type info" {...@@ -358,36 +358,36 @@ test "type info: function type info" {
358fn testFunction() !void {358fn testFunction() !void {
359 const foo_fn_type = @TypeOf(typeInfoFoo);359 const foo_fn_type = @TypeOf(typeInfoFoo);
360 const foo_fn_info = @typeInfo(foo_fn_type);360 const foo_fn_info = @typeInfo(foo_fn_type);
361 try expect(foo_fn_info.Fn.calling_convention == .C);361 try expect(foo_fn_info.@"fn".calling_convention == .C);
362 try expect(!foo_fn_info.Fn.is_generic);362 try expect(!foo_fn_info.@"fn".is_generic);
363 try expect(foo_fn_info.Fn.params.len == 2);363 try expect(foo_fn_info.@"fn".params.len == 2);
364 try expect(foo_fn_info.Fn.is_var_args);364 try expect(foo_fn_info.@"fn".is_var_args);
365 try expect(foo_fn_info.Fn.return_type.? == usize);365 try expect(foo_fn_info.@"fn".return_type.? == usize);
366 const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo));366 const foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFoo));
367 try expect(foo_ptr_fn_info.Pointer.size == .One);367 try expect(foo_ptr_fn_info.pointer.size == .One);
368 try expect(foo_ptr_fn_info.Pointer.is_const);368 try expect(foo_ptr_fn_info.pointer.is_const);
369 try expect(!foo_ptr_fn_info.Pointer.is_volatile);369 try expect(!foo_ptr_fn_info.pointer.is_volatile);
370 try expect(foo_ptr_fn_info.Pointer.address_space == .generic);370 try expect(foo_ptr_fn_info.pointer.address_space == .generic);
371 try expect(foo_ptr_fn_info.Pointer.child == foo_fn_type);371 try expect(foo_ptr_fn_info.pointer.child == foo_fn_type);
372 try expect(!foo_ptr_fn_info.Pointer.is_allowzero);372 try expect(!foo_ptr_fn_info.pointer.is_allowzero);
373 try expect(foo_ptr_fn_info.Pointer.sentinel == null);373 try expect(foo_ptr_fn_info.pointer.sentinel == null);
374374
375 const aligned_foo_fn_type = @TypeOf(typeInfoFooAligned);375 const aligned_foo_fn_type = @TypeOf(typeInfoFooAligned);
376 const aligned_foo_fn_info = @typeInfo(aligned_foo_fn_type);376 const aligned_foo_fn_info = @typeInfo(aligned_foo_fn_type);
377 try expect(aligned_foo_fn_info.Fn.calling_convention == .C);377 try expect(aligned_foo_fn_info.@"fn".calling_convention == .C);
378 try expect(!aligned_foo_fn_info.Fn.is_generic);378 try expect(!aligned_foo_fn_info.@"fn".is_generic);
379 try expect(aligned_foo_fn_info.Fn.params.len == 2);379 try expect(aligned_foo_fn_info.@"fn".params.len == 2);
380 try expect(aligned_foo_fn_info.Fn.is_var_args);380 try expect(aligned_foo_fn_info.@"fn".is_var_args);
381 try expect(aligned_foo_fn_info.Fn.return_type.? == usize);381 try expect(aligned_foo_fn_info.@"fn".return_type.? == usize);
382 const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned));382 const aligned_foo_ptr_fn_info = @typeInfo(@TypeOf(&typeInfoFooAligned));
383 try expect(aligned_foo_ptr_fn_info.Pointer.size == .One);383 try expect(aligned_foo_ptr_fn_info.pointer.size == .One);
384 try expect(aligned_foo_ptr_fn_info.Pointer.is_const);384 try expect(aligned_foo_ptr_fn_info.pointer.is_const);
385 try expect(!aligned_foo_ptr_fn_info.Pointer.is_volatile);385 try expect(!aligned_foo_ptr_fn_info.pointer.is_volatile);
386 try expect(aligned_foo_ptr_fn_info.Pointer.alignment == 4);386 try expect(aligned_foo_ptr_fn_info.pointer.alignment == 4);
387 try expect(aligned_foo_ptr_fn_info.Pointer.address_space == .generic);387 try expect(aligned_foo_ptr_fn_info.pointer.address_space == .generic);
388 try expect(aligned_foo_ptr_fn_info.Pointer.child == aligned_foo_fn_type);388 try expect(aligned_foo_ptr_fn_info.pointer.child == aligned_foo_fn_type);
389 try expect(!aligned_foo_ptr_fn_info.Pointer.is_allowzero);389 try expect(!aligned_foo_ptr_fn_info.pointer.is_allowzero);
390 try expect(aligned_foo_ptr_fn_info.Pointer.sentinel == null);390 try expect(aligned_foo_ptr_fn_info.pointer.sentinel == null);
391}391}
392392
393extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.C) usize;393extern fn typeInfoFoo(a: usize, b: bool, ...) callconv(.C) usize;
...@@ -395,32 +395,32 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize...@@ -395,32 +395,32 @@ extern fn typeInfoFooAligned(a: usize, b: bool, ...) align(4) callconv(.C) usize
395395
396test "type info: generic function types" {396test "type info: generic function types" {
397 const G1 = @typeInfo(@TypeOf(generic1));397 const G1 = @typeInfo(@TypeOf(generic1));
398 try expect(G1.Fn.params.len == 1);398 try expect(G1.@"fn".params.len == 1);
399 try expect(G1.Fn.params[0].is_generic == true);399 try expect(G1.@"fn".params[0].is_generic == true);
400 try expect(G1.Fn.params[0].type == null);400 try expect(G1.@"fn".params[0].type == null);
401 try expect(G1.Fn.return_type == void);401 try expect(G1.@"fn".return_type == void);
402402
403 const G2 = @typeInfo(@TypeOf(generic2));403 const G2 = @typeInfo(@TypeOf(generic2));
404 try expect(G2.Fn.params.len == 3);404 try expect(G2.@"fn".params.len == 3);
405 try expect(G2.Fn.params[0].is_generic == false);405 try expect(G2.@"fn".params[0].is_generic == false);
406 try expect(G2.Fn.params[0].type == type);406 try expect(G2.@"fn".params[0].type == type);
407 try expect(G2.Fn.params[1].is_generic == true);407 try expect(G2.@"fn".params[1].is_generic == true);
408 try expect(G2.Fn.params[1].type == null);408 try expect(G2.@"fn".params[1].type == null);
409 try expect(G2.Fn.params[2].is_generic == false);409 try expect(G2.@"fn".params[2].is_generic == false);
410 try expect(G2.Fn.params[2].type == u8);410 try expect(G2.@"fn".params[2].type == u8);
411 try expect(G2.Fn.return_type == void);411 try expect(G2.@"fn".return_type == void);
412412
413 const G3 = @typeInfo(@TypeOf(generic3));413 const G3 = @typeInfo(@TypeOf(generic3));
414 try expect(G3.Fn.params.len == 1);414 try expect(G3.@"fn".params.len == 1);
415 try expect(G3.Fn.params[0].is_generic == true);415 try expect(G3.@"fn".params[0].is_generic == true);
416 try expect(G3.Fn.params[0].type == null);416 try expect(G3.@"fn".params[0].type == null);
417 try expect(G3.Fn.return_type == null);417 try expect(G3.@"fn".return_type == null);
418418
419 const G4 = @typeInfo(@TypeOf(generic4));419 const G4 = @typeInfo(@TypeOf(generic4));
420 try expect(G4.Fn.params.len == 1);420 try expect(G4.@"fn".params.len == 1);
421 try expect(G4.Fn.params[0].is_generic == true);421 try expect(G4.@"fn".params[0].is_generic == true);
422 try expect(G4.Fn.params[0].type == null);422 try expect(G4.@"fn".params[0].type == null);
423 try expect(G4.Fn.return_type == null);423 try expect(G4.@"fn".return_type == null);
424}424}
425425
426fn generic1(param: anytype) void {426fn generic1(param: anytype) void {
...@@ -450,9 +450,9 @@ test "type info: vectors" {...@@ -450,9 +450,9 @@ test "type info: vectors" {
450450
451fn testVector() !void {451fn testVector() !void {
452 const vec_info = @typeInfo(@Vector(4, i32));452 const vec_info = @typeInfo(@Vector(4, i32));
453 try expect(vec_info == .Vector);453 try expect(vec_info == .vector);
454 try expect(vec_info.Vector.len == 4);454 try expect(vec_info.vector.len == 4);
455 try expect(vec_info.Vector.child == i32);455 try expect(vec_info.vector.child == i32);
456}456}
457457
458test "type info: anyframe and anyframe->T" {458test "type info: anyframe and anyframe->T" {
...@@ -468,14 +468,14 @@ test "type info: anyframe and anyframe->T" {...@@ -468,14 +468,14 @@ test "type info: anyframe and anyframe->T" {
468fn testAnyFrame() !void {468fn testAnyFrame() !void {
469 {469 {
470 const anyframe_info = @typeInfo(anyframe->i32);470 const anyframe_info = @typeInfo(anyframe->i32);
471 try expect(anyframe_info == .AnyFrame);471 try expect(anyframe_info == .@"anyframe");
472 try expect(anyframe_info.AnyFrame.child.? == i32);472 try expect(anyframe_info.@"anyframe".child.? == i32);
473 }473 }
474474
475 {475 {
476 const anyframe_info = @typeInfo(anyframe);476 const anyframe_info = @typeInfo(anyframe);
477 try expect(anyframe_info == .AnyFrame);477 try expect(anyframe_info == .@"anyframe");
478 try expect(anyframe_info.AnyFrame.child == null);478 try expect(anyframe_info.@"anyframe".child == null);
479 }479 }
480}480}
481481
...@@ -490,13 +490,13 @@ fn passTypeInfo(comptime info: Type) type {...@@ -490,13 +490,13 @@ fn passTypeInfo(comptime info: Type) type {
490}490}
491491
492test "type info: TypeId -> Type impl cast" {492test "type info: TypeId -> Type impl cast" {
493 _ = passTypeInfo(TypeId.Void);493 _ = passTypeInfo(TypeId.void);
494 _ = comptime passTypeInfo(TypeId.Void);494 _ = comptime passTypeInfo(TypeId.void);
495}495}
496496
497test "sentinel of opaque pointer type" {497test "sentinel of opaque pointer type" {
498 const c_void_info = @typeInfo(*anyopaque);498 const c_void_info = @typeInfo(*anyopaque);
499 try expect(c_void_info.Pointer.sentinel == null);499 try expect(c_void_info.pointer.sentinel == null);
500}500}
501501
502test "@typeInfo does not force declarations into existence" {502test "@typeInfo does not force declarations into existence" {
...@@ -507,7 +507,7 @@ test "@typeInfo does not force declarations into existence" {...@@ -507,7 +507,7 @@ test "@typeInfo does not force declarations into existence" {
507 @compileError("test failed");507 @compileError("test failed");
508 }508 }
509 };509 };
510 comptime assert(@typeInfo(S).Struct.fields.len == 1);510 comptime assert(@typeInfo(S).@"struct".fields.len == 1);
511}511}
512512
513fn add(a: i32, b: i32) i32 {513fn add(a: i32, b: i32) i32 {
...@@ -521,7 +521,7 @@ test "type info for async frames" {...@@ -521,7 +521,7 @@ test "type info for async frames" {
521 }521 }
522522
523 switch (@typeInfo(@Frame(add))) {523 switch (@typeInfo(@Frame(add))) {
524 .Frame => |frame| {524 .frame => |frame| {
525 try expect(@as(@TypeOf(add), @ptrCast(frame.function)) == add);525 try expect(@as(@TypeOf(add), @ptrCast(frame.function)) == add);
526 },526 },
527 else => unreachable,527 else => unreachable,
...@@ -538,7 +538,7 @@ test "Declarations are returned in declaration order" {...@@ -538,7 +538,7 @@ test "Declarations are returned in declaration order" {
538 pub const d = 4;538 pub const d = 4;
539 pub const e = 5;539 pub const e = 5;
540 };540 };
541 const d = @typeInfo(S).Struct.decls;541 const d = @typeInfo(S).@"struct".decls;
542 try expect(std.mem.eql(u8, d[0].name, "a"));542 try expect(std.mem.eql(u8, d[0].name, "a"));
543 try expect(std.mem.eql(u8, d[1].name, "b"));543 try expect(std.mem.eql(u8, d[1].name, "b"));
544 try expect(std.mem.eql(u8, d[2].name, "c"));544 try expect(std.mem.eql(u8, d[2].name, "c"));
...@@ -547,19 +547,19 @@ test "Declarations are returned in declaration order" {...@@ -547,19 +547,19 @@ test "Declarations are returned in declaration order" {
547}547}
548548
549test "Struct.is_tuple for anon list literal" {549test "Struct.is_tuple for anon list literal" {
550 try expect(@typeInfo(@TypeOf(.{0})).Struct.is_tuple);550 try expect(@typeInfo(@TypeOf(.{0})).@"struct".is_tuple);
551}551}
552552
553test "Struct.is_tuple for anon struct literal" {553test "Struct.is_tuple for anon struct literal" {
554 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO554 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
555555
556 const info = @typeInfo(@TypeOf(.{ .a = 0 }));556 const info = @typeInfo(@TypeOf(.{ .a = 0 }));
557 try expect(!info.Struct.is_tuple);557 try expect(!info.@"struct".is_tuple);
558 try expect(std.mem.eql(u8, info.Struct.fields[0].name, "a"));558 try expect(std.mem.eql(u8, info.@"struct".fields[0].name, "a"));
559}559}
560560
561test "StructField.is_comptime" {561test "StructField.is_comptime" {
562 const info = @typeInfo(struct { x: u8 = 3, comptime y: u32 = 5 }).Struct;562 const info = @typeInfo(struct { x: u8 = 3, comptime y: u32 = 5 }).@"struct";
563 try expect(!info.fields[0].is_comptime);563 try expect(!info.fields[0].is_comptime);
564 try expect(info.fields[1].is_comptime);564 try expect(info.fields[1].is_comptime);
565}565}
...@@ -574,7 +574,7 @@ test "typeInfo resolves usingnamespace declarations" {...@@ -574,7 +574,7 @@ test "typeInfo resolves usingnamespace declarations" {
574 pub usingnamespace A;574 pub usingnamespace A;
575 };575 };
576576
577 const decls = @typeInfo(B).Struct.decls;577 const decls = @typeInfo(B).@"struct".decls;
578 try expect(decls.len == 2);578 try expect(decls.len == 2);
579 try expectEqualStrings(decls[0].name, "f0");579 try expectEqualStrings(decls[0].name, "f0");
580 try expectEqualStrings(decls[1].name, "f1");580 try expectEqualStrings(decls[1].name, "f1");
...@@ -582,7 +582,7 @@ test "typeInfo resolves usingnamespace declarations" {...@@ -582,7 +582,7 @@ test "typeInfo resolves usingnamespace declarations" {
582582
583test "value from struct @typeInfo default_value can be loaded at comptime" {583test "value from struct @typeInfo default_value can be loaded at comptime" {
584 comptime {584 comptime {
585 const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).Struct.fields[0].default_value;585 const a = @typeInfo(@TypeOf(.{ .foo = @as(u8, 1) })).@"struct".fields[0].default_value;
586 try expect(@as(*const u8, @ptrCast(a)).* == 1);586 try expect(@as(*const u8, @ptrCast(a)).* == 1);
587 }587 }
588}588}
...@@ -603,7 +603,7 @@ test "@typeInfo decls and usingnamespace" {...@@ -603,7 +603,7 @@ test "@typeInfo decls and usingnamespace" {
603603
604 test {}604 test {}
605 };605 };
606 const decls = @typeInfo(B).Struct.decls;606 const decls = @typeInfo(B).@"struct".decls;
607 try expect(decls.len == 3);607 try expect(decls.len == 3);
608 try expectEqualStrings(decls[0].name, "z");608 try expectEqualStrings(decls[0].name, "z");
609 try expectEqualStrings(decls[1].name, "x");609 try expectEqualStrings(decls[1].name, "x");
...@@ -613,7 +613,7 @@ test "@typeInfo decls and usingnamespace" {...@@ -613,7 +613,7 @@ test "@typeInfo decls and usingnamespace" {
613test "@typeInfo decls ignore dependency loops" {613test "@typeInfo decls ignore dependency loops" {
614 const S = struct {614 const S = struct {
615 pub fn Def(comptime T: type) type {615 pub fn Def(comptime T: type) type {
616 std.debug.assert(@typeInfo(T).Struct.decls.len == 1);616 std.debug.assert(@typeInfo(T).@"struct".decls.len == 1);
617 return struct {617 return struct {
618 const foo = u32;618 const foo = u32;
619 };619 };
...@@ -624,7 +624,7 @@ test "@typeInfo decls ignore dependency loops" {...@@ -624,7 +624,7 @@ test "@typeInfo decls ignore dependency loops" {
624}624}
625625
626test "type info of tuple of string literal default value" {626test "type info of tuple of string literal default value" {
627 const struct_field = @typeInfo(@TypeOf(.{"hi"})).Struct.fields[0];627 const struct_field = @typeInfo(@TypeOf(.{"hi"})).@"struct".fields[0];
628 const value = @as(*align(1) const *const [2:0]u8, @ptrCast(struct_field.default_value.?)).*;628 const value = @as(*align(1) const *const [2:0]u8, @ptrCast(struct_field.default_value.?)).*;
629 comptime std.debug.assert(value[0] == 'h');629 comptime std.debug.assert(value[0] == 'h');
630}630}
...@@ -648,7 +648,7 @@ test "@typeInfo only contains pub decls" {...@@ -648,7 +648,7 @@ test "@typeInfo only contains pub decls" {
648 };648 };
649 };649 };
650 const ti = @typeInfo(other);650 const ti = @typeInfo(other);
651 const decls = ti.Struct.decls;651 const decls = ti.@"struct".decls;
652652
653 try std.testing.expectEqual(2, decls.len);653 try std.testing.expectEqual(2, decls.len);
654 try std.testing.expectEqualStrings("Enum", decls[0].name);654 try std.testing.expectEqualStrings("Enum", decls[0].name);
test/behavior/type_info_mul_linksection_addrspace_decls.zig+1-1
...@@ -7,6 +7,6 @@ pub const c addrspace("space_c") = 0;...@@ -7,6 +7,6 @@ pub const c addrspace("space_c") = 0;
7pub const d addrspace("space_d") = 0;7pub const d addrspace("space_d") = 0;
88
9test {9test {
10 const decls = @typeInfo(@This()).Struct.decls;10 const decls = @typeInfo(@This()).@"struct".decls;
11 try expect(decls.len == 4);11 try expect(decls.len == 4);
12}12}
test/behavior/typename.zig+1-1
...@@ -110,7 +110,7 @@ test "top level decl" {...@@ -110,7 +110,7 @@ test "top level decl" {
110 );110 );
111 // regular fn inside struct, with error111 // regular fn inside struct, with error
112 try expectEqualStrings(112 try expectEqualStrings(
113 "fn () @typeInfo(@typeInfo(@TypeOf(behavior.typename.B.doTest)).Fn.return_type.?).ErrorUnion.error_set!void",113 "fn () @typeInfo(@typeInfo(@TypeOf(behavior.typename.B.doTest)).@\"fn\".return_type.?).error_union.error_set!void",
114 @typeName(@TypeOf(B.doTest)),114 @typeName(@TypeOf(B.doTest)),
115 );115 );
116 // generic fn116 // generic fn
test/behavior/union.zig+6-6
...@@ -479,7 +479,7 @@ test "global union with single field is correctly initialized" {...@@ -479,7 +479,7 @@ test "global union with single field is correctly initialized" {
479 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO479 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
480480
481 glbl = Foo1{481 glbl = Foo1{
482 .f = @typeInfo(Foo1).Union.fields[0].type{ .x = 123 },482 .f = @typeInfo(Foo1).@"union".fields[0].type{ .x = 123 },
483 };483 };
484 try expect(glbl.f.x == 123);484 try expect(glbl.f.x == 123);
485}485}
...@@ -600,8 +600,8 @@ test "tagged union type" {...@@ -600,8 +600,8 @@ test "tagged union type" {
600 const baz = Baz.B;600 const baz = Baz.B;
601601
602 try expect(baz == Baz.B);602 try expect(baz == Baz.B);
603 try expect(@typeInfo(TaggedFoo).Union.fields.len == 3);603 try expect(@typeInfo(TaggedFoo).@"union".fields.len == 3);
604 try expect(@typeInfo(Baz).Enum.fields.len == 4);604 try expect(@typeInfo(Baz).@"enum".fields.len == 4);
605 try expect(@sizeOf(TaggedFoo) == @sizeOf(FooNoVoid));605 try expect(@sizeOf(TaggedFoo) == @sizeOf(FooNoVoid));
606 try expect(@sizeOf(Baz) == 1);606 try expect(@sizeOf(Baz) == 1);
607}607}
...@@ -2305,13 +2305,13 @@ test "create union(enum) from other union(enum)" {...@@ -2305,13 +2305,13 @@ test "create union(enum) from other union(enum)" {
2305test "matching captures causes union equivalence" {2305test "matching captures causes union equivalence" {
2306 const S = struct {2306 const S = struct {
2307 fn SignedUnsigned(comptime I: type) type {2307 fn SignedUnsigned(comptime I: type) type {
2308 const bits = @typeInfo(I).Int.bits;2308 const bits = @typeInfo(I).int.bits;
2309 return union {2309 return union {
2310 u: @Type(.{ .Int = .{2310 u: @Type(.{ .int = .{
2311 .signedness = .unsigned,2311 .signedness = .unsigned,
2312 .bits = bits,2312 .bits = bits,
2313 } }),2313 } }),
2314 i: @Type(.{ .Int = .{2314 i: @Type(.{ .int = .{
2315 .signedness = .signed,2315 .signedness = .signed,
2316 .bits = bits,2316 .bits = bits,
2317 } }),2317 } }),
test/behavior/usingnamespace.zig+1-1
...@@ -109,7 +109,7 @@ test "container member access usingnamespace decls" {...@@ -109,7 +109,7 @@ test "container member access usingnamespace decls" {
109109
110usingnamespace opaque {};110usingnamespace opaque {};
111111
112usingnamespace @Type(.{ .Struct = .{112usingnamespace @Type(.{ .@"struct" = .{
113 .layout = .auto,113 .layout = .auto,
114 .fields = &.{},114 .fields = &.{},
115 .decls = &.{},115 .decls = &.{},
test/behavior/vector.zig+17-17
...@@ -564,7 +564,7 @@ test "vector division operators" {...@@ -564,7 +564,7 @@ test "vector division operators" {
564 const S = struct {564 const S = struct {
565 fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void {565 fn doTheTestDiv(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void {
566 const is_signed_int = switch (@typeInfo(T)) {566 const is_signed_int = switch (@typeInfo(T)) {
567 .Int => |info| info.signedness == .signed,567 .int => |info| info.signedness == .signed,
568 else => false,568 else => false,
569 };569 };
570 if (!is_signed_int) {570 if (!is_signed_int) {
...@@ -589,10 +589,10 @@ test "vector division operators" {...@@ -589,10 +589,10 @@ test "vector division operators" {
589589
590 fn doTheTestMod(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void {590 fn doTheTestMod(comptime T: type, x: @Vector(4, T), y: @Vector(4, T)) !void {
591 const is_signed_int = switch (@typeInfo(T)) {591 const is_signed_int = switch (@typeInfo(T)) {
592 .Int => |info| info.signedness == .signed,592 .int => |info| info.signedness == .signed,
593 else => false,593 else => false,
594 };594 };
595 if (!is_signed_int and @typeInfo(T) != .Float) {595 if (!is_signed_int and @typeInfo(T) != .float) {
596 const r0 = x % y;596 const r0 = x % y;
597 for (@as([4]T, r0), 0..) |v, i| {597 for (@as([4]T, r0), 0..) |v, i| {
598 try expect(x[i] % y[i] == v);598 try expect(x[i] % y[i] == v);
...@@ -686,9 +686,9 @@ test "vector shift operators" {...@@ -686,9 +686,9 @@ test "vector shift operators" {
686686
687 const S = struct {687 const S = struct {
688 fn doTheTestShift(x: anytype, y: anytype) !void {688 fn doTheTestShift(x: anytype, y: anytype) !void {
689 const N = @typeInfo(@TypeOf(x)).Array.len;689 const N = @typeInfo(@TypeOf(x)).array.len;
690 const TX = @typeInfo(@TypeOf(x)).Array.child;690 const TX = @typeInfo(@TypeOf(x)).array.child;
691 const TY = @typeInfo(@TypeOf(y)).Array.child;691 const TY = @typeInfo(@TypeOf(y)).array.child;
692692
693 const xv = @as(@Vector(N, TX), x);693 const xv = @as(@Vector(N, TX), x);
694 const yv = @as(@Vector(N, TY), y);694 const yv = @as(@Vector(N, TY), y);
...@@ -703,9 +703,9 @@ test "vector shift operators" {...@@ -703,9 +703,9 @@ test "vector shift operators" {
703 }703 }
704 }704 }
705 fn doTheTestShiftExact(x: anytype, y: anytype, dir: enum { Left, Right }) !void {705 fn doTheTestShiftExact(x: anytype, y: anytype, dir: enum { Left, Right }) !void {
706 const N = @typeInfo(@TypeOf(x)).Array.len;706 const N = @typeInfo(@TypeOf(x)).array.len;
707 const TX = @typeInfo(@TypeOf(x)).Array.child;707 const TX = @typeInfo(@TypeOf(x)).array.child;
708 const TY = @typeInfo(@TypeOf(y)).Array.child;708 const TY = @typeInfo(@TypeOf(y)).array.child;
709709
710 const xv = @as(@Vector(N, TX), x);710 const xv = @as(@Vector(N, TX), x);
711 const yv = @as(@Vector(N, TY), y);711 const yv = @as(@Vector(N, TY), y);
...@@ -777,13 +777,13 @@ test "vector reduce operation" {...@@ -777,13 +777,13 @@ test "vector reduce operation" {
777777
778 const S = struct {778 const S = struct {
779 fn testReduce(comptime op: std.builtin.ReduceOp, x: anytype, expected: anytype) !void {779 fn testReduce(comptime op: std.builtin.ReduceOp, x: anytype, expected: anytype) !void {
780 const N = @typeInfo(@TypeOf(x)).Array.len;780 const N = @typeInfo(@TypeOf(x)).array.len;
781 const TX = @typeInfo(@TypeOf(x)).Array.child;781 const TX = @typeInfo(@TypeOf(x)).array.child;
782782
783 const r = @reduce(op, @as(@Vector(N, TX), x));783 const r = @reduce(op, @as(@Vector(N, TX), x));
784 switch (@typeInfo(TX)) {784 switch (@typeInfo(TX)) {
785 .Int, .Bool => try expect(expected == r),785 .int, .bool => try expect(expected == r),
786 .Float => {786 .float => {
787 const expected_nan = math.isNan(expected);787 const expected_nan = math.isNan(expected);
788 const got_nan = math.isNan(r);788 const got_nan = math.isNan(r);
789789
...@@ -941,10 +941,10 @@ test "mask parameter of @shuffle is comptime scope" {...@@ -941,10 +941,10 @@ test "mask parameter of @shuffle is comptime scope" {
941 var v4_b = __v4hi{ 5, 6, 7, 8 };941 var v4_b = __v4hi{ 5, 6, 7, 8 };
942 _ = .{ &v4_a, &v4_b };942 _ = .{ &v4_a, &v4_b };
943 const shuffled: __v4hi = @shuffle(i16, v4_a, v4_b, @Vector(4, i32){943 const shuffled: __v4hi = @shuffle(i16, v4_a, v4_b, @Vector(4, i32){
944 std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).Vector.len),944 std.zig.c_translation.shuffleVectorIndex(0, @typeInfo(@TypeOf(v4_a)).vector.len),
945 std.zig.c_translation.shuffleVectorIndex(2, @typeInfo(@TypeOf(v4_a)).Vector.len),945 std.zig.c_translation.shuffleVectorIndex(2, @typeInfo(@TypeOf(v4_a)).vector.len),
946 std.zig.c_translation.shuffleVectorIndex(4, @typeInfo(@TypeOf(v4_a)).Vector.len),946 std.zig.c_translation.shuffleVectorIndex(4, @typeInfo(@TypeOf(v4_a)).vector.len),
947 std.zig.c_translation.shuffleVectorIndex(6, @typeInfo(@TypeOf(v4_a)).Vector.len),947 std.zig.c_translation.shuffleVectorIndex(6, @typeInfo(@TypeOf(v4_a)).vector.len),
948 });948 });
949 try expect(shuffled[0] == 1);949 try expect(shuffled[0] == 1);
950 try expect(shuffled[1] == 3);950 try expect(shuffled[1] == 3);
test/c_import/macros.zig+1-1
...@@ -222,7 +222,7 @@ test "Macro that uses remainder operator. Issue #13346" {...@@ -222,7 +222,7 @@ test "Macro that uses remainder operator. Issue #13346" {
222test "@typeInfo on @cImport result" {222test "@typeInfo on @cImport result" {
223 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;223 if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
224224
225 try expect(@typeInfo(h).Struct.decls.len > 1);225 try expect(@typeInfo(h).@"struct".decls.len > 1);
226}226}
227227
228test "Macro that uses Long type concatenation casting" {228test "Macro that uses Long type concatenation casting" {
test/cases/compile_errors/@errorCast_with_bad_type.zig+2-2
...@@ -23,8 +23,8 @@ pub export fn entry4() void {...@@ -23,8 +23,8 @@ pub export fn entry4() void {
23// backend=stage223// backend=stage2
24// target=x86_64-linux24// target=x86_64-linux
25//25//
26// :4:25: error: expected error set or error union type, found 'ComptimeInt'26// :4:25: error: expected error set or error union type, found 'comptime_int'
27// :8:20: error: expected error set or error union type, found 'Int'27// :8:20: error: expected error set or error union type, found 'int'
28// :13:25: error: cannot cast an error union type to error set28// :13:25: error: cannot cast an error union type to error set
29// :18:29: error: payload types of error unions must match29// :18:29: error: payload types of error unions must match
30// :18:29: note: destination payload is 'f32'30// :18:29: note: destination payload is 'f32'
test/cases/compile_errors/access_invalid_typeInfo_decl.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const A = B;1const A = B;
2test "Crash" {2test "Crash" {
3 _ = @typeInfo(@This()).Struct.decls[0];3 _ = @typeInfo(@This()).@"struct".decls[0];
4}4}
55
6// error6// error
test/cases/compile_errors/addition_with_non_numbers.zig+1-1
...@@ -11,4 +11,4 @@ export fn entry() usize {...@@ -11,4 +11,4 @@ export fn entry() usize {
11// backend=llvm11// backend=llvm
12// target=native12// target=native
13//13//
14// :4:29: error: invalid operands to binary expression: 'Struct' and 'Struct'14// :4:29: error: invalid operands to binary expression: 'struct' and 'struct'
test/cases/compile_errors/array_init_generic_fn_with_inferred_error_set.zig+2-2
...@@ -8,5 +8,5 @@ fn my_func(comptime T: type) !T {}...@@ -8,5 +8,5 @@ fn my_func(comptime T: type) !T {}
88
9// error9// error
10//10//
11// :2:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype'11// :2:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).@"fn".return_type.?).error_union.error_set!anytype'
12// :5:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).Fn.return_type.?).ErrorUnion.error_set!anytype'12// :5:9: error: expected type 'type', found 'fn (comptime type) @typeInfo(@typeInfo(@TypeOf(tmp.my_func)).@"fn".return_type.?).error_union.error_set!anytype'
test/cases/compile_errors/attempt_to_create_17_bit_float_type.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const builtin = @import("std").builtin;1const builtin = @import("std").builtin;
2comptime {2comptime {
3 _ = @Type(.{ .Float = .{ .bits = 17 } });3 _ = @Type(.{ .float = .{ .bits = 17 } });
4}4}
55
6// error6// error
test/cases/compile_errors/binary_OR_operator_on_error_sets.zig+1-1
...@@ -9,4 +9,4 @@ export fn entry() void {...@@ -9,4 +9,4 @@ export fn entry() void {
9// backend=stage29// backend=stage2
10// target=native10// target=native
11//11//
12// :2:18: error: invalid operands to binary bitwise expression: 'ErrorSet' and 'ErrorSet'12// :2:18: error: invalid operands to binary bitwise expression: 'error_set' and 'error_set'
test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig+1-1
...@@ -6,7 +6,7 @@ pub export fn entry() void {...@@ -6,7 +6,7 @@ pub export fn entry() void {
6 const Widget = union(enum) { a: u0 };6 const Widget = union(enum) { a: u0 };
77
8 comptime var a = 1;8 comptime var a = 1;
9 const info = @typeInfo(Widget).Union;9 const info = @typeInfo(Widget).@"union";
10 inline for (info.fields) |field| {10 inline for (info.fields) |field| {
11 if (foo()) {11 if (foo()) {
12 switch (field.type) {12 switch (field.type) {
test/cases/compile_errors/dereference_anyopaque.zig+2-2
...@@ -13,13 +13,13 @@ fn parse(comptime T: type, allocator: std.mem.Allocator) !void {...@@ -13,13 +13,13 @@ fn parse(comptime T: type, allocator: std.mem.Allocator) !void {
1313
14fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void {14fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void {
15 switch (@typeInfo(T)) {15 switch (@typeInfo(T)) {
16 .Struct => |structInfo| {16 .@"struct" => |structInfo| {
17 inline for (structInfo.fields) |field| {17 inline for (structInfo.fields) |field| {
18 if (!field.is_comptime)18 if (!field.is_comptime)
19 parseFree(field.type, undefined, allocator);19 parseFree(field.type, undefined, allocator);
20 }20 }
21 },21 },
22 .Pointer => |ptrInfo| {22 .pointer => |ptrInfo| {
23 switch (ptrInfo.size) {23 switch (ptrInfo.size) {
24 .One => {24 .One => {
25 parseFree(ptrInfo.child, value.*, allocator);25 parseFree(ptrInfo.child, value.*, allocator);
test/cases/compile_errors/error_set_membership.zig+1-1
...@@ -27,5 +27,5 @@ pub fn main() Error!void {...@@ -27,5 +27,5 @@ pub fn main() Error!void {
27// backend=llvm27// backend=llvm
28// target=native28// target=native
29//29//
30// :23:29: error: expected type 'error{InvalidCharacter}', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).Fn.return_type.?).ErrorUnion.error_set'30// :23:29: error: expected type 'error{InvalidCharacter}', found '@typeInfo(@typeInfo(@TypeOf(tmp.fooey)).@"fn".return_type.?).error_union.error_set'
31// :23:29: note: 'error.InvalidDirection' not a member of destination error set31// :23:29: note: 'error.InvalidDirection' not a member of destination error set
test/cases/compile_errors/for_loop_error_union.zig+1-1
...@@ -10,6 +10,6 @@ export fn a() void {...@@ -10,6 +10,6 @@ export fn a() void {
10// backend=stage210// backend=stage2
11// target=native11// target=native
12//12//
13// :6:11: error: type '@typeInfo(@typeInfo(@TypeOf(tmp.b)).Fn.return_type.?).ErrorUnion.error_set!u32' is not indexable and not a range13// :6:11: error: type '@typeInfo(@typeInfo(@TypeOf(tmp.b)).@"fn".return_type.?).error_union.error_set!u32' is not indexable and not a range
14// :6:11: note: for loop operand must be a range, array, slice, tuple, or vector14// :6:11: note: for loop operand must be a range, array, slice, tuple, or vector
15// :6:11: note: consider using 'try', 'catch', or 'if'15// :6:11: note: consider using 'try', 'catch', or 'if'
test/cases/compile_errors/generic_instantiation_failure_in_generic_function_return_type.zig+3-3
...@@ -5,7 +5,7 @@ pub export fn entry() void {...@@ -5,7 +5,7 @@ pub export fn entry() void {
5 _ = sliceAsBytes(ohnoes);5 _ = sliceAsBytes(ohnoes);
6 _ = &ohnoes;6 _ = &ohnoes;
7}7}
8fn sliceAsBytes(slice: anytype) isPtrTo(.Array)(@TypeOf(slice)) {}8fn sliceAsBytes(slice: anytype) isPtrTo(.array)(@TypeOf(slice)) {}
99
10pub const TraitFn = fn (type) bool;10pub const TraitFn = fn (type) bool;
1111
...@@ -20,8 +20,8 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {...@@ -20,8 +20,8 @@ pub fn isPtrTo(comptime id: std.builtin.TypeId) TraitFn {
20}20}
2121
22pub fn isSingleItemPtr(comptime T: type) bool {22pub fn isSingleItemPtr(comptime T: type) bool {
23 if (comptime is(.Pointer)(T)) {23 if (comptime is(.pointer)(T)) {
24 return @typeInfo(T).Pointer.size == .One;24 return @typeInfo(T).pointer.size == .One;
25 }25 }
26 return false;26 return false;
27}27}
test/cases/compile_errors/helpful_return_type_error_message.zig+3-3
...@@ -21,12 +21,12 @@ export fn quux() u32 {...@@ -21,12 +21,12 @@ export fn quux() u32 {
21//21//
22// :2:18: error: expected type 'u32', found 'error{Ohno}'22// :2:18: error: expected type 'u32', found 'error{Ohno}'
23// :1:17: note: function cannot return an error23// :1:17: note: function cannot return an error
24// :8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).Fn.return_type.?).ErrorUnion.error_set'24// :8:5: error: expected type 'void', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).@"fn".return_type.?).error_union.error_set'
25// :7:17: note: function cannot return an error25// :7:17: note: function cannot return an error
26// :11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).Fn.return_type.?).ErrorUnion.error_set!u32'26// :11:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).@"fn".return_type.?).error_union.error_set!u32'
27// :11:15: note: cannot convert error union to payload type27// :11:15: note: cannot convert error union to payload type
28// :11:15: note: consider using 'try', 'catch', or 'if'28// :11:15: note: consider using 'try', 'catch', or 'if'
29// :10:17: note: function cannot return an error29// :10:17: note: function cannot return an error
30// :15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).Fn.return_type.?).ErrorUnion.error_set!u32'30// :15:14: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.bar)).@"fn".return_type.?).error_union.error_set!u32'
31// :15:14: note: cannot convert error union to payload type31// :15:14: note: cannot convert error union to payload type
32// :15:14: note: consider using 'try', 'catch', or 'if'32// :15:14: note: consider using 'try', 'catch', or 'if'
test/cases/compile_errors/invalid_pointer_arithmetic.zig+1-1
...@@ -45,7 +45,7 @@ comptime {...@@ -45,7 +45,7 @@ comptime {
45// :2:11: note: pointer-integer arithmetic only supports addition and subtraction45// :2:11: note: pointer-integer arithmetic only supports addition and subtraction
46// :6:11: error: invalid pointer-pointer arithmetic operator46// :6:11: error: invalid pointer-pointer arithmetic operator
47// :6:11: note: pointer-pointer arithmetic only supports subtraction47// :6:11: note: pointer-pointer arithmetic only supports subtraction
48// :12:11: error: invalid operands to binary expression: 'Pointer' and 'Pointer'48// :12:11: error: invalid operands to binary expression: 'pointer' and 'pointer'
49// :20:11: error: incompatible pointer arithmetic operands '[*]u8' and '[*]u16'49// :20:11: error: incompatible pointer arithmetic operands '[*]u8' and '[*]u16'
50// :26:11: error: incompatible pointer arithmetic operands '*u8' and '*u16'50// :26:11: error: incompatible pointer arithmetic operands '*u8' and '*u16'
51// :31:11: error: pointer arithmetic requires element type 'u0' to have runtime bits51// :31:11: error: pointer arithmetic requires element type 'u0' to have runtime bits
test/cases/compile_errors/invalid_pointer_with_reify_type.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{ .Pointer = .{2 _ = @Type(.{ .pointer = .{
3 .size = .One,3 .size = .One,
4 .is_const = false,4 .is_const = false,
5 .is_volatile = false,5 .is_volatile = false,
test/cases/compile_errors/issue_15572_break_on_inline_while.zig+1-1
...@@ -6,7 +6,7 @@ pub const DwarfSection = enum {...@@ -6,7 +6,7 @@ pub const DwarfSection = enum {
6};6};
77
8pub fn main() void {8pub fn main() void {
9 const section = inline for (@typeInfo(DwarfSection).Enum.fields) |section| {9 const section = inline for (@typeInfo(DwarfSection).@"enum".fields) |section| {
10 if (std.mem.eql(u8, section.name, "eh_frame")) break section;10 if (std.mem.eql(u8, section.name, "eh_frame")) break section;
11 };11 };
1212
test/cases/compile_errors/issue_5221_invalid_struct_init_type_referenced_by_typeInfo_and_passed_into_function.zig+1-1
...@@ -7,7 +7,7 @@ export fn foo() void {...@@ -7,7 +7,7 @@ export fn foo() void {
7 wrong_type: []u8 = "foo",7 wrong_type: []u8 = "foo",
8 };8 };
99
10 comptime ignore(@typeInfo(MyStruct).Struct.fields[0]);10 comptime ignore(@typeInfo(MyStruct).@"struct".fields[0]);
11}11}
1212
13// error13// error
test/cases/compile_errors/method_call_on_error_union.zig+1-1
...@@ -17,5 +17,5 @@ export fn entry() void {...@@ -17,5 +17,5 @@ export fn entry() void {
17// backend=stage217// backend=stage2
18// target=native18// target=native
19//19//
20// :13:6: error: no field or member function named 'a' in '@typeInfo(@typeInfo(@TypeOf(tmp.X.init)).Fn.return_type.?).ErrorUnion.error_set!tmp.X'20// :13:6: error: no field or member function named 'a' in '@typeInfo(@typeInfo(@TypeOf(tmp.X.init)).@"fn".return_type.?).error_union.error_set!tmp.X'
21// :13:6: note: consider using 'try', 'catch', or 'if'21// :13:6: note: consider using 'try', 'catch', or 'if'
test/cases/compile_errors/nested_vectors.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1export fn entry() void {1export fn entry() void {
2 const V1 = @Vector(4, u8);2 const V1 = @Vector(4, u8);
3 const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });3 const V2 = @Type(.{ .vector = .{ .len = 4, .child = V1 } });
4 const v: V2 = undefined;4 const v: V2 = undefined;
5 _ = v;5 _ = v;
6}6}
test/cases/compile_errors/non-enum_tag_type_passed_to_union.zig+1-1
...@@ -2,7 +2,7 @@ const Foo = union(u32) {...@@ -2,7 +2,7 @@ const Foo = union(u32) {
2 A: i32,2 A: i32,
3};3};
4export fn entry() void {4export fn entry() void {
5 const x = @typeInfo(Foo).Union.tag_type.?;5 const x = @typeInfo(Foo).@"union".tag_type.?;
6 _ = x;6 _ = x;
7}7}
88
test/cases/compile_errors/non-integer_tag_type_to_automatic_union_enum.zig+1-1
...@@ -2,7 +2,7 @@ const Foo = union(enum(f32)) {...@@ -2,7 +2,7 @@ const Foo = union(enum(f32)) {
2 A: i32,2 A: i32,
3};3};
4export fn entry() void {4export fn entry() void {
5 const x = @typeInfo(Foo).Union.tag_type.?;5 const x = @typeInfo(Foo).@"union".tag_type.?;
6 _ = x;6 _ = x;
7}7}
88
test/cases/compile_errors/not_an_enum_type.zig+1-1
...@@ -16,5 +16,5 @@ const ExpectedVarDeclOrFn = struct {};...@@ -16,5 +16,5 @@ const ExpectedVarDeclOrFn = struct {};
16// backend=stage216// backend=stage2
17// target=native17// target=native
18//18//
19// :4:9: error: expected type '@typeInfo(tmp.Error).Union.tag_type.?', found 'type'19// :4:9: error: expected type '@typeInfo(tmp.Error).@"union".tag_type.?', found 'type'
20// :8:15: note: enum declared here20// :8:15: note: enum declared here
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{2 _ = @Type(.{ .@"struct" = .{ .layout = .@"packed", .fields = &.{
3 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },3 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },
4 }, .decls = &.{}, .is_tuple = false } });4 }, .decls = &.{}, .is_tuple = false } });
5}5}
test/cases/compile_errors/range_operator_in_switch_used_on_error_set.zig+1-1
...@@ -16,5 +16,5 @@ fn foo(x: i32) !void {...@@ -16,5 +16,5 @@ fn foo(x: i32) !void {
16// backend=llvm16// backend=llvm
17// target=native17// target=native
18//18//
19// :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).Fn.return_type.?).ErrorUnion.error_set'19// :2:34: error: ranges not allowed when switching on type '@typeInfo(@typeInfo(@TypeOf(tmp.foo)).@"fn".return_type.?).error_union.error_set'
20// :3:18: note: range here20// :3:18: note: range here
test/cases/compile_errors/regression_test_2980_base_type_u32_is_not_type_checked_properly_when_assigning_a_value_within_a_struct.zig+1-1
...@@ -18,6 +18,6 @@ export fn entry() void {...@@ -18,6 +18,6 @@ export fn entry() void {
18// backend=stage218// backend=stage2
19// target=native19// target=native
20//20//
21// :12:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.get_uval)).Fn.return_type.?).ErrorUnion.error_set!u32'21// :12:15: error: expected type 'u32', found '@typeInfo(@typeInfo(@TypeOf(tmp.get_uval)).@"fn".return_type.?).error_union.error_set!u32'
22// :12:15: note: cannot convert error union to payload type22// :12:15: note: cannot convert error union to payload type
23// :12:15: note: consider using 'try', 'catch', or 'if'23// :12:15: note: consider using 'try', 'catch', or 'if'
test/cases/compile_errors/reified_enum_field_value_overflow.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1comptime {1comptime {
2 const E = @Type(.{ .Enum = .{2 const E = @Type(.{ .@"enum" = .{
3 .tag_type = u1,3 .tag_type = u1,
4 .fields = &.{4 .fields = &.{
5 .{ .name = "f0", .value = 0 },5 .{ .name = "f0", .value = 0 },
test/cases/compile_errors/reify_enum_with_duplicate_field.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{2 _ = @Type(.{
3 .Enum = .{3 .@"enum" = .{
4 .tag_type = u32,4 .tag_type = u32,
5 .fields = &.{5 .fields = &.{
6 .{ .name = "A", .value = 0 },6 .{ .name = "A", .value = 0 },
test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{2 _ = @Type(.{
3 .Enum = .{3 .@"enum" = .{
4 .tag_type = u32,4 .tag_type = u32,
5 .fields = &.{5 .fields = &.{
6 .{ .name = "A", .value = 10 },6 .{ .name = "A", .value = 10 },
test/cases/compile_errors/reify_struct.zig+5-5
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1comptime {1comptime {
2 @Type(.{ .Struct = .{2 @Type(.{ .@"struct" = .{
3 .layout = .auto,3 .layout = .auto,
4 .fields = &.{.{4 .fields = &.{.{
5 .name = "foo",5 .name = "foo",
...@@ -13,7 +13,7 @@ comptime {...@@ -13,7 +13,7 @@ comptime {
13 } });13 } });
14}14}
15comptime {15comptime {
16 @Type(.{ .Struct = .{16 @Type(.{ .@"struct" = .{
17 .layout = .auto,17 .layout = .auto,
18 .fields = &.{.{18 .fields = &.{.{
19 .name = "3",19 .name = "3",
...@@ -27,7 +27,7 @@ comptime {...@@ -27,7 +27,7 @@ comptime {
27 } });27 } });
28}28}
29comptime {29comptime {
30 @Type(.{ .Struct = .{30 @Type(.{ .@"struct" = .{
31 .layout = .auto,31 .layout = .auto,
32 .fields = &.{.{32 .fields = &.{.{
33 .name = "0",33 .name = "0",
...@@ -41,7 +41,7 @@ comptime {...@@ -41,7 +41,7 @@ comptime {
41 } });41 } });
42}42}
43comptime {43comptime {
44 @Type(.{ .Struct = .{44 @Type(.{ .@"struct" = .{
45 .layout = .@"extern",45 .layout = .@"extern",
46 .fields = &.{.{46 .fields = &.{.{
47 .name = "0",47 .name = "0",
...@@ -55,7 +55,7 @@ comptime {...@@ -55,7 +55,7 @@ comptime {
55 } });55 } });
56}56}
57comptime {57comptime {
58 @Type(.{ .Struct = .{58 @Type(.{ .@"struct" = .{
59 .layout = .@"packed",59 .layout = .@"packed",
60 .fields = &.{.{60 .fields = &.{.{
61 .name = "0",61 .name = "0",
test/cases/compile_errors/reify_type.Fn_with_is_generic_true.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Foo = @Type(.{1const Foo = @Type(.{
2 .Fn = .{2 .@"fn" = .{
3 .calling_convention = .Unspecified,3 .calling_convention = .Unspecified,
4 .is_generic = true,4 .is_generic = true,
5 .is_var_args = false,5 .is_var_args = false,
test/cases/compile_errors/reify_type.Fn_with_is_var_args_true_and_non-C_callconv.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Foo = @Type(.{1const Foo = @Type(.{
2 .Fn = .{2 .@"fn" = .{
3 .calling_convention = .Unspecified,3 .calling_convention = .Unspecified,
4 .is_generic = false,4 .is_generic = false,
5 .is_var_args = true,5 .is_var_args = true,
test/cases/compile_errors/reify_type.Fn_with_return_type_null.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Foo = @Type(.{1const Foo = @Type(.{
2 .Fn = .{2 .@"fn" = .{
3 .calling_convention = .Unspecified,3 .calling_convention = .Unspecified,
4 .is_generic = false,4 .is_generic = false,
5 .is_var_args = false,5 .is_var_args = false,
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Tag = @Type(.{1const Tag = @Type(.{
2 .Enum = .{2 .@"enum" = .{
3 .tag_type = bool,3 .tag_type = bool,
4 .fields = &.{},4 .fields = &.{},
5 .decls = &.{},5 .decls = &.{},
test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Tag = @Type(.{1const Tag = @Type(.{
2 .Enum = .{2 .@"enum" = .{
3 .tag_type = undefined,3 .tag_type = undefined,
4 .fields = &.{},4 .fields = &.{},
5 .decls = &.{},5 .decls = &.{},
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Tag = @Type(.{1const Tag = @Type(.{
2 .Enum = .{2 .@"enum" = .{
3 .tag_type = u2,3 .tag_type = u2,
4 .fields = &.{4 .fields = &.{
5 .{ .name = "signed", .value = 0 },5 .{ .name = "signed", .value = 0 },
...@@ -11,7 +11,7 @@ const Tag = @Type(.{...@@ -11,7 +11,7 @@ const Tag = @Type(.{
11 },11 },
12});12});
13const Tagged = @Type(.{13const Tagged = @Type(.{
14 .Union = .{14 .@"union" = .{
15 .layout = .auto,15 .layout = .auto,
16 .tag_type = Tag,16 .tag_type = Tag,
17 .fields = &.{17 .fields = &.{
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Tag = @Type(.{1const Tag = @Type(.{
2 .Enum = .{2 .@"enum" = .{
3 .tag_type = u1,3 .tag_type = u1,
4 .fields = &.{4 .fields = &.{
5 .{ .name = "signed", .value = 0 },5 .{ .name = "signed", .value = 0 },
...@@ -10,7 +10,7 @@ const Tag = @Type(.{...@@ -10,7 +10,7 @@ const Tag = @Type(.{
10 },10 },
11});11});
12const Tagged = @Type(.{12const Tagged = @Type(.{
13 .Union = .{13 .@"union" = .{
14 .layout = .auto,14 .layout = .auto,
15 .tag_type = Tag,15 .tag_type = Tag,
16 .fields = &.{16 .fields = &.{
test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Tag = @Type(.{1const Tag = @Type(.{
2 .Enum = .{2 .@"enum" = .{
3 .tag_type = u0,3 .tag_type = u0,
4 .fields = &.{},4 .fields = &.{},
5 .decls = &.{},5 .decls = &.{},
...@@ -7,7 +7,7 @@ const Tag = @Type(.{...@@ -7,7 +7,7 @@ const Tag = @Type(.{
7 },7 },
8});8});
9const Tagged = @Type(.{9const Tagged = @Type(.{
10 .Union = .{10 .@"union" = .{
11 .layout = .auto,11 .layout = .auto,
12 .tag_type = Tag,12 .tag_type = Tag,
13 .fields = &.{13 .fields = &.{
test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig+2-2
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Tag = @Type(.{1const Tag = @Type(.{
2 .Enum = .{2 .@"enum" = .{
3 .tag_type = u1,3 .tag_type = u1,
4 .fields = &.{4 .fields = &.{
5 .{ .name = "signed", .value = 0 },5 .{ .name = "signed", .value = 0 },
...@@ -10,7 +10,7 @@ const Tag = @Type(.{...@@ -10,7 +10,7 @@ const Tag = @Type(.{
10 },10 },
11});11});
12const Tagged = @Type(.{12const Tagged = @Type(.{
13 .Union = .{13 .@"union" = .{
14 .layout = .auto,14 .layout = .auto,
15 .tag_type = Tag,15 .tag_type = Tag,
16 .fields = &.{},16 .fields = &.{},
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Untagged = @Type(.{1const Untagged = @Type(.{
2 .Union = .{2 .@"union" = .{
3 .layout = .auto,3 .layout = .auto,
4 .tag_type = null,4 .tag_type = null,
5 .fields = &.{5 .fields = &.{
test/cases/compile_errors/reify_type_union_payload_is_undefined.zig+1-1
...@@ -1,5 +1,5 @@...@@ -1,5 +1,5 @@
1const Foo = @Type(.{1const Foo = @Type(.{
2 .Struct = undefined,2 .@"struct" = undefined,
3});3});
4comptime {4comptime {
5 _ = Foo;5 _ = Foo;
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+3-3
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1comptime {1comptime {
2 _ = @Type(.{2 _ = @Type(.{
3 .Union = .{3 .@"union" = .{
4 .layout = .auto,4 .layout = .auto,
5 .tag_type = null,5 .tag_type = null,
6 .fields = &.{6 .fields = &.{
...@@ -12,7 +12,7 @@ comptime {...@@ -12,7 +12,7 @@ comptime {
12}12}
13comptime {13comptime {
14 _ = @Type(.{14 _ = @Type(.{
15 .Struct = .{15 .@"struct" = .{
16 .layout = .auto,16 .layout = .auto,
17 .fields = &.{.{17 .fields = &.{.{
18 .name = "0",18 .name = "0",
...@@ -28,7 +28,7 @@ comptime {...@@ -28,7 +28,7 @@ comptime {
28}28}
29comptime {29comptime {
30 _ = @Type(.{30 _ = @Type(.{
31 .Pointer = .{31 .pointer = .{
32 .size = .Many,32 .size = .Many,
33 .is_const = true,33 .is_const = true,
34 .is_volatile = false,34 .is_volatile = false,
test/cases/compile_errors/reify_type_with_undefined.zig+3-3
...@@ -1,9 +1,9 @@...@@ -1,9 +1,9 @@
1comptime {1comptime {
2 _ = @Type(.{ .Array = .{ .len = 0, .child = u8, .sentinel = undefined } });2 _ = @Type(.{ .array = .{ .len = 0, .child = u8, .sentinel = undefined } });
3}3}
4comptime {4comptime {
5 _ = @Type(.{5 _ = @Type(.{
6 .Struct = .{6 .@"struct" = .{
7 .fields = undefined,7 .fields = undefined,
8 .decls = undefined,8 .decls = undefined,
9 .is_tuple = false,9 .is_tuple = false,
...@@ -15,7 +15,7 @@ comptime {...@@ -15,7 +15,7 @@ comptime {
15 const std = @import("std");15 const std = @import("std");
16 const fields: [1]std.builtin.Type.StructField = undefined;16 const fields: [1]std.builtin.Type.StructField = undefined;
17 _ = @Type(.{17 _ = @Type(.{
18 .Struct = .{18 .@"struct" = .{
19 .layout = .auto,19 .layout = .auto,
20 .fields = &fields,20 .fields = &fields,
21 .decls = &.{},21 .decls = &.{},
test/cases/compile_errors/resolve_inferred_error_set_of_generic_fn.zig+2-2
...@@ -5,8 +5,8 @@ fn foo(a: anytype) !void {...@@ -5,8 +5,8 @@ fn foo(a: anytype) !void {
5const Error = error{ A, B };5const Error = error{ A, B };
6export fn entry() void {6export fn entry() void {
7 const info = @typeInfo(@TypeOf(foo));7 const info = @typeInfo(@TypeOf(foo));
8 const ret_type = info.Fn.return_type.?;8 const ret_type = info.@"fn".return_type.?;
9 const error_set = @typeInfo(ret_type).ErrorUnion.error_set;9 const error_set = @typeInfo(ret_type).error_union.error_set;
10 _ = Error || error_set;10 _ = Error || error_set;
11}11}
1212
test/cases/compile_errors/runtime_index_into_comptime_type_slice.zig+2-2
...@@ -6,7 +6,7 @@ fn getIndex() usize {...@@ -6,7 +6,7 @@ fn getIndex() usize {
6}6}
7export fn entry() void {7export fn entry() void {
8 const index = getIndex();8 const index = getIndex();
9 const field = @typeInfo(Struct).Struct.fields[index];9 const field = @typeInfo(Struct).@"struct".fields[index];
10 _ = field;10 _ = field;
11}11}
1212
...@@ -14,7 +14,7 @@ export fn entry() void {...@@ -14,7 +14,7 @@ export fn entry() void {
14// backend=stage214// backend=stage2
15// target=native15// target=native
16//16//
17// :9:51: error: values of type '[]const builtin.Type.StructField' must be comptime-known, but index value is runtime-known17// :9:54: error: values of type '[]const builtin.Type.StructField' must be comptime-known, but index value is runtime-known
18// : note: struct requires comptime because of this field18// : note: struct requires comptime because of this field
19// : note: types are not available at runtime19// : note: types are not available at runtime
20// : struct requires comptime because of this field20// : struct requires comptime because of this field
test/cases/compile_errors/saturating_arithmetic_does_not_allow_floats.zig+1-1
...@@ -6,4 +6,4 @@ export fn a() void {...@@ -6,4 +6,4 @@ export fn a() void {
6// backend=stage26// backend=stage2
7// target=native7// target=native
8//8//
9// :2:23: error: invalid operands to binary expression: 'Float' and 'Float'9// :2:23: error: invalid operands to binary expression: 'float' and 'float'
test/cases/compile_errors/switch_on_error_with_non_trivial_switch_operand.zig+2-2
...@@ -18,5 +18,5 @@ export fn entry2() void {...@@ -18,5 +18,5 @@ export fn entry2() void {
18// backend=stage218// backend=stage2
19// target=native19// target=native
20//20//
21// :4:42: error: invalid operands to binary expression: 'ErrorSet' and 'ComptimeInt'21// :4:42: error: invalid operands to binary expression: 'error_set' and 'comptime_int'
22// :12:35: error: invalid operands to binary expression: 'ErrorSet' and 'ComptimeInt'22// :12:35: error: invalid operands to binary expression: 'error_set' and 'comptime_int'
test/cases/compile_errors/unable_to_evaluate_comptime_expr.zig+1-1
...@@ -16,7 +16,7 @@ pub export fn entry2() void {...@@ -16,7 +16,7 @@ pub export fn entry2() void {
16 _ = b;16 _ = b;
17}17}
1818
19const Int = @typeInfo(bar).Struct.backing_integer.?;19const Int = @typeInfo(bar).@"struct".backing_integer.?;
2020
21const foo = enum(Int) {21const foo = enum(Int) {
22 c = @bitCast(bar{22 c = @bitCast(bar{
test/cases/compile_errors/union_fields_are_resolved_before_tag_type_is_needed.zig+1-1
...@@ -12,5 +12,5 @@ pub export fn entry() void {...@@ -12,5 +12,5 @@ pub export fn entry() void {
12// backend=stage212// backend=stage2
13// target=native13// target=native
14//14//
15// :8:8: error: no field or member function named 'f' in '@typeInfo(tmp.T).Union.tag_type.?'15// :8:8: error: no field or member function named 'f' in '@typeInfo(tmp.T).@"union".tag_type.?'
16// :1:11: note: enum declared here16// :1:11: note: enum declared here
test/cases/compile_errors/union_noreturn_field_initialized.zig+2-2
...@@ -23,7 +23,7 @@ pub export fn entry3() void {...@@ -23,7 +23,7 @@ pub export fn entry3() void {
23 a: noreturn,23 a: noreturn,
24 b: void,24 b: void,
25 };25 };
26 var e = @typeInfo(U).Union.tag_type.?.a;26 var e = @typeInfo(U).@"union".tag_type.?.a;
27 var u: U = undefined;27 var u: U = undefined;
28 u = (&e).*;28 u = (&e).*;
29}29}
...@@ -38,6 +38,6 @@ pub export fn entry3() void {...@@ -38,6 +38,6 @@ pub export fn entry3() void {
38// :19:10: error: cannot initialize 'noreturn' field of union38// :19:10: error: cannot initialize 'noreturn' field of union
39// :16:9: note: field 'a' declared here39// :16:9: note: field 'a' declared here
40// :15:15: note: union declared here40// :15:15: note: union declared here
41// :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).Union.tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field41// :28:13: error: runtime coercion from enum '@typeInfo(tmp.entry3.U).@"union".tag_type.?' to union 'tmp.entry3.U' which has a 'noreturn' field
42// :23:9: note: 'noreturn' field here42// :23:9: note: 'noreturn' field here
43// :22:15: note: union declared here43// :22:15: note: union declared here
test/cases/fn_typeinfo_passed_to_comptime_fn.zig+1-1
...@@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 {...@@ -9,7 +9,7 @@ fn someFn(arg: ?*c_int) f64 {
9 return 8;9 return 8;
10}10}
11fn foo(comptime info: std.builtin.Type) !void {11fn foo(comptime info: std.builtin.Type) !void {
12 try std.testing.expect(info.Fn.params[0].type.? == ?*c_int);12 try std.testing.expect(info.@"fn".params[0].type.? == ?*c_int);
13}13}
1414
15// run15// run
test/cases/safety/@tagName on corrupted union value.zig +1-1
...@@ -16,7 +16,7 @@ const U = union(enum(u32)) {...@@ -16,7 +16,7 @@ const U = union(enum(u32)) {
16pub fn main() !void {16pub fn main() !void {
17 var u: U = undefined;17 var u: U = undefined;
18 @memset(@as([*]u8, @ptrCast(&u))[0..@sizeOf(U)], 0x55);18 @memset(@as([*]u8, @ptrCast(&u))[0..@sizeOf(U)], 0x55);
19 const t: @typeInfo(U).Union.tag_type.? = u;19 const t: @typeInfo(U).@"union".tag_type.? = u;
20 const n = @tagName(t);20 const n = @tagName(t);
21 _ = n;21 _ = n;
22 return error.TestFailed;22 return error.TestFailed;
test/link/build.zig+1-1
...@@ -23,7 +23,7 @@ pub fn build(b: *std.Build) void {...@@ -23,7 +23,7 @@ pub fn build(b: *std.Build) void {
23 const dep_name, const dep_hash = available_dep;23 const dep_name, const dep_hash = available_dep;
2424
25 const all_pkgs = @import("root").dependencies.packages;25 const all_pkgs = @import("root").dependencies.packages;
26 inline for (@typeInfo(all_pkgs).Struct.decls) |decl| {26 inline for (@typeInfo(all_pkgs).@"struct".decls) |decl| {
27 const pkg_hash = decl.name;27 const pkg_hash = decl.name;
28 if (std.mem.eql(u8, dep_hash, pkg_hash)) {28 if (std.mem.eql(u8, dep_hash, pkg_hash)) {
29 const pkg = @field(all_pkgs, pkg_hash);29 const pkg = @field(all_pkgs, pkg_hash);
test/src/Cases.zig+4-4
...@@ -1188,12 +1188,12 @@ const TestManifest = struct {...@@ -1188,12 +1188,12 @@ const TestManifest = struct {
1188 }.parse;1188 }.parse;
11891189
1190 switch (@typeInfo(T)) {1190 switch (@typeInfo(T)) {
1191 .Int => return struct {1191 .int => return struct {
1192 fn parse(str: []const u8) anyerror!T {1192 fn parse(str: []const u8) anyerror!T {
1193 return try std.fmt.parseInt(T, str, 0);1193 return try std.fmt.parseInt(T, str, 0);
1194 }1194 }
1195 }.parse,1195 }.parse,
1196 .Bool => return struct {1196 .bool => return struct {
1197 fn parse(str: []const u8) anyerror!T {1197 fn parse(str: []const u8) anyerror!T {
1198 if (std.mem.eql(u8, str, "true")) return true;1198 if (std.mem.eql(u8, str, "true")) return true;
1199 if (std.mem.eql(u8, str, "false")) return false;1199 if (std.mem.eql(u8, str, "false")) return false;
...@@ -1201,7 +1201,7 @@ const TestManifest = struct {...@@ -1201,7 +1201,7 @@ const TestManifest = struct {
1201 return error.InvalidBool;1201 return error.InvalidBool;
1202 }1202 }
1203 }.parse,1203 }.parse,
1204 .Enum => return struct {1204 .@"enum" => return struct {
1205 fn parse(str: []const u8) anyerror!T {1205 fn parse(str: []const u8) anyerror!T {
1206 return std.meta.stringToEnum(T, str) orelse {1206 return std.meta.stringToEnum(T, str) orelse {
1207 std.log.err("unknown enum variant for {s}: {s}", .{ @typeName(T), str });1207 std.log.err("unknown enum variant for {s}: {s}", .{ @typeName(T), str });
...@@ -1209,7 +1209,7 @@ const TestManifest = struct {...@@ -1209,7 +1209,7 @@ const TestManifest = struct {
1209 };1209 };
1210 }1210 }
1211 }.parse,1211 }.parse,
1212 .Struct => @compileError("no default parser for " ++ @typeName(T)),1212 .@"struct" => @compileError("no default parser for " ++ @typeName(T)),
1213 else => @compileError("no default parser for " ++ @typeName(T)),1213 else => @compileError("no default parser for " ++ @typeName(T)),
1214 }1214 }
1215 }1215 }
test/standalone/build.zig+1-1
...@@ -60,7 +60,7 @@ pub fn build(b: *std.Build) void {...@@ -60,7 +60,7 @@ pub fn build(b: *std.Build) void {
60 if (std.mem.eql(u8, dep_name, "simple")) continue;60 if (std.mem.eql(u8, dep_name, "simple")) continue;
6161
62 const all_pkgs = @import("root").dependencies.packages;62 const all_pkgs = @import("root").dependencies.packages;
63 inline for (@typeInfo(all_pkgs).Struct.decls) |decl| {63 inline for (@typeInfo(all_pkgs).@"struct".decls) |decl| {
64 const pkg_hash = decl.name;64 const pkg_hash = decl.name;
65 if (std.mem.eql(u8, dep_hash, pkg_hash)) {65 if (std.mem.eql(u8, dep_hash, pkg_hash)) {
66 const pkg = @field(all_pkgs, pkg_hash);66 const pkg = @field(all_pkgs, pkg_hash);
test/standalone/simple/issue_7030.zig+1-1
...@@ -6,7 +6,7 @@ pub const std_options = .{...@@ -6,7 +6,7 @@ pub const std_options = .{
66
7pub fn log(7pub fn log(
8 comptime message_level: std.log.Level,8 comptime message_level: std.log.Level,
9 comptime scope: @Type(.EnumLiteral),9 comptime scope: @Type(.enum_literal),
10 comptime format: []const u8,10 comptime format: []const u8,
11 args: anytype,11 args: anytype,
12) void {12) void {
test/standalone/simple/std_enums_big_enums.zig+12-14
...@@ -3,21 +3,19 @@ const std = @import("std");...@@ -3,21 +3,19 @@ const std = @import("std");
3// big enums should not hit the eval branch quota3// big enums should not hit the eval branch quota
4pub fn main() void {4pub fn main() void {
5 const big = struct {5 const big = struct {
6 const Big = @Type(@as(std.builtin.Type, .{6 const Big = @Type(.{ .@"enum" = .{
7 .Enum = .{7 .tag_type = u16,
8 .tag_type = u16,8 .fields = make_fields: {
9 .fields = make_fields: {9 var fields: [1001]std.builtin.Type.EnumField = undefined;
10 var fields: [1001]std.builtin.Type.EnumField = undefined;10 for (&fields, 0..) |*field, i| {
11 for (&fields, 0..) |*field, i| {11 field.* = .{ .name = std.fmt.comptimePrint("field_{d}", .{i}), .value = i };
12 field.* = .{ .name = std.fmt.comptimePrint("field_{d}", .{i}), .value = i };12 }
13 }13 fields[1000] = .{ .name = "field_9999", .value = 9999 };
14 fields[1000] = .{ .name = "field_9999", .value = 9999 };14 break :make_fields &fields;
15 break :make_fields &fields;
16 },
17 .decls = &.{},
18 .is_exhaustive = true,
19 },15 },
20 }));16 .decls = &.{},
17 .is_exhaustive = true,
18 } });
21 };19 };
2220
23 var set = std.enums.EnumSet(big.Big).init(.{});21 var set = std.enums.EnumSet(big.Big).init(.{});
tools/generate_c_size_and_align_checks.zig+1-1
...@@ -43,7 +43,7 @@ pub fn main() !void {...@@ -43,7 +43,7 @@ pub fn main() !void {
43 const target = try std.zig.system.resolveTargetQuery(query);43 const target = try std.zig.system.resolveTargetQuery(query);
4444
45 const stdout = std.io.getStdOut().writer();45 const stdout = std.io.getStdOut().writer();
46 inline for (@typeInfo(std.Target.CType).Enum.fields) |field| {46 inline for (@typeInfo(std.Target.CType).@"enum".fields) |field| {
47 const c_type: std.Target.CType = @enumFromInt(field.value);47 const c_type: std.Target.CType = @enumFromInt(field.value);
48 try stdout.print("_Static_assert(sizeof({0s}) == {1d}, \"sizeof({0s}) == {1d}\");\n", .{48 try stdout.print("_Static_assert(sizeof({0s}) == {1d}, \"sizeof({0s}) == {1d}\");\n", .{
49 cName(c_type),49 cName(c_type),
tools/lldb_pretty_printers.py+1-1
...@@ -602,7 +602,7 @@ type_tag_handlers = {...@@ -602,7 +602,7 @@ type_tag_handlers = {
602 'error_set': lambda payload: type_tag_handlers['error_set_merged'](payload.GetChildMemberWithName('names')),602 'error_set': lambda payload: type_tag_handlers['error_set_merged'](payload.GetChildMemberWithName('names')),
603 'error_set_single': lambda payload: 'error{%s}' % zig_String_AsIdentifier(payload, zig_IsFieldName),603 'error_set_single': lambda payload: 'error{%s}' % zig_String_AsIdentifier(payload, zig_IsFieldName),
604 'error_set_merged': lambda payload: 'error{%s}' % ','.join(zig_String_AsIdentifier(child.GetChildMemberWithName('key'), zig_IsFieldName) for child in payload.GetChildMemberWithName('entries').children),604 'error_set_merged': lambda payload: 'error{%s}' % ','.join(zig_String_AsIdentifier(child.GetChildMemberWithName('key'), zig_IsFieldName) for child in payload.GetChildMemberWithName('entries').children),
605 'error_set_inferred': lambda payload: '@typeInfo(@typeInfo(@TypeOf(%s)).Fn.return_type.?).ErrorUnion.error_set' % OwnerDecl_RenderFullyQualifiedName(payload.GetChildMemberWithName('func')),605 'error_set_inferred': lambda payload: '@typeInfo(@typeInfo(@TypeOf(%s)).@"fn".return_type.?).error_union.error_set' % OwnerDecl_RenderFullyQualifiedName(payload.GetChildMemberWithName('func')),
606606
607 'enum_full': OwnerDecl_RenderFullyQualifiedName,607 'enum_full': OwnerDecl_RenderFullyQualifiedName,
608 'enum_nonexhaustive': OwnerDecl_RenderFullyQualifiedName,608 'enum_nonexhaustive': OwnerDecl_RenderFullyQualifiedName,
tools/update_clang_options.zig+1-1
...@@ -616,7 +616,7 @@ pub fn main() anyerror!void {...@@ -616,7 +616,7 @@ pub fn main() anyerror!void {
616616
617 var llvm_to_zig_cpu_features = std.StringHashMap([]const u8).init(allocator);617 var llvm_to_zig_cpu_features = std.StringHashMap([]const u8).init(allocator);
618618
619 inline for (@typeInfo(cpu_targets).Struct.decls) |decl| {619 inline for (@typeInfo(cpu_targets).@"struct".decls) |decl| {
620 const Feature = @field(cpu_targets, decl.name).Feature;620 const Feature = @field(cpu_targets, decl.name).Feature;
621 const all_features = @field(cpu_targets, decl.name).all_features;621 const all_features = @field(cpu_targets, decl.name).all_features;
622622
tools/update_cpu_features.zig+2-2
...@@ -1348,7 +1348,7 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -1348,7 +1348,7 @@ fn processOneTarget(job: Job) anyerror!void {
1348 try w.print(" @setEvalBranchQuota({d});\n", .{branch_quota});1348 try w.print(" @setEvalBranchQuota({d});\n", .{branch_quota});
1349 }1349 }
1350 try w.writeAll(1350 try w.writeAll(
1351 \\ const len = @typeInfo(Feature).Enum.fields.len;1351 \\ const len = @typeInfo(Feature).@"enum".fields.len;
1352 \\ std.debug.assert(len <= CpuFeature.Set.needed_bit_count);1352 \\ std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
1353 \\ var result: [len]CpuFeature = undefined;1353 \\ var result: [len]CpuFeature = undefined;
1354 \\1354 \\
...@@ -1417,7 +1417,7 @@ fn processOneTarget(job: Job) anyerror!void {...@@ -1417,7 +1417,7 @@ fn processOneTarget(job: Job) anyerror!void {
1417 \\ const ti = @typeInfo(Feature);1417 \\ const ti = @typeInfo(Feature);
1418 \\ for (&result, 0..) |*elem, i| {1418 \\ for (&result, 0..) |*elem, i| {
1419 \\ elem.index = i;1419 \\ elem.index = i;
1420 \\ elem.name = ti.Enum.fields[i].name;1420 \\ elem.name = ti.@"enum".fields[i].name;
1421 \\ }1421 \\ }
1422 \\ break :blk result;1422 \\ break :blk result;
1423 \\};1423 \\};
tools/update_spirv_features.zig+2-2
...@@ -129,7 +129,7 @@ pub fn main() !void {...@@ -129,7 +129,7 @@ pub fn main() !void {
129 \\129 \\
130 \\pub const all_features = blk: {130 \\pub const all_features = blk: {
131 \\ @setEvalBranchQuota(2000);131 \\ @setEvalBranchQuota(2000);
132 \\ const len = @typeInfo(Feature).Enum.fields.len;132 \\ const len = @typeInfo(Feature).@"enum".fields.len;
133 \\ std.debug.assert(len <= CpuFeature.Set.needed_bit_count);133 \\ std.debug.assert(len <= CpuFeature.Set.needed_bit_count);
134 \\ var result: [len]CpuFeature = undefined;134 \\ var result: [len]CpuFeature = undefined;
135 \\135 \\
...@@ -210,7 +210,7 @@ pub fn main() !void {...@@ -210,7 +210,7 @@ pub fn main() !void {
210 \\ const ti = @typeInfo(Feature);210 \\ const ti = @typeInfo(Feature);
211 \\ for (&result, 0..) |*elem, i| {211 \\ for (&result, 0..) |*elem, i| {
212 \\ elem.index = i;212 \\ elem.index = i;
213 \\ elem.name = ti.Enum.fields[i].name;213 \\ elem.name = ti.@"enum".fields[i].name;
214 \\ }214 \\ }
215 \\ break :blk result;215 \\ break :blk result;
216 \\};216 \\};