ziglang / zig

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

Error message was not helpful at all #16829

Closed CGQAQ closed 10 months ago

CGQAQ commented 11 months ago

Zig Version

0.11.0

Steps to Reproduce and Observed Output

Recently I am playing with bun.js source code, and it was using outdated zig version in here

and when I try to compile it using 0.11.0 stable, lots of unhelpful message was given to me

  1. several error directly point to std code, with no clue of where was the actually bunjs code to cause it
    1. /snap/zig/8241/lib/std/mem/Allocator.zig:113:28: error: ptr must be a single item pointer
  2. a bunch of error: unable to resolve inferred error set with no reason about which point of the compilation that zig was confused and not able to infering the error set, and what makes zig so confusing ( I have read 0.11.0 changelog, but didn't see any error related will affect this)
  3. the same error message prints out several times, see below image

When I see a bunch of compilation errors, typically I will look through top down, and solve them one by one, and typically those errors will have some relations(making them error groups that look like they are some of the error 'stack trace' to make it clearer to the programmers and make it easier to solve. But in these compilation errors that zig gives me, I can't tell what the relation between them is, what I can see is several errors laid out flat with some errors repeated, and makes me have no clue how to solve these errors

Details

``` zig build-obj bun-debug Debug native-native-gnu.2.27: error: the following command failed with 36 compilation errors: /snap/zig/8241/zig build-obj /root/repos/bun/root.zig -lc -fno-emit-bin -fno-strip --eh-frame-hdr --emit-relocs -ffunction-sections --cache-dir /root/repos/bun/zig-cache --global-cache-dir /root/.cache/zig --name bun-debug -fno-compiler-rt -fno-stack-check -fno-omit-frame-pointer -target native-native-gnu.2.27 -mcpu haswell --mod build_options::/root/repos/bun/zig-cache/c/d5f6cbabcfba908946685105eddb487e/options.zig --mod async_io::/root/repos/bun/src/io/io_linux.zig --deps async_io,build_options --main-pkg-path /root/repos/bun --listen=- Build Summary: 1/4 steps succeeded; 1 failed (disable with --summary none) install transitive failure └─ obj transitive failure └─ zig build-obj bun-debug Debug native-native-gnu.2.27 36 errors src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ referenced by: run: src/css_scanner.zig:950:62 buildWithResolveResultEager__anon_52208: src/bundler.zig:1006:31 remaining reference traces hidden; use '-freference-trace' to see all reference traces src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1046:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, false); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ /snap/zig/8241/lib/std/mem/Allocator.zig:113:28: error: ptr must be a single item pointer if (info.size != .One) @compileError("ptr must be a single item pointer"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /snap/zig/8241/lib/std/json/stringify.zig:493:37: error: member function expected 2 argument(s), found 1 return value.jsonStringify(self); ~~~~~^~~~~~~~~~~~~~ src/env_loader.zig:872:9: note: function declared here pub fn jsonStringify(self: *const @This(), options: anytype, writer: anytype) !void { ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/js_parser.zig:17797:53: error: unable to resolve inferred error set p.visitStmts(&_stmts, kind) catch unreachable; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ src/js_parser.zig:17797:53: error: unable to resolve inferred error set p.visitStmts(&_stmts, kind) catch unreachable; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ src/js_parser.zig:17797:53: error: unable to resolve inferred error set p.visitStmts(&_stmts, kind) catch unreachable; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ src/js_parser.zig:17797:53: error: unable to resolve inferred error set p.visitStmts(&_stmts, kind) catch unreachable; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ src/js_parser.zig:17797:53: error: unable to resolve inferred error set p.visitStmts(&_stmts, kind) catch unreachable; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ src/js_parser.zig:17797:53: error: unable to resolve inferred error set p.visitStmts(&_stmts, kind) catch unreachable; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /snap/zig/8241/lib/std/mem/Allocator.zig:113:28: error: ptr must be a single item pointer if (info.size != .One) @compileError("ptr must be a single item pointer"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /snap/zig/8241/lib/std/mem/Allocator.zig:113:28: error: ptr must be a single item pointer if (info.size != .One) @compileError("ptr must be a single item pointer"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /snap/zig/8241/lib/std/mem/Allocator.zig:113:28: error: ptr must be a single item pointer if (info.size != .One) @compileError("ptr must be a single item pointer"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ src/css_scanner.zig:1031:32: error: unable to resolve inferred error set return err; ^~~ src/css_scanner.zig:1050:30: error: unable to resolve inferred error set return writeChunk(writer, chunk, true); ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ /snap/zig/8241/lib/std/mem/Allocator.zig:113:28: error: ptr must be a single item pointer if (info.size != .One) @compileError("ptr must be a single item pointer"); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```

Expected Output

more helpful error message

jacobly0 commented 10 months ago
  1. Mixup between free and destroy, missing reference trace is a duplicate of #16725.
  2. See the second half of this section. Note that a Ctrl+F for the error message takes you straight there.
  3. Probably one error for each generic instantiation, see 1 for missing reference trace and 2 for fix.