refactor: ban std.debug.assert (#10168)

* Ban `std.debug.assert`

* Create .clangd

* Update lint.yml

* Update linter.ts

* update

* lint

* Update linter.ts

* Update linter.ts

* update

* Update linter.ts

* update

* Update linter.ts

* more

* Update install.zig

* words

* Remove UB
This commit is contained in:
Jarred Sumner
2024-04-11 17:52:29 -07:00
committed by GitHub
parent 0f10d4f1be
commit 688844b472
149 changed files with 1314 additions and 1105 deletions

View File

@@ -458,15 +458,15 @@ pub const RunCommand = struct {
// a relative lookup, because in the case we do find it, we have to
// generate this full path anyways.
if (Environment.isWindows and bun.FeatureFlags.windows_bunx_fast_path and bun.strings.hasSuffixComptime(executable, ".exe")) {
std.debug.assert(std.fs.path.isAbsolute(executable));
bun.assert(std.fs.path.isAbsolute(executable));
// Using @constCast is safe because we know that
// `direct_launch_buffer` is the data destination that assumption is
// backed by the immediate assertion.
var wpath = @constCast(bun.strings.toNTPath(&BunXFastPath.direct_launch_buffer, executable));
std.debug.assert(bun.isSliceInBufferT(u16, wpath, &BunXFastPath.direct_launch_buffer));
bun.assert(bun.isSliceInBufferT(u16, wpath, &BunXFastPath.direct_launch_buffer));
std.debug.assert(wpath.len > bun.windows.nt_object_prefix.len + ".exe".len);
bun.assert(wpath.len > bun.windows.nt_object_prefix.len + ".exe".len);
wpath.len += ".bunx".len - ".exe".len;
@memcpy(wpath[wpath.len - "bunx".len ..], comptime bun.strings.w("bunx"));
@@ -806,7 +806,7 @@ pub const RunCommand = struct {
.ALREADY_EXISTS => {},
else => {
{
std.debug.assert(target_path_buffer[dir_slice.len] == '\\');
bun.assert(target_path_buffer[dir_slice.len] == '\\');
target_path_buffer[dir_slice.len] = 0;
std.os.mkdirW(target_path_buffer[0..dir_slice.len :0], 0) catch {};
target_path_buffer[dir_slice.len] = '\\';
@@ -1615,7 +1615,7 @@ pub const RunCommand = struct {
}
pub fn execAsIfNode(ctx: Command.Context) !void {
std.debug.assert(CLI.pretend_to_be_node);
bun.assert(CLI.pretend_to_be_node);
if (ctx.runtime_options.eval.script.len > 0) {
const trigger = bun.pathLiteral("/[eval]");
@@ -1673,12 +1673,12 @@ pub const BunXFastPath = struct {
if (!bun.FeatureFlags.windows_bunx_fast_path) return;
var ctx = ctx_const;
std.debug.assert(bun.isSliceInBufferT(u16, path_to_use, &BunXFastPath.direct_launch_buffer));
bun.assert(bun.isSliceInBufferT(u16, path_to_use, &BunXFastPath.direct_launch_buffer));
var command_line = BunXFastPath.direct_launch_buffer[path_to_use.len..];
debug("Attempting to find and load bunx file: '{}'", .{bun.fmt.utf16(path_to_use)});
if (Environment.allow_assert) {
std.debug.assert(std.fs.path.isAbsoluteWindowsWTF16(path_to_use));
bun.assert(std.fs.path.isAbsoluteWindowsWTF16(path_to_use));
}
const handle = (bun.sys.openFileAtWindows(
bun.invalid_fd, // absolute path is given