# Is the syntax inconsistency intentional?

**URL:** <https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486>\
**Category:** Help\
**Tags:** language, compiler\
**Created:** [September 5, 2026, 8:46am UTC](https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486 "2026-09-05T08:46:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zigo](https://ziggit.dev/user_avatar/ziggit.dev/zigo/32/2414_2.png) [@zigo](https://ziggit.dev/u/zigo)\
**Post date:** [September 5, 2026, 8:46am UTC](https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486/1 "2026-09-05T08:46:40Z")

</div>

```zig
const print = @import("std").debug.print;

fn bar(n: i8) !usize {
    return if (n <= 0) error.A else 123;
}

pub fn main() !void {
    while (bar(0)) |_| { // The capture is optional.
        unreachable;
    } else |_| {
        print("while captures\n", .{});
    }

    while (bar(0)) { // compiles
        unreachable;
    } else |_| {
        print("while no capture\n", .{});
    }

    if (bar(0)) |_| { // The capture is required.
        unreachable;
    } else |_| {
        print("if captures\n", .{});
    }
    
    // Only this doesn't compile.
    if (bar(0)) {
        unreachable;
    } else |_| {
        print("if no capture\n", .{});
    }
}

```

---

<div class="post-metadata">

**Author:** ![rpkak](https://ziggit.dev/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@rpkak](https://ziggit.dev/u/rpkak)\
**Post date:** [September 5, 2026, 9:00am UTC](https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486/2 "2026-09-05T09:00:57Z")

</div>

> [@zigo](#):
>
> ```zig
> while (bar(0)) { // compiles
> unreachable;
> } else |_| {
> print("while no capture\n", .{});
> }
> 
> ```

I think this should not compile.

---

<div class="post-metadata">

**Author:** ![zigo](https://ziggit.dev/user_avatar/ziggit.dev/zigo/32/2414_2.png) [@zigo](https://ziggit.dev/u/zigo)\
**Post date:** [September 5, 2026, 9:19am UTC](https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486/3 "2026-09-05T09:19:31Z")

</div>

> [@rpkak](#):
>
> I think this should not compile.

It does compile now. So you think it is a bug?

---

<div class="post-metadata">

**Author:** ![rpkak](https://ziggit.dev/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@rpkak](https://ziggit.dev/u/rpkak)\
**Post date:** [September 5, 2026, 9:22am UTC](https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486/4 "2026-09-05T09:22:23Z")

</div>

Yes. I’m currently trying to fix it in the compiler.

---

<div class="post-metadata">

**Author:** ![rpkak](https://ziggit.dev/letter_avatar_proxy/v4/letter/r/a4c791/32.png) [@rpkak](https://ziggit.dev/u/rpkak)\
**Post date:** [September 5, 2026, 10:36am UTC](https://ziggit.dev/t/is-the-syntax-inconsistency-intentional/17486/5 "2026-09-05T10:36:59Z")

</div>

[#36757](https://codeberg.org/ziglang/zig/pulls/36757)
