Why are tabs allowed in code, but not in comments?

I just got this interesting bug report for the sokol-shdc shader compiler:

…long story short: a tab slips into a comment in a generated Zig file via some very obscure code-generation situation involving third-party libraries, and this causes a Zig compilation error.

So I immediately thought “yeah figures, Zig doesn’t allow tabs”, but that’s outdated information, tabs are actually allowed in regular code now.

But now the confusing thing: tabs in comments are still a compilation error. Is there a rational explanation for this, or just an oversight?

6 Likes

some relevant facts:
0.7.0 ignored tabs in comments but complained about tabs in source code Compiler Explorer.
in 0.10.0 compiler started to accept tabs in code and in comments. Compiler Explorer
And finally in 0.14.0 compiler started reject tabs in comments but not in code. Compiler Explorer

Also issue about it grammar clarifications regarding tabs and carriage returns · Issue #38 · ziglang/zig-spec · GitHub

5 Likes