aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-11-01 04:04:18 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-11-01 04:04:18 -0700
commitbc5f99dc43c4f61546f15ed27485a8c6ec7472bd (patch)
treea2ca9aa5b667ef6d3c42d6e0397a0b05d193cbf1 /src
parent4d4966592e75f27b5f58a1c3132dae47bc6f6afc (diff)
downloadbun-bc5f99dc43c4f61546f15ed27485a8c6ec7472bd.tar.gz
bun-bc5f99dc43c4f61546f15ed27485a8c6ec7472bd.tar.zst
bun-bc5f99dc43c4f61546f15ed27485a8c6ec7472bd.zip
[internal] Tiny changes that will eventually make it easier to update zig
Diffstat (limited to 'src')
-rw-r--r--src/http.zig5
-rw-r--r--src/js_parser/js_parser.zig19
-rw-r--r--src/json_parser.zig6
-rw-r--r--src/resolver/tsconfig_json.zig4
-rw-r--r--src/string_immutable.zig2
5 files changed, 19 insertions, 17 deletions
diff --git a/src/http.zig b/src/http.zig
index 2ea79f953..59920003c 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -374,7 +374,7 @@ pub const RequestContext = struct {
comptime chunked: bool,
) !void {
defer {
- if (isDebug or isTest) {
+ if (Environment.isDebug or isTest) {
std.debug.assert(!ctx.has_written_last_header);
ctx.has_written_last_header = true;
}
@@ -500,7 +500,7 @@ pub const RequestContext = struct {
defer ctx.done();
try ctx.writeStatus(500);
const printed = std.fmt.bufPrint(&error_buf, "Error: {s}", .{@errorName(err)}) catch |err2| brk: {
- if (isDebug or isTest) {
+ if (Environment.isDebug or isTest) {
Global.panic("error while printing error: {s}", .{@errorName(err2)});
}
@@ -2494,7 +2494,6 @@ pub const Server = struct {
RequestContext.WebsocketHandler.broadcast(written_buf) catch |err| {
Output.prettyln("Error writing change notification: {s}<r>", .{@errorName(err)});
};
-
if (comptime is_emoji_enabled) {
Output.prettyln("<r>📜 <d>File change: {s}<r>", .{ctx.bundler.fs.relativeTo(file_path)});
} else {
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index 50a94d582..84e6b0b13 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -6802,7 +6802,7 @@ pub fn NewParser(
if (strings.eqlComptime(name, "require") and p.lexer.token == .t_open_paren) {
// "import ns = require('x')"
try p.lexer.next();
- var path = p.e(p.lexer.toEString(), p.lexer.loc());
+ const path = p.e(p.lexer.toEString(), p.lexer.loc());
try p.lexer.expect(.t_string_literal);
try p.lexer.expect(.t_close_paren);
const args = p.allocator.alloc(ExprNodeIndex, 1) catch unreachable;
@@ -13013,20 +13013,21 @@ pub fn NewParser(
p.popScope();
},
.s_local => |data| {
- for (data.decls) |*d| {
- p.visitBinding(d.binding, null);
+ var i: usize = 0;
+ while (i < data.decls.len) : (i += 1) {
+ p.visitBinding(data.decls[i].binding, null);
- if (d.value != null) {
- var val = d.value orelse unreachable;
+ if (data.decls[i].value != null) {
+ var val = data.decls[i].value.?;
const was_anonymous_named_expr = p.isAnonymousNamedExpr(val);
- d.value = p.visitExpr(val);
+ data.decls[i].value = p.visitExpr(val);
// Optionally preserve the name
- switch (d.binding.data) {
+ switch (data.decls[i].binding.data) {
.b_identifier => |id| {
- d.value = p.maybeKeepExprSymbolName(
- d.value.?,
+ data.decls[i].value = p.maybeKeepExprSymbolName(
+ data.decls[i].value.?,
p.symbols.items[id.ref.inner_index].original_name,
was_anonymous_named_expr,
);
diff --git a/src/json_parser.zig b/src/json_parser.zig
index d661d0b98..47eeb5669 100644
--- a/src/json_parser.zig
+++ b/src/json_parser.zig
@@ -37,9 +37,11 @@ const Op = js_ast.Op;
const Scope = js_ast.Scope;
const locModuleScope = logger.Loc.Empty;
+const LEXER_DEBUGGER_WORKAROUND = isDebug;
+
fn JSONLikeParser(opts: js_lexer.JSONOptions) type {
return struct {
- const Lexer = js_lexer.NewLexer(opts);
+ const Lexer = js_lexer.NewLexer(if (LEXER_DEBUGGER_WORKAROUND) js_lexer.JSONOptions{} else opts);
lexer: Lexer,
source: *const logger.Source,
@@ -282,7 +284,7 @@ pub fn ParseJSONForBundling(source: *const logger.Source, log: *logger.Log, allo
const result = try parser.parseExpr(false);
return JSONParseResult{
- .tag = if (parser.lexer.is_ascii_only) JSONParseResult.Tag.ascii else JSONParseResult.Tag.expr,
+ .tag = if (!LEXER_DEBUGGER_WORKAROUND and parser.lexer.is_ascii_only) JSONParseResult.Tag.ascii else JSONParseResult.Tag.expr,
.expr = result,
};
}
diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig
index bbd58f900..2d936dcf8 100644
--- a/src/resolver/tsconfig_json.zig
+++ b/src/resolver/tsconfig_json.zig
@@ -270,14 +270,14 @@ pub const TSConfigJSON = struct {
}
}
- if (isDebug and has_base_url) {
+ if (Environment.isDebug and has_base_url) {
std.debug.assert(result.base_url.len > 0);
}
var _result = allocator.create(TSConfigJSON) catch unreachable;
_result.* = result;
- if (isDebug and has_base_url) {
+ if (Environment.isDebug and has_base_url) {
std.debug.assert(_result.base_url.len > 0);
}
return _result;
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index 4c41b1e63..10f88fab9 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -395,7 +395,7 @@ inline fn eqlComptimeCheckLen(a: string, comptime b: anytype, comptime check_len
if (comptime b_ptr == b.len) return true;
}
- if ((comptime ( len & 1) != 0) and a[b_ptr] != comptime b[b_ptr]) return false;
+ if ((comptime (len & 1) != 0) and a[b_ptr] != comptime b[b_ptr]) return false;
return true;
}