Skip to content

Commit

Permalink
std: update std.builtin.Type fields to follow naming conventions
Browse files Browse the repository at this point in the history
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of ziglang#9938.
  • Loading branch information
mlugg committed Aug 28, 2024
1 parent 1a178d4 commit 0fe3fd0
Show file tree
Hide file tree
Showing 336 changed files with 4,107 additions and 4,114 deletions.
24 changes: 12 additions & 12 deletions doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -4299,7 +4299,7 @@ comptime {
Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
</p>
<p>
Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
Asserts that {#syntax#}@typeInfo(DestType) != .pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@ptrFromInt{#endsyntax#} if you need this.
</p>
<p>
Can be used for these things for example:
Expand Down Expand Up @@ -4517,7 +4517,7 @@ comptime {
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
<p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
<p>{#syntax#}@typeInfo(@TypeOf(ptr)).pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
<p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p>
{#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgWeak#}
{#header_close#}
Expand Down Expand Up @@ -4549,7 +4549,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#syntax#}T{#endsyntax#} must be a pointer, a {#syntax#}bool{#endsyntax#}, a float,
an integer or an enum.
</p>
<p>{#syntax#}@typeInfo(@TypeOf(ptr)).Pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
<p>{#syntax#}@typeInfo(@TypeOf(ptr)).pointer.alignment{#endsyntax#} must be {#syntax#}>= @sizeOf(T).{#endsyntax#}</p>
<p>{#syntax#}AtomicOrder{#endsyntax#} can be found with {#syntax#}@import("std").builtin.AtomicOrder{#endsyntax#}.</p>
{#see_also|@atomicStore|@atomicLoad|@atomicRmw|@fence|@cmpxchgStrong#}
{#header_close#}
Expand Down Expand Up @@ -4672,7 +4672,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
<p>
Floored division. Rounds toward negative infinity. For unsigned integers it is
the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
{#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
{#syntax#}!(@typeInfo(T) == .int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
</p>
<ul>
<li>{#syntax#}@divFloor(-5, 3) == -2{#endsyntax#}</li>
Expand All @@ -4686,7 +4686,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
<p>
Truncated division. Rounds toward zero. For unsigned integers it is
the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
{#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
{#syntax#}!(@typeInfo(T) == .int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
</p>
<ul>
<li>{#syntax#}@divTrunc(-5, 3) == -1{#endsyntax#}</li>
Expand Down Expand Up @@ -5320,8 +5320,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
any bits that disagree with the resultant sign bit are shifted out.
</p>
<p>
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior.
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(T).int.bits{#endsyntax#} is undefined behavior.
</p>
<p>
{#syntax#}comptime_int{#endsyntax#} is modeled as an integer with an infinite number of bits,
Expand All @@ -5337,8 +5337,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
Performs {#syntax#}a << b{#endsyntax#} and returns a tuple with the result and a possible overflow bit.
</p>
<p>
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(@TypeOf(a)).Int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(@TypeOf(a)).Int.bits{#endsyntax#} is undefined behavior.
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(@TypeOf(a)).int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(@TypeOf(a)).int.bits{#endsyntax#} is undefined behavior.
</p>
{#see_also|@shlExact|@shrExact#}
{#header_close#}
Expand All @@ -5350,8 +5350,8 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
that the shift will not shift any 1 bits out.
</p>
<p>
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).Int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(T).Int.bits{#endsyntax#} is undefined behavior.
The type of {#syntax#}shift_amt{#endsyntax#} is an unsigned integer with {#syntax#}log2(@typeInfo(T).int.bits){#endsyntax#} bits.
This is because {#syntax#}shift_amt >= @typeInfo(T).int.bits{#endsyntax#} is undefined behavior.
</p>
{#see_also|@shlExact|@shlWithOverflow#}
{#header_close#}
Expand Down Expand Up @@ -5405,7 +5405,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
This size may contain padding bytes. If there were two consecutive T in memory, the padding would be the offset
in bytes between element at index 0 and the element at index 1. For {#link|integer|Integers#},
consider whether you want to use {#syntax#}@sizeOf(T){#endsyntax#} or
{#syntax#}@typeInfo(T).Int.bits{#endsyntax#}.
{#syntax#}@typeInfo(T).int.bits{#endsyntax#}.
</p>
<p>
This function measures the size at runtime. For types that are disallowed at runtime, such as
Expand Down
4 changes: 2 additions & 2 deletions doc/langref/inline_prong_range.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn isFieldOptional(comptime T: type, field_index: usize) !bool {
const fields = @typeInfo(T).Struct.fields;
const fields = @typeInfo(T).@"struct".fields;
return switch (field_index) {
inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional,
inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .optional,
else => return error.IndexOutOfBounds,
};
}
Expand Down
6 changes: 3 additions & 3 deletions doc/langref/poc_printValue_fn.zig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const Writer = struct {
pub fn printValue(self: *Writer, value: anytype) !void {
switch (@typeInfo(@TypeOf(value))) {
.Int => {
.int => {
return self.writeInt(value);
},
.Float => {
.float => {
return self.writeFloat(value);
},
.Pointer => {
.pointer => {
return self.write(value);
},
else => {
Expand Down
6 changes: 3 additions & 3 deletions doc/langref/test_enums.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ const Small = enum {
four,
};
test "std.meta.Tag" {
try expect(@typeInfo(Small).Enum.tag_type == u2);
try expect(@typeInfo(Small).@"enum".tag_type == u2);
}

// @typeInfo tells us the field count and the fields names:
test "@typeInfo" {
try expect(@typeInfo(Small).Enum.fields.len == 4);
try expect(mem.eql(u8, @typeInfo(Small).Enum.fields[1].name, "two"));
try expect(@typeInfo(Small).@"enum".fields.len == 4);
try expect(mem.eql(u8, @typeInfo(Small).@"enum".fields[1].name, "two"));
}

// @tagName gives a [:0]const u8 representation of an enum value:
Expand Down
4 changes: 2 additions & 2 deletions doc/langref/test_error_union.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ test "error union" {
foo = error.SomeError;

// Use compile-time reflection to access the payload type of an error union:
try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.payload == i32);
try comptime expect(@typeInfo(@TypeOf(foo)).error_union.payload == i32);

// Use compile-time reflection to access the error set type of an error union:
try comptime expect(@typeInfo(@TypeOf(foo)).ErrorUnion.error_set == anyerror);
try comptime expect(@typeInfo(@TypeOf(foo)).error_union.error_set == anyerror);
}

// test
6 changes: 3 additions & 3 deletions doc/langref/test_fn_reflection.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const math = std.math;
const testing = std.testing;

test "fn reflection" {
try testing.expect(@typeInfo(@TypeOf(testing.expect)).Fn.params[0].type.? == bool);
try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).Fn.return_type.? == testing.TmpDir);
try testing.expect(@typeInfo(@TypeOf(testing.expect)).@"fn".params[0].type.? == bool);
try testing.expect(@typeInfo(@TypeOf(testing.tmpDir)).@"fn".return_type.? == testing.TmpDir);

try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).Fn.is_generic);
try testing.expect(@typeInfo(@TypeOf(math.Log2Int)).@"fn".is_generic);
}

// test
4 changes: 2 additions & 2 deletions doc/langref/test_inline_else.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const AnySlice = union(enum) {
};

fn withFor(any: AnySlice) usize {
const Tag = @typeInfo(AnySlice).Union.tag_type.?;
inline for (@typeInfo(Tag).Enum.fields) |field| {
const Tag = @typeInfo(AnySlice).@"union".tag_type.?;
inline for (@typeInfo(Tag).@"enum".fields) |field| {
// With `inline for` the function gets generated as
// a series of `if` statements relying on the optimizer
// to convert it to a switch.
Expand Down
4 changes: 2 additions & 2 deletions doc/langref/test_inline_switch.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const expect = std.testing.expect;
const expectError = std.testing.expectError;

fn isFieldOptional(comptime T: type, field_index: usize) !bool {
const fields = @typeInfo(T).Struct.fields;
const fields = @typeInfo(T).@"struct".fields;
return switch (field_index) {
// This prong is analyzed twice with `idx` being a
// comptime-known value each time.
inline 0, 1 => |idx| @typeInfo(fields[idx].type) == .Optional,
inline 0, 1 => |idx| @typeInfo(fields[idx].type) == .optional,
else => return error.IndexOutOfBounds,
};
}
Expand Down
2 changes: 1 addition & 1 deletion doc/langref/test_optional_type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test "optional type" {
foo = 1234;

// Use compile-time reflection to access the child type of the optional:
try comptime expect(@typeInfo(@TypeOf(foo)).Optional.child == i32);
try comptime expect(@typeInfo(@TypeOf(foo)).optional.child == i32);
}

// test
2 changes: 1 addition & 1 deletion doc/langref/test_pointer_casting.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test "pointer casting" {

test "pointer child type" {
// pointer types have a `child` field which tells you the type they point to.
try expect(@typeInfo(*u32).Pointer.child == u32);
try expect(@typeInfo(*u32).pointer.child == u32);
}

// test
2 changes: 1 addition & 1 deletion doc/langref/test_variable_alignment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test "variable alignment" {
try expect(@TypeOf(&x) == *i32);
try expect(*i32 == *align(align_of_i32) i32);
if (builtin.target.cpu.arch == .x86_64) {
try expect(@typeInfo(*i32).Pointer.alignment == 4);
try expect(@typeInfo(*i32).pointer.alignment == 4);
}
}

Expand Down
2 changes: 1 addition & 1 deletion doc/langref/test_variable_func_alignment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const expect = @import("std").testing.expect;
var foo: u8 align(4) = 100;

test "global variable alignment" {
try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
try expect(@typeInfo(@TypeOf(&foo)).pointer.alignment == 4);
try expect(@TypeOf(&foo) == *align(4) u8);
const as_pointer_to_array: *align(4) [1]u8 = &foo;
const as_slice: []align(4) u8 = as_pointer_to_array;
Expand Down
2 changes: 1 addition & 1 deletion doc/langref/test_variadic_function.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;

test "variadic function" {
try testing.expect(printf("Hello, world!\n") == 14);
try testing.expect(@typeInfo(@TypeOf(printf)).Fn.is_var_args);
try testing.expect(@typeInfo(@TypeOf(printf)).@"fn".is_var_args);
}

// test
Expand Down
28 changes: 14 additions & 14 deletions lib/compiler/aro/aro/Attribute.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn requiredArgCount(attr: Tag) u32 {
comptime {
const fields = std.meta.fields(@field(attributes, @tagName(tag)));
for (fields) |arg_field| {
if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .Optional) needed += 1;
if (!mem.eql(u8, arg_field.name, "__name_tok") and @typeInfo(arg_field.type) != .optional) needed += 1;
}
}
return needed;
Expand All @@ -93,7 +93,7 @@ pub fn maxArgCount(attr: Tag) u32 {

fn UnwrapOptional(comptime T: type) type {
return switch (@typeInfo(T)) {
.Optional => |optional| optional.child,
.optional => |optional| optional.child,
else => T,
};
}
Expand All @@ -110,7 +110,7 @@ pub const Formatting = struct {

if (fields.len == 0) unreachable;
const Unwrapped = UnwrapOptional(fields[0].type);
if (@typeInfo(Unwrapped) != .Enum) unreachable;
if (@typeInfo(Unwrapped) != .@"enum") unreachable;

return if (Unwrapped.opts.enum_kind == .identifier) "'" else "\"";
},
Expand All @@ -127,9 +127,9 @@ pub const Formatting = struct {

if (fields.len == 0) unreachable;
const Unwrapped = UnwrapOptional(fields[0].type);
if (@typeInfo(Unwrapped) != .Enum) unreachable;
if (@typeInfo(Unwrapped) != .@"enum") unreachable;

const enum_fields = @typeInfo(Unwrapped).Enum.fields;
const enum_fields = @typeInfo(Unwrapped).@"enum".fields;
@setEvalBranchQuota(3000);
const quote = comptime quoteChar(@enumFromInt(@intFromEnum(tag)));
comptime var values: []const u8 = quote ++ enum_fields[0].name ++ quote;
Expand All @@ -152,7 +152,7 @@ pub fn wantsIdentEnum(attr: Tag) bool {

if (fields.len == 0) return false;
const Unwrapped = UnwrapOptional(fields[0].type);
if (@typeInfo(Unwrapped) != .Enum) return false;
if (@typeInfo(Unwrapped) != .@"enum") return false;

return Unwrapped.opts.enum_kind == .identifier;
},
Expand All @@ -165,7 +165,7 @@ pub fn diagnoseIdent(attr: Tag, arguments: *Arguments, ident: []const u8) ?Diagn
const fields = std.meta.fields(@field(attributes, @tagName(tag)));
if (fields.len == 0) unreachable;
const Unwrapped = UnwrapOptional(fields[0].type);
if (@typeInfo(Unwrapped) != .Enum) unreachable;
if (@typeInfo(Unwrapped) != .@"enum") unreachable;
if (std.meta.stringToEnum(Unwrapped, normalize(ident))) |enum_val| {
@field(@field(arguments, @tagName(tag)), fields[0].name) = enum_val;
return null;
Expand Down Expand Up @@ -239,7 +239,7 @@ fn diagnoseField(
const key = p.comp.interner.get(res.val.ref());
switch (key) {
.int => {
if (@typeInfo(Wanted) == .Int) {
if (@typeInfo(Wanted) == .int) {
@field(@field(arguments, decl.name), field.name) = res.val.toInt(Wanted, p.comp) orelse return .{
.tag = .attribute_int_out_of_range,
.extra = .{ .str = try res.str(p) },
Expand All @@ -258,7 +258,7 @@ fn diagnoseField(
}
@field(@field(arguments, decl.name), field.name) = try p.removeNull(res.val);
return null;
} else if (@typeInfo(Wanted) == .Enum and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) {
} else if (@typeInfo(Wanted) == .@"enum" and @hasDecl(Wanted, "opts") and Wanted.opts.enum_kind == .string) {
const str = bytes[0 .. bytes.len - 1];
if (std.meta.stringToEnum(Wanted, str)) |enum_val| {
@field(@field(arguments, decl.name), field.name) = enum_val;
Expand Down Expand Up @@ -293,7 +293,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess
Alignment => .alignment,
CallingConvention => .identifier,
else => switch (@typeInfo(Expected)) {
.Enum => if (Expected.opts.enum_kind == .string) .string else .identifier,
.@"enum" => if (Expected.opts.enum_kind == .string) .string else .identifier,
else => unreachable,
},
}, .actual = actual } },
Expand All @@ -303,7 +303,7 @@ fn invalidArgMsg(comptime Expected: type, actual: ArgumentType) Diagnostics.Mess
pub fn diagnose(attr: Tag, arguments: *Arguments, arg_idx: u32, res: Parser.Result, node: Tree.Node, p: *Parser) !?Diagnostics.Message {
switch (attr) {
inline else => |tag| {
const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)];
const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)];
const max_arg_count = comptime maxArgCount(tag);
if (arg_idx >= max_arg_count) return Diagnostics.Message{
.tag = .attribute_too_many_args,
Expand Down Expand Up @@ -641,7 +641,7 @@ const attributes = struct {
pub const Tag = std.meta.DeclEnum(attributes);

pub const Arguments = blk: {
const decls = @typeInfo(attributes).Struct.decls;
const decls = @typeInfo(attributes).@"struct".decls;
var union_fields: [decls.len]ZigType.UnionField = undefined;
for (decls, &union_fields) |decl, *field| {
field.* = .{
Expand All @@ -652,7 +652,7 @@ pub const Arguments = blk: {
}

break :blk @Type(.{
.Union = .{
.@"union" = .{
.layout = .auto,
.tag_type = null,
.fields = &union_fields,
Expand All @@ -662,7 +662,7 @@ pub const Arguments = blk: {
};

pub fn ArgumentsForTag(comptime tag: Tag) type {
const decl = @typeInfo(attributes).Struct.decls[@intFromEnum(tag)];
const decl = @typeInfo(attributes).@"struct".decls[@intFromEnum(tag)];
return @field(attributes, decl.name);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/compiler/aro/aro/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub const Environment = struct {
var env: Environment = .{};
errdefer env.deinit(allocator);

inline for (@typeInfo(@TypeOf(env)).Struct.fields) |field| {
inline for (@typeInfo(@TypeOf(env)).@"struct".fields) |field| {
std.debug.assert(@field(env, field.name) == null);

var env_var_buf: [field.name.len]u8 = undefined;
Expand All @@ -78,7 +78,7 @@ pub const Environment = struct {

/// Use this only if environment slices were allocated with `allocator` (such as via `loadAll`)
pub fn deinit(self: *Environment, allocator: std.mem.Allocator) void {
inline for (@typeInfo(@TypeOf(self.*)).Struct.fields) |field| {
inline for (@typeInfo(@TypeOf(self.*)).@"struct".fields) |field| {
if (@field(self, field.name)) |slice| {
allocator.free(slice);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/compiler/aro/aro/Tree.zig
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void {
switch (attr.tag) {
inline else => |tag| {
const args = @field(attr.args, @tagName(tag));
const fields = @typeInfo(@TypeOf(args)).Struct.fields;
const fields = @typeInfo(@TypeOf(args)).@"struct".fields;
if (fields.len == 0) {
try writer.writeByte('\n');
return;
Expand All @@ -724,7 +724,7 @@ fn dumpAttribute(tree: *const Tree, attr: Attribute, writer: anytype) !void {
Interner.Ref => try writer.print("\"{s}\"", .{tree.interner.get(@field(args, f.name)).bytes}),
?Interner.Ref => try writer.print("\"{?s}\"", .{if (@field(args, f.name)) |str| tree.interner.get(str).bytes else null}),
else => switch (@typeInfo(f.type)) {
.Enum => try writer.writeAll(@tagName(@field(args, f.name))),
.@"enum" => try writer.writeAll(@tagName(@field(args, f.name))),
else => try writer.print("{any}", .{@field(args, f.name)}),
},
}
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/aro/aro/Value.zig
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn intern(comp: *Compilation, k: Interner.Key) !Value {

pub fn int(i: anytype, comp: *Compilation) !Value {
const info = @typeInfo(@TypeOf(i));
if (info == .ComptimeInt or info.Int.signedness == .unsigned) {
if (info == .comptime_int or info.int.signedness == .unsigned) {
return intern(comp, .{ .int = .{ .u64 = i } });
} else {
return intern(comp, .{ .int = .{ .i64 = i } });
Expand Down
Loading

0 comments on commit 0fe3fd0

Please sign in to comment.