blocks

    test.zig

    1. /home/andy/dev/zig/docgen_tmp/test.zig:5:5: error: use of undeclared identifier 'x'
    2. x += 1;
    3. ^

    Blocks are expressions. When labeled, break can be used to return a value from the block:

    1. $ zig test test.zig
    2. All tests passed.

    Here, blk can be any name.

    See also:

    test.zig

    1. $ zig test test.zig
    2. /home/andy/dev/zig/docgen_tmp/test.zig:6:9: error: redefinition of 'pi'
    3. var pi: i32 = 1234;
    4. /home/andy/dev/zig/docgen_tmp/test.zig:1:1: note: previous definition is here
    5. const pi = 3.14;
    6. ^

    Because of this, when you read Zig code you can rely on an identifier always meaning the same thing, within the scope it is defined. Note that you can, however use the same name if the scopes are separate:

    1. $ zig test test.zig
    2. Test 1/1 separate scopes...OK