I am puzzled by the output of the following program:
const std = @import("std");
pub fn main() void {
const s = .{9, 2};
const T = @TypeOf(s);
const S = @typeInfo(T).Struct;
inline for (S.fields) |f| {
std.debug.print("field {}\n", .{f});
}
inline for (S.decls) |d| {
std.debug.print("decl {}\n", .{d});
}
std.debug.print("{}\n", .{@field(s, "len")});
}
It prints two fields (@"0"
and @"1"
), zero decls, but somehow len
is also a field.
Ah, looks like in my attempt to ask the question I nerd-sniped myself. Turns out this is hard-coded on a pretty deep level: