# Zig finally forces parentheses on ambiguous operator precedence after a 10-year-old proposal

Original title: Partial Operator Precedence

> Hacker News story 50340195 · language: en · submitted 2026-11-02
> Web version: https://zeli.app/story/50340195
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 105 · by [tosh](<https://news.ycombinator.com/user?id=tosh>) · 💬 66
[original](<https://ziglang.org/devlog/2026/#2026-10-24>) · [HN discussion](<https://news.ycombinator.com/item?id=50340195>)

## Summary

Zig has implemented a proposal from 2016 that requires parentheses for ambiguous operator combinations, ending years of confusion over precedence rules. The change affects only rare cases—about 353 lines in the million-line codebase—while common expressions like `x + y * z` remain unchanged. Developers can fix code manually or use `zig fmt --upgrade` to automatically insert parentheses, though manual review is recommended to catch hidden bugs.

## Key quote

> No matter how experienced you are with Zig, it’s unlikely that you’d be able to explain the evaluation order of the following expression without looking up the precedence rules: a & b + c * d >> e | f orelse g() catch h + i == j or k and l

## HN discussion (66 comments)

### [rwoerz](<https://news.ycombinator.com/item?id=50378617>)

> Funny that they named it "orelse" which sounds like a conditional threat to me :)

### [nitnelave](<https://news.ycombinator.com/item?id=50378185>)

> A bit over 10 years ago, I remember implementing partial operator precedence in Bison, for an internship. I think it was merged, but I'm not sure anyone ever used it for anything :) The age of Bison for new parsers was already mostly over

### [raphlinus](<https://news.ycombinator.com/item?id=50376481>)

> Worth noting, WGSL does this too, and is mostly a bit stricter than Zig: `a + b & c` and `a << b & c` are errors in WGSL but accepted by Zig. (Quick: off the top of your head, how do those parse)?
>
> I'm thinking of doing this for symbolasm also.

### [v9v](<https://news.ycombinator.com/item?id=50377379>)

> Something very similar was in Fortress, see 16.2 here https://www.ccs.neu.edu/home/samth/fortress-spec.pdf

### [skrebbel](<https://news.ycombinator.com/item?id=50376441>)

> I never realized that languages have so many strict precedence levels because that’s easier to implement than not having them.
>
> This here seems like a very good idea and I hope other languages in active development take note. And als JS’ Prettier, which actively removes parentheses like these.

---

## Cite

- Page: https://zeli.app/story/50340195
- Date: 2026-11-02
- Source: ziglang.org (https://ziglang.org/devlog/2026/#2026-10-24)
- Hacker News: https://news.ycombinator.com/item?id=50340195

## Other languages

- zh: https://zeli.app/zh/story/50340195 · markdown: https://zeli.app/zh/story/50340195.md
- ja: https://zeli.app/ja/story/50340195 · markdown: https://zeli.app/ja/story/50340195.md
- ko: https://zeli.app/ko/story/50340195 · markdown: https://zeli.app/ko/story/50340195.md
- de: https://zeli.app/de/story/50340195 · markdown: https://zeli.app/de/story/50340195.md
- es: https://zeli.app/es/story/50340195 · markdown: https://zeli.app/es/story/50340195.md
- ru: https://zeli.app/ru/story/50340195 · markdown: https://zeli.app/ru/story/50340195.md
