aboutsummaryrefslogtreecommitdiff
path: root/src/js_ast.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_ast.zig')
-rw-r--r--src/js_ast.zig38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig
index 7eede039c..1e608b54b 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -1626,6 +1626,14 @@ pub const E = struct {
rope_len: u32 = 0,
is_utf16: bool = false,
+ pub fn format(this: String, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
+ if (this.isUTF8()) {
+ try writer.writeAll(this.data);
+ } else {
+ try writer.print("{any}", .{JSC.ZigString.init16(this.slice16())});
+ }
+ }
+
pub var class = E.String{ .data = "class" };
pub fn push(this: *String, other: *String) void {
std.debug.assert(this.isUTF8());
@@ -4872,7 +4880,7 @@ pub const Macro = struct {
source,
import_range,
log.msgs.allocator,
- "Macro \"{any}\" not found",
+ "Macro \"{s}\" not found",
.{import_record_path},
.stmt,
err,
@@ -4884,7 +4892,7 @@ pub const Macro = struct {
source,
import_range,
log.msgs.allocator,
- "{any} resolving macro \"{any}\"",
+ "{s} resolving macro \"{s}\"",
.{ @errorName(err), import_record_path },
) catch unreachable;
return err;
@@ -5547,7 +5555,7 @@ pub const Macro = struct {
},
else => {
if (comptime Environment.isDebug) {
- Output.prettyWarnln("initExpr fail: {any}", .{@tagName(this.data)});
+ Output.prettyWarnln("initExpr fail: {s}", .{@tagName(this.data)});
}
return JSNode{ .loc = this.loc, .data = .{ .e_missing = .{} } };
},
@@ -5957,7 +5965,7 @@ pub const Macro = struct {
if (!@hasField(JSNode.Tag, name)) {
@compileError(
"JSNode.Tag does not have a \"" ++ name ++ "\" field. Valid fields are " ++ std.fmt.comptimePrint(
- "{any}",
+ "{s}",
.{
std.meta.fieldNames(@TypeOf(valid_tags)),
},
@@ -6709,7 +6717,7 @@ pub const Macro = struct {
Tag.e_super, Tag.e_null, Tag.e_undefined, Tag.e_missing, Tag.inline_true, Tag.inline_false, Tag.e_this => {
self.args.append(Expr{ .loc = loc, .data = Tag.ids.get(tag) }) catch unreachable;
},
- else => Global.panic("Tag \"{any}\" is not implemented yet.", .{@tagName(tag)}),
+ else => Global.panic("Tag \"{s}\" is not implemented yet.", .{@tagName(tag)}),
}
return true;
@@ -6745,7 +6753,7 @@ pub const Macro = struct {
tag_expr.loc,
);
},
- else => Global.panic("Not implemented yet top-level jsx element: {any}", .{@tagName(tag_expr.data)}),
+ else => Global.panic("Not implemented yet top-level jsx element: {s}", .{@tagName(tag_expr.data)}),
}
} else {
const loc = logger.Loc.Empty;
@@ -6782,16 +6790,12 @@ pub const Macro = struct {
var p = self.p;
const node_type: JSNode.Tag = JSNode.Tag.names.get(str.data) orelse {
- if (!str.isUTF8()) {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{any}\" is invalid", .{strings.toUTF8Alloc(self.p.allocator, str.slice16())}) catch unreachable;
- } else {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{any}\" is invalid", .{str.data}) catch unreachable;
- }
+ self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{any}\" is invalid", .{str}) catch unreachable;
return false;
};
if (!valid_tags.get(node_type)) {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{any}\" is invalid here", .{str.data}) catch unreachable;
+ self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{s}\" is invalid here", .{str}) catch unreachable;
}
return self.writeNodeType(node_type, element.properties.slice(), element.children.slice(), tag_expr.loc);
@@ -6805,9 +6809,9 @@ pub const Macro = struct {
const node_type: JSNode.Tag = JSNode.Tag.names.get(str.data) orelse {
if (!str.isUTF8()) {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{any}\" is invalid", .{strings.toUTF8Alloc(self.p.allocator, str.slice16())}) catch unreachable;
+ self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{s}\" is invalid", .{strings.toUTF8Alloc(self.p.allocator, str.slice16()) catch unreachable}) catch unreachable;
} else {
- self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{any}\" is invalid", .{str.data}) catch unreachable;
+ self.log.addErrorFmt(p.source, tag_expr.loc, p.allocator, "Tag \"{s}\" is invalid", .{str.data}) catch unreachable;
}
return false;
};
@@ -7838,7 +7842,7 @@ pub const Macro = struct {
this.source,
this.caller.loc,
this.allocator,
- "cannot coerce {any} to Bun's AST. Please return a valid macro using the JSX syntax",
+ "cannot coerce {s} to Bun's AST. Please return a valid macro using the JSX syntax",
.{@tagName(value.jsType())},
) catch unreachable;
break :brk error.MacroFailed;
@@ -8085,7 +8089,7 @@ pub const Macro = struct {
this.source,
this.caller.loc,
this.allocator,
- "cannot coerce {any} to Bun's AST. Please return a valid macro using the JSX syntax",
+ "cannot coerce {s} to Bun's AST. Please return a valid macro using the JSX syntax",
.{@tagName(value.jsType())},
) catch unreachable;
return error.MacroFailed;
@@ -8106,7 +8110,7 @@ pub const Macro = struct {
visitor: Visitor,
javascript_object: JSC.JSValue,
) MacroError!Expr {
- if (comptime Environment.isDebug) Output.prettyln("<r><d>[macro]<r> call <d><b>{any}<r>", .{function_name});
+ if (comptime Environment.isDebug) Output.prettyln("<r><d>[macro]<r> call <d><b>{s}<r>", .{function_name});
exception_holder = Zig.ZigException.Holder.init();
expr_nodes_buf[0] = JSNode.initExpr(caller);