Lobsters | 📄 原文链接 | 2026-10-26 收录

Zig 十年老提案落地:歧义优先级现在必须加括号

来源:ziglang.org — 2026-10-24

📋 概述

Zig 仓库里第二老的未关闭提案 issue #114 从 2016 年 2 月挂到现在,终于由贡献者 CMDRZero 在主线实现:当运算符组合的优先级本身有歧义时,编译器不再默默按一张难记的优先级表求值,而是要求你写括号。作者用 orelse 与 == 的组合说明,以前 x orelse y == z 会被当成 (x orelse y) == z,现在直接报错;而 x + y * z 这样有明确定义的常见组合依然不用括号,全库迁移只改了 353 行。

🔑 核心要点

💡 金句

Ten years later, that proposal has been implemented in the master branch version of Zig thanks to contributor CMDRZero.
← 返回 Lobsters 首页