Where is the identifier "EnumLiteral" declared?

In reading zig/lib/std/log.zig at master · ziglang/zig · GitHub, I found there are several uses of “@Type(.EnumLiteral),”, but I failed to find how “EnumLiteral” is declared. Is it a builtin?

The @Type builtin takes an argument of type std.builtin.Type, so its argument is coerced to that type. If you look at builtin.zig in the standard library, you should find a declaration pub const Type = ... - that’s what it’s referring to. In this case, it’s a tagged union, describing all the different kinds of type in Zig. Usually, you’d initialize a tagged union something like .{ .foo = payload }, Since the EnumLiteral field has a void payload, you’re allowed to just write .EnumLiteral, which is equivalent to .{ .EnumLiteral = {} } (where {} is how you write a void value).

1 Like

Got it. Many thanks.