Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

addErrorsFromExpr

main.addErrorsFromExpr
fn addErrorsFromExpr(
    decl_index: Decl.Index,
    out: *std.array_hash_map.String(ErrorIdentifier),
    node: Ast.Node.Index,
) Oom!void

File

lib/docs/wasm/main.zig:317

Code

fn addErrorsFromExpr(
    decl_index: Decl.Index,
    out: *std.array_hash_map.String(ErrorIdentifier),
    node: Ast.Node.Index,
) Oom!void {
    const decl = decl_index.get();
    const ast = decl.file.get_ast();

    switch (decl.file.categorize_expr(node)) {
        .error_set => |n| switch (ast.nodeTag(n)) {
            .error_set_decl => {
                try addErrorsFromNode(decl_index, out, node);
            },
            .merge_error_sets => {
                const lhs, const rhs = ast.nodeData(n).node_and_node;
                try addErrorsFromExpr(decl_index, out, lhs);
                try addErrorsFromExpr(decl_index, out, rhs);
            },
            else => unreachable,
        },
        .alias => |aliasee| {
            try addErrorsFromDecl(aliasee, out);
        },
        else => return,
    }
}