Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Private Function

checkLabelRedefinition

Private Function
std.zig.AstGen.checkLabelRedefinition
fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: Ast.TokenIndex) !void

Params

File

zig/AstGen.zig:2447
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
fn checkLabelRedefinition(astgen: *AstGen, parent_scope: *Scope, label: Ast.TokenIndex) !void {
    // Look for the label in the scope.
    find_scope: switch (parent_scope.unwrap()) {
        .gen_zir => |gen_zir| {
            if (gen_zir.label) |prev_label| {
                if (try astgen.tokenIdentEql(label, prev_label.token)) {
                    const label_name = try astgen.identifierTokenString(label);
                    return astgen.failTokNotes(label, "redefinition of label '{s}'", .{
                        label_name,
                    }, &[_]u32{
                        try astgen.errNoteTok(
                            prev_label.token,
                            "previous definition here",
                            .{},
                        ),
                    });
                }
            }
            continue :find_scope gen_zir.parent.unwrap();
        },
        .local_val => |local_val| continue :find_scope local_val.parent.unwrap(),
        .local_ptr => |local_ptr| continue :find_scope local_ptr.parent.unwrap(),
        .defer_normal, .defer_error => |defer_scope| continue :find_scope defer_scope.parent.unwrap(),
        .namespace => break :find_scope,
        .top => unreachable,
    }
}