feature. See also
. The project being documented here (as the example) is the Zig library itself.
AstGen.arrayType
fn arrayType(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) !Zir.Inst.Ref
File
Code
fn arrayType(gz: *GenZir, scope: *Scope, ri: ResultInfo, node: Ast.Node.Index) !Zir.Inst.Ref {
const astgen = gz.astgen;
const tree = astgen.tree;
const len_node, const elem_type_node = tree.nodeData(node).node_and_node;
if (tree.nodeTag(len_node) == .identifier and
mem.eql(u8, tree.tokenSlice(tree.nodeMainToken(len_node)), "_"))
{
return astgen.failNode(len_node, "unable to infer array size", .{});
}
const len = try reachableExprComptime(gz, scope, .{ .rl = .{ .coerced_ty = .usize_type } }, len_node, node, .type);
const elem_type = try typeExpr(gz, scope, elem_type_node);
const result = try gz.addPlNode(.array_type, node, Zir.Inst.Bin{
.lhs = len,
.rhs = elem_type,
});
return rvalue(gz, ri, result, node);
}