oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.84k stars 2.73k forks source link

Zig tracking issue #5611

Open Jarred-Sumner opened 1 year ago

Jarred-Sumner commented 1 year ago

Zig is obviously great and we love it.

Specific painpoints

Safety checks for undefined are not good enough. That undefined is a user-visible number in debug builds and not in release builds has contributed to bugs. When the expected type is a large-ish number, it's very difficult to tell in debug builds whether a number is undefined or just a large number. A Zig developer has to use Valgrind to find out. This has contributed to bugs in bun install, in node:dns, the JS parser, and more. Especially in bun install - we often use an index into a buffer instead of a pointer, which means undefined is a consistent value instead of anything. EXC_BAD_ACCESS won't happen for a number.

IMO:

Example code which would should panic in debug builds but does not

assigning undefined without the undefined literal:
var foo = try allocator.create(Foo);
var baz = try allocator.create(Baz);
foo.* = .{
  .baz = baz,
};
Branching on undefined
var foo = try allocator.create(usize);
// ... sometime later ...
if (foo.* > 0) {
  // ... do stuff
}
More painpoints

Things which are not a priority for us:

heysokam commented 3 weeks ago

zig cc -Wno-everything might be of help