ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.95k stars 2.55k forks source link

Regression where writer now requires @setEvalBranchQuota to print #18888

Open scheibo opened 9 months ago

scheibo commented 9 months ago

Zig Version

0.12.0-dev.2665+919a3bae1

Steps to Reproduce and Observed Behavior

$ git clone https://github.com/pkmn/engine.git
<snip>
$ cd engine
$ git reset --hard 49f6bf262f150b8f45698f4ef7952ac979a92932
$ zig version
0.12.0-dev.2638+38c2a2573
$ zig build dump -- protocol
<snip> (prints and exits successfully)

# change zig versions
$ zig version
0.12.0-dev.2665+919a3bae1
$ zig build dump -- protocol
dump
└─ run dump
   └─ zig build-exe dump Debug native 1 errors
src/tools/dump.zig:73:44: error: evaluation exceeded 1000 backwards branches
                                try w.print("    \"{s}\"", .{field.name});
                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/tools/dump.zig:73:44: note: use @setEvalBranchQuota() to raise the branch limit from 1000

Expected Behavior

This print call should continue to not need any branch quota. If I add a @setEvalBranchQuota(1) before the line in the error message prior to 0.12.0-dev.2665+919a3bae1 then it still works, but after that build the code will not compile without @setEvalBranchQuota(2004). This doesn't seem to be specifically related to the buffered writer as commenting out that part and writing directly to standard out still fails in the same place.

Vexu commented 9 months ago

Probably caused by #17634

rohlem commented 9 months ago

Linking https://github.com/ziglang/zig/issues/16983#issuecomment-1722226184 for ideas that could help prevent this class of regression.